Fix SyntaxWarning from invalid escape sequences in regex strings#29
Open
thegushi wants to merge 11 commits into
Open
Fix SyntaxWarning from invalid escape sequences in regex strings#29thegushi wants to merge 11 commits into
thegushi wants to merge 11 commits into
Conversation
iconv -o is a GNU iconv extension not supported on BSD. Replace the subprocess call with Python's own open() encoding support, which is portable and removes the iconv dependency entirely.
Replace file -bi encoding detection with a Python-native UTF-8 open attempt. If the file opens cleanly as UTF-8, skip it; otherwise convert from the known locale encoding. No external tools needed.
Detects legacy SHA1 hex digest passwords that need upgrading to the PBKDF2 format introduced by hash_password().
sha_new() requires bytes in Python 3 but was receiving a str. Switch to hash_password() so new lists get PBKDF2 hashes from the start rather than legacy SHA1. Fixes jaredmauch#24.
'Hit enter to notify %(listname)s owner...' was never interpolated. Replace print()+readline() with input() which handles both the prompt and waiting for Enter in one call.
check_perms and Mailman/MTA/Postfix.py both had Python 2-style
print C_('...') % locals(), statements where the migration to Python 3
dropped the % locals() substitution, leaving literal %(varname)s in
error output. Also fix two bare print -> print() in Postfix.py.
BSD make does not have a wildcard function -- it treats the argument as a variable name with spaces, generating warnings. Use $(POFILES) in messages/ (already defined) and drop the dependency list in templates/ (stamp file is sufficient for a clean build).
distutils was removed in Python 3.12. The configure check was using
distutils.sysconfig solely to verify Python development headers exist.
Replace with the sysconfig stdlib module (available since Python 3.2)
using sysconfig.get_path('include') in place of get_python_inc().
Use raw strings (r"...") for regex patterns in bin/rmlist, bin/transcheck, contrib/check_perms_grsecurity.py, and contrib/courier-to-mailman.py. Bare \d, \w, \(, \+, \. etc. in non-raw strings are deprecated in Python 3.12 (SyntaxWarning) and will become SyntaxErrors in Python 3.14. Fixes jaredmauch#28 (bin/rmlist); also addresses the same class of bug in transcheck and two contrib scripts. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
448a300 to
8a52489
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #28 (
bin/rmlist) and the same class of bug inbin/transcheck,contrib/check_perms_grsecurity.py, andcontrib/courier-to-mailman.py.All affected regex patterns used bare
\d,\w,\(,\+,\.etc. in non-raw Python strings. Changed to raw strings (r"...") throughout.Unrecognized escape sequences in non-raw strings produce
SyntaxWarningin Python 3.12 and will becomeSyntaxErrorin Python 3.14.Files changed:
bin/rmlist:131—\d,\.bin/transcheck:285,287,331—\(,\)bin/transcheck:367,368—\.contrib/check_perms_grsecurity.py:160,162—\(contrib/courier-to-mailman.py:83,85—\+