Skip to content

Python syntax warning appearing after image update #80

Description

@CovetingEpiphany2152

After updating the SONiC image and rebooting, these syntax warnings appear after the login prompt.

sonic login: [   23.426235] eth0 NIC Link is UP 1000 Mbps Full duplex
[   28.234708] sonic-ztp[2914]: /usr/lib/python3/dist-packages/ztp/Downloader.py:35: SyntaxWarning: invalid escape sequence '\c'
[   28.234807] sonic-ztp[2914]:   \code
[   28.236479] sonic-ztp[2914]: /usr/lib/python3/dist-packages/ztp/Logger.py:38: SyntaxWarning: invalid escape sequence '\c'
[   28.236516] sonic-ztp[2914]:   \code

\c is not a valid Python escape sequence. Since Python 3.12+, invalid escape sequences now emit SyntaxWarning (visible by default). In the future, they will be raised to SyntaxError.. python/cpython#98401

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

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