Skip to content

Python 3.12 and 3.13 emit "SyntaxWarning: invalid escape sequence" #7

@hacklschorsch

Description

@hacklschorsch

Similar to https://tahoe-lafs.org/trac/tahoe-lafs/ticket/4158 and tahoe-lafs/tahoe-lafs#1427:

From https://stackoverflow.com/a/77531416/1181063:

Back in Python 3.6, using invalid escape sequences in string literals was deprecated (bpo-27364). Since then, attempting to use an invalid escape sequence has emitted a DeprecationWarning. This can often go unnoticed if you don't run Python with warnings enabled. DeprecationWarnings are silenced by default.

Python 3.12 upgraded the DeprecationWarning to a SyntaxWarning. SyntaxWarnings are emitted by the compiler when the code is parsed, not when it's being run, so they cannot be ignored using a runtime warning filter. Unlike DeprecationWarnings, SyntaxWarnings are displayed by default, which is why you're seeing it now. This increase in visibility was intentional. In a future version of Python, using invalid escape sequences in string literals is planned to eventually become a hard SyntaxError.

Setting up python3-txi2p-tahoe (0.3.7-3) ...
/usr/lib/python3/dist-packages/txi2p/test/test_plugins.py:69: SyntaxWarning: invalid escape sequence '\:'
  MemoryReactor(), "i2p:stats.i2p:apiEndpoint=tcp\:127.0.0.1\:2827")
/usr/lib/python3/dist-packages/txi2p/test/test_plugins.py:81: SyntaxWarning: invalid escape sequence '\:'
  MemoryReactor(), "i2p:stats.i2p:api=BOB:tunnelNick=spam:inport=12345:options=inbound.length\:5,outbound.length\:5")
/usr/lib/python3/dist-packages/txi2p/test/test_plugins.py:93: SyntaxWarning: invalid escape sequence '\:'
  MemoryReactor(), "i2p:stats.i2p:81:api=SAM:localPort=34444:options=inbound.length\:5,outbound.length\:5:sigType=foobar")
/usr/lib/python3/dist-packages/txi2p/test/test_plugins.py:125: SyntaxWarning: invalid escape sequence '\:'
  MemoryReactor(), "i2p:/tmp/testkeys.foo:apiEndpoint=tcp\:127.0.0.1\:2827")
/usr/lib/python3/dist-packages/txi2p/test/test_plugins.py:137: SyntaxWarning: invalid escape sequence '\:'
  MemoryReactor(), "i2p:/tmp/testkeys.foo:api=BOB:tunnelNick=spam:outport=23456:options=inbound.length\:5,outbound.length\:5")
/usr/lib/python3/dist-packages/txi2p/test/test_plugins.py:149: SyntaxWarning: invalid escape sequence '\:'
  MemoryReactor(), "i2p:/tmp/testkeys.foo:81:api=SAM:options=inbound.length\:5,outbound.length\:5:sigType=foobar")

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions