zhangyu836 / xltpl

A python module to generate xls/x files from a xls/x template.
MIT License
71 stars 17 forks source link

Regex SyntaxWarning #27

Open Yelinz opened 2 months ago

Yelinz commented 2 months ago

Using python 3.12 a regex DeprecationWarning got upgraded to SyntaxWarning.

.../lib/python3.12/site-packages/xltpl/utils.py:23: SyntaxWarning: invalid escape sequence '\d'
  COORD = '[a-z]{1,3}\d+'
.../lib/python3.12/site-packages/xltpl/utils.py:24: SyntaxWarning: invalid escape sequence '\S'
  RANGETAG = '%s *%s *(%s:%s\S*?) *%s' % (RANGE, VARIABLE_START_STRING, COORD, COORD, VARIABLE_END_STRING)
.../lib/python3.12/site-packages/xltpl/utils.py:111: SyntaxWarning: invalid escape sequence '\d'
  FIXTEST = '({(?:___\d+___)?(?:{|%).+?(?:}|%)(?:___\d+___)?})'
.../lib/python3.12/site-packages/xltpl/utils.py:112: SyntaxWarning: invalid escape sequence '\d'
  RUNSPLIT = '(___\d+___)'
.../lib/python3.12/site-packages/xltpl/utils.py:113: SyntaxWarning: invalid escape sequence '\d'
  RUNSPLIT2 = '___(\d+)___'
.../lib/python3.12/site-packages/xltpl/jinja.py:25: SyntaxWarning: invalid escape sequence '\d'
  p = re.compile("'(\d*,\d*[,\d]*)'")

A backslash-character pair that is not a valid escape sequence now generates a SyntaxWarning, instead of DeprecationWarning. For example, re.compile("\d+.\d+") now emits a SyntaxWarning ("\d" is an invalid escape sequence, use raw strings for regular expression: re.compile(r"\d+.\d+")). In a future Python version, SyntaxError will eventually be raised, instead of SyntaxWarning.

from https://docs.python.org/3/whatsnew/3.12.html#other-language-changes