Skip to content

Conversation

@ukleinek
Copy link

Starting with Python 3.12 during byte compilation the following warnings are emitted:

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

Fix them by using raw strings or quoting as appropriate.

The patch is taken from https://bugs.debian.org/1085633, I just expanded the commit log a bit.

Starting with Python 3.12 during byte compilation the following warnings
are emitted:

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

Fix them by using raw strings or quoting as appropriate.

Closes: projecthamster#769
@ukleinek ukleinek force-pushed the python3.12-syntax-warnings branch from ee649fb to 0061b45 Compare March 10, 2025 09:43
Copy link
Member

@matthijskooijman matthijskooijman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Have not tested yet.

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 this pull request may close these issues.

3 participants