sahib / rmlint

Extremely fast tool to remove duplicates and other lint from your filesystem
http://rmlint.rtfd.org
GNU General Public License v3.0
1.85k stars 128 forks source link

SyntaxWarning: invalid escape sequence #655

Open ryandesign opened 3 months ago

ryandesign commented 3 months ago

If scons uses python 3.12 or later, these warnings appear:

scons: Reading SConscript files ...
SConstruct:839: SyntaxWarning: invalid escape sequence '\.'
  'sed -i "s/2\.0\.0/{v}/g" po/rmlint.pot',
SConstruct:840: SyntaxWarning: invalid escape sequence '\('
  'sed -i "s/^Version:\(\s*\)2\.0\.0/Version:\\1{v}/g" pkg/fedora/rmlint.spec'

See https://docs.python.org/3/library/re.html:

The solution is to use Python’s raw string notation for regular expression patterns; backslashes are not handled in any special way in a string literal prefixed with 'r'. So r"\n" is a two-character string containing '\' and 'n', while "\n" is a one-character string containing a newline. Usually patterns will be expressed in Python code using this raw string notation.