Skip to content

Fix SyntaxWarning from invalid escape sequences in regex strings#29

Open
thegushi wants to merge 11 commits into
jaredmauch:mainfrom
thegushi:fix/invalid-escape-sequences
Open

Fix SyntaxWarning from invalid escape sequences in regex strings#29
thegushi wants to merge 11 commits into
jaredmauch:mainfrom
thegushi:fix/invalid-escape-sequences

Conversation

@thegushi
Copy link
Copy Markdown
Collaborator

Fixes #28 (bin/rmlist) and the same class of bug in bin/transcheck, contrib/check_perms_grsecurity.py, and contrib/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 SyntaxWarning in Python 3.12 and will become SyntaxError in 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\+

thegushi and others added 11 commits May 11, 2026 23:04
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>
@thegushi thegushi force-pushed the fix/invalid-escape-sequences branch from 448a300 to 8a52489 Compare May 20, 2026 22:49
@thegushi thegushi mentioned this pull request May 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

SyntaxWarning in bin/rmlist

1 participant