Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

osc2_scenario: Fix SyntaxWarnings #1122

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

wentasah
Copy link

@wentasah wentasah commented Oct 16, 2024

Checklist:

  • Your branch is up-to-date with the master branch and tested with latest changes
  • Extended the README / documentation, if necessary
  • Code compiles correctly and runs
  • Code is formatted and checked with Utilities/code_check_and_formatting.sh
  • Changelog is updated

Description

This fixes warnings like the one below:

.../srunner/scenarios/osc2_scenario.py:515: SyntaxWarning: invalid escape sequence '\W'
expression_value = re.split("\W+", option)

These were introduced in Python 3.12. See https://docs.python.org/3.12/reference/lexical_analysis.html#escape-sequences.

Where has this been tested?

  • Platform(s): Linux
  • Python version(s): 3.12
  • Unreal Engine version(s): 4.26
  • CARLA version: 0.9.15

Possible Drawbacks

Hopefully none. r-strings are available even in Python 2.6, so this should work even with older Python versions.


This change is Reviewable

This fixes warnings like the one below:

    .../srunner/scenarios/osc2_scenario.py:515: SyntaxWarning: invalid escape sequence '\W'
    expression_value = re.split("\W+", option)
Copy link
Contributor

@Daraan Daraan left a comment

Choose a reason for hiding this comment

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

LGTM, I am no maintainer though. Raw strings are indeed already present in Python2 and \W is not a escape sequence recognized by python.

I would encourage their usage for regex much more as it helps to avoid mistakes and future compatibility.

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.

2 participants