ulif/diceware

Invalid escape sequence warning with Python 3.12

SoMuchForSubtlety opened this issue · 1 comments

Running diceware with python 3.12 results in the following warnings

/usr/lib/python3.12/site-packages/diceware/wordlist.py:32: SyntaxWarning: invalid escape sequence '\w'
  RE_WORDLIST_NAME = re.compile('^[\w-]+$')
/usr/lib/python3.12/site-packages/diceware/wordlist.py:35: SyntaxWarning: invalid escape sequence '\-'
  RE_NUMBERED_WORDLIST_ENTRY = re.compile('^[0-9]+(\-[0-9]+)*\s+([^\s]+)$')
/usr/lib/python3.12/site-packages/diceware/wordlist.py:39: SyntaxWarning: invalid escape sequence '\w'
  '^wordlist_([\w-]+)\.[\w][\w\.]+[\w]+$')

From the python 3.12 release notes1:

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. (Contributed by Victor Stinner in gh-98401.)

Footnotes

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

Looks like this was fixed in c1aa7b1