ietf-tools / xml2rfc

Generate RFCs and IETF drafts from document source in XML according to the IETF xml2rfc v2 and v3 vocabularies
https://ietf-tools.github.io/xml2rfc/
BSD 3-Clause "New" or "Revised" License
68 stars 38 forks source link

Regular expression related deprecation warnings with Python 3.12 #1073

Closed kitterma closed 8 months ago

kitterma commented 9 months ago

Describe the issue

With Python 3.12, I get the following deprecation warnings:

xml2rfc/utils.py:271: SyntaxWarning: invalid escape sequence '\S'
  text = re.sub('http:\S*', replacer, text)
xml2rfc/utils.py:273: SyntaxWarning: invalid escape sequence '\S'
  text = re.sub('https:\S*', replacer, text)
xml2rfc/utils.py:289: SyntaxWarning: invalid escape sequence '\s'
  element.text = re.sub('\s*\n\s*', ' ', \
xml2rfc/utils.py:290: SyntaxWarning: invalid escape sequence '\.'
  re.sub('\.\s*\n\s*', '.  ', \
xml2rfc/utils.py:294: SyntaxWarning: invalid escape sequence '\s'
  element.tail = re.sub('\s*\n\s*', ' ', \
xml2rfc/utils.py:295: SyntaxWarning: invalid escape sequence '\.'
  re.sub('\.\s*\n\s*', '.  ', \
xml2rfc/utils.py:583: SyntaxWarning: invalid escape sequence '\w'
  match = re.findall(u'(\w+(/\w+)+)', str)
xml2rfc/writers/base.py:612: SyntaxWarning: invalid escape sequence '\g'
  initials = re.sub('([^.]) ', '\g<1>. ', initials)
xml2rfc/writers/base.py:1350: SyntaxWarning: invalid escape sequence '\d'
  if docName and not rfcnum and not re.search('-\d\d$', docName):

This looks like the regular expressions change listed in "Other Language Changes" at What’s New In Python 3.12.

This is with xml2rfc 3.19.0.

Code of Conduct

jrlevine commented 9 months ago

Those quoted strings should all be r’…’ rather than ‘…’ or u’…’