Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[3.1.7] SyntaxWarning: invalid escape sequence '\<something>' with Python 3.12 #181

Open
picca opened this issue Dec 18, 2023 · 2 comments

Comments

@picca
Copy link

picca commented Dec 18, 2023

Hello, Python3.12 seems to detect malformed strings like this.

I am wondering if these strings should not be marked with r'' in order to avoid interpretation of the escape sequences.

Setting up python3-uncertainties (3.1.7-1.1) ...
/usr/lib/python3/dist-packages/uncertainties/test_uncertainties.py:1707: SyntaxWarning: invalid escape sequence '\p'
  'fL': '1234.57 \pm 0.10',
/usr/lib/python3/dist-packages/uncertainties/test_uncertainties.py:1708: SyntaxWarning: invalid escape sequence '\p'
  'FL': '1234.57 \pm 0.10',
/usr/lib/python3/dist-packages/uncertainties/test_uncertainties.py:1709: SyntaxWarning: invalid escape sequence '\p'
  'fL': '1234.57 \pm 0.10',
/usr/lib/python3/dist-packages/uncertainties/test_uncertainties.py:1710: SyntaxWarning: invalid escape sequence '\p'
  'FL': '1234.57 \pm 0.10',
/usr/lib/python3/dist-packages/uncertainties/test_uncertainties.py:1750: SyntaxWarning: invalid escape sequence '\m'
  'PSL': u'-1.2(\mathrm{nan})×10⁻¹²',
/usr/lib/python3/dist-packages/uncertainties/test_uncertainties.py:1829: SyntaxWarning: invalid escape sequence '\p'
  'fL': '1234.567890 \pm 0',
/usr/lib/python3/dist-packages/uncertainties/test_uncertainties.py:1830: SyntaxWarning: invalid escape sequence '\p'
  'FL': '1234.567890 \pm 0',
/usr/lib/python3/dist-packages/uncertainties/test_uncertainties.py:1995: SyntaxWarning: invalid escape sequence '\i'
  'LS': '-\infty(\infty)',
/usr/lib/python3/dist-packages/uncertainties/test_uncertainties.py:1996: SyntaxWarning: invalid escape sequence '\i'
  'L': '-\infty \pm \infty',
/usr/lib/python3/dist-packages/uncertainties/test_uncertainties.py:1997: SyntaxWarning: invalid escape sequence '\i'
  'LP': u'-\infty±\infty',
/usr/lib/python3/dist-packages/uncertainties/test_uncertainties.py:2021: SyntaxWarning: invalid escape sequence '\m'
  'LS': '\mathrm{nan}(\infty)',
/usr/lib/python3/dist-packages/uncertainties/test_uncertainties.py:2022: SyntaxWarning: invalid escape sequence '\m'
  'L': '\mathrm{nan} \pm \infty',
/usr/lib/python3/dist-packages/uncertainties/test_uncertainties.py:2023: SyntaxWarning: invalid escape sequence '\m'
  'LP': u'\mathrm{nan}±\infty'
@lebigot
Copy link
Collaborator

lebigot commented Dec 18, 2023

Indeed:

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.)

This should be fixed. I can work on that. In the meantime, anybody's very welcome to do it, but then please leave a note here when you start!

@newville
Copy link
Member

@lebigot see #182

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 a pull request may close this issue.

3 participants