GeezerVison is showing github.com — Invalid escape sequences raise SyntaxWarning · Issue #119458 · python/cpython
Invalid escape sequences raise SyntaxWarning #119458
Description
PEP 701 introduced with python version 3.12.3 claims to be backwards compatible.
But in python version 3.12.2 the string "\.00" gives \\.00 and since python version 3.12.3 I get the follwing error:
<stdin>:1: SyntaxWarning: invalid escape sequence '\.'
'\\.00'
Activity
pablogsal commented on May 23, 2024
That has nothing to be with PEP 701. PEP 701 is about f-strings, not about strings in general. That change was introduced here:
3483299a24e4
terryjreedy commented on May 23, 2024
The referenced commit is about octal sequences above 0o377. The warning results from changing the invalid escape sequence warning from DeprecationWarning (usually invisible) to SyntaxWarning (usually visible, but not currently in IDLE and other possible circumstances) in 3.12 in issue #98401, PR #99011. The same warning occurs with '\.a' and '\.'.
The change was in 3.12.0 and noted in What' New 3.12:
A backslash-character pair that is not a valid escape sequence now generates a SyntaxWarning, instead of DeprecationWarning.
If you want a single backslash in the string, either double it or precede the string with 'r': '\\.00' == r'\.00' is True.
Reacted by Pablo Galindo Salgado
changed the title
[-]PEP 701 is not backwards compatible[/-] [+]Invalid escape sequences raise SyntaxWarning[/+] on May 23, 2024Okarin99 commented on May 23, 2024
Ahh ok that explains everything. I got this Error because Mathematica’s ExternalEvaluate uses an invalid escape sequence and I knew that in march all was working fine. I regularly update my system so I thought I was using python version 3.12.2 in march. But it turns out that Archlinux doesn’t update their python package that often, therefore I was using version 3.11.8 instead.
Metadata
Metadata
Development
No branches or pull requestsIssue actions