[BUG Report]:
Kuchiriel opened this issue · 1 comments
Kuchiriel commented
Version
2.4 (Default)
Which section is the problem?
Script Base
Please complete the following information
- OS: WSL Ubuntu 24.04.1 LTS
- Python Version 3.12
What happened (Describe the bug) ?
MHDDoS/start.py:169: SyntaxWarning: invalid escape sequence '\d'
protocolRex = compile('"protocol":(\d+)')
MHDDoS/start.py:168: SyntaxWarning: invalid escape sequence '\d'
IP = compile("(?:\d{1,3}.){3}\d{1,3}")
Screenshots
No need
Please provide a link to a minimal reproduction of the bug
No response
Relevant log output
MHDDoS/start.py:169: SyntaxWarning: invalid escape sequence '\d'
protocolRex = compile('"protocol":(\d+)')
MHDDoS/start.py:168: SyntaxWarning: invalid escape sequence '\d'
IP = compile("(?:\d{1,3}.){3}\d{1,3}")
Additional context
Merge PR
Your code
The issue seems to be with the escape sequences in the regular expression. Here's how to manually address this:
Locate the problematic lines:
IP = compile("(?:\d{1,3}.){3}\d{1,3}")
protocolRex = compile('"protocol":(\d+)')
Modify these lines to use raw strings (r"..."):
Replace:
IP = compile("(?:\d{1,3}.){3}\d{1,3}")
protocolRex = compile('"protocol":(\d+)')
IP = compile(r"(?:\d{1,3}.){3}\d{1,3}")
protocolRex = compile(r'"protocol":(\d+)')
Explanation:
Raw Strings (r"..."): Using raw strings in Python helps prevent issues with escape sequences. This is particularly useful in regular expressions where backslashes are common.
The lines should look exactly like this:
IP = compile(r"(?:\d{1,3}.){3}\d{1,3}")
protocolRex = compile(r'"protocol":(\d+)')
MHDDoS/start.py:169: SyntaxWarning: invalid escape sequence '\d'
protocolRex = compile('"protocol":(\d+)')
MHDDoS/start.py:168: SyntaxWarning: invalid escape sequence '\d'
IP = compile("(?:\d{1,3}.){3}\d{1,3}")
Kuchiriel commented
Even if you dont accept the PR and closed the issue with no comments, can you please fix this? Thank you.