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

fix: invalid escape sequence #112

Merged
merged 1 commit into from
Feb 9, 2024
Merged

fix: invalid escape sequence #112

merged 1 commit into from
Feb 9, 2024

Conversation

olemoign
Copy link
Contributor

@olemoign olemoign commented Feb 8, 2024

Normal strings regex produce "SyntaxWarning: invalid escape sequence" for special chars like "&", "\d" and "\S".
Transform those normal strings to raw strings to fix this.

@svituz
Copy link
Member

svituz commented Feb 8, 2024

Hi,
I'm not sure I'm getting the problem you're trying to solve.
Can you provide a snippet that replicates the bug?

@olemoign
Copy link
Contributor Author

olemoign commented Feb 8, 2024

Hi,
this is not a huge problem as those are warnings only, so I expect the regex to still work.
I think those warnings appeared with python 3.12, as I don't remember seeing them before.
I don't know if they appear again during a call to the respective functions, I see them during the start of my app, which imports hl7apy, so this happens during the parsing of the python code.

@olemoign
Copy link
Contributor Author

olemoign commented Feb 8, 2024

The logs:

/usr/local/lib/python3.12/site-packages/hl7apy/exceptions.py:45: SyntaxWarning: invalid escape sequence '&'
"""
/usr/local/lib/python3.12/site-packages/hl7apy/parser.py:40: SyntaxWarning: invalid escape sequence '&'
"""
/usr/local/lib/python3.12/site-packages/hl7apy/parser.py:637: SyntaxWarning: invalid escape sequence '\S'
m = re.match("^MSH(?P<field_sep>\S)", content)
/usr/local/lib/python3.12/site-packages/hl7apy/core.py:117: SyntaxWarning: invalid escape sequence '\d'
regex = '^z[a-z1-9]{2}_\d+$'
/usr/local/lib/python3.12/site-packages/hl7apy/utils.py:116: SyntaxWarning: invalid escape sequence '\d'
offset = re.search('\d*((+(1[0-4]|0[0-9])|(-(1[0-2]|0[0-9])))([0-5][0-9]))$', value)

@olemoign
Copy link
Contributor Author

olemoign commented Feb 8, 2024

I think the first two logs are linked to DEFAULT_ENCODING_CHARS but I couldn't test it.

@svituz svituz merged commit c59242b into crs4:develop Feb 9, 2024
9 of 18 checks passed
@svituz
Copy link
Member

svituz commented Feb 9, 2024

thanks

@olemoign olemoign deleted the regex branch March 18, 2024 23:27
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