Skip to content

SyntaxWarning with Python 3.12 and newer #769

@rhertzog

Description

@rhertzog

With Python 3.12 and newer you get SyntaxWarning warnings when byte-compiling the hamster's code:

  /usr/lib/python3/dist-packages/hamster/lib/datetime.py:471:
SyntaxWarning: invalid escape sequence '\s'
    position="exact", separator="\s+", default_day=None, ref="now"):
  /usr/lib/python3/dist-packages/hamster/lib/datetime.py:472:
SyntaxWarning: invalid escape sequence '\s'
    """Parse a start-end range from text.
  /usr/lib/python3/dist-packages/hamster/widgets/activityentry.py:381:
SyntaxWarning: invalid escape sequence '\s'
    fragments = [f for f in re.split("[\s|#]", text)]
  /usr/lib/python3/dist-packages/hamster/widgets/timeinput.py:141:
SyntaxWarning: invalid escape sequence '\D'
    numbers = re.split("\D", str_time)

All those strings should be turned into regexp-quoted strings (with a leading r): r"\s+" for example.

(Initially reported in Debian here: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1085633)

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