Skip to content

Commit

Permalink
wrapper: use raw string literals for regular expressions (#946)
Browse files Browse the repository at this point in the history
This fixes a SyntaxWarning with Python 3.12:

/usr/lib/nzbhydra2/nzbhydra2wrapperPy3.py:584: SyntaxWarning: invalid escape sequence '\d'
  match = re.match('(java|openjdk) (version )?"?(?P<major>\d+)((\.(?P<minor>\d+)\.(?P<patch>\d)+)?[\-_\w]*)?"?.*', versionLine)

Although Python 2 doesn't print a warning, using a raw string literal is
the correct thing to do, so I applied this change to the Python 2
wrapper as well.
  • Loading branch information
jkhsjdhjs authored May 23, 2024
1 parent d3b465e commit fbddaf2
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion other/wrapper/nzbhydra2wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -548,7 +548,7 @@ def getJavaVersion(javaExecutable):
if len(lines) == 0:
raise Exception("Unable to get output from call to java -version")
versionLine = lines[0].replace("\n", "").replace("\r", "")
match = re.match('(java|openjdk) (version )?"?(?P<major>\d+)((\.(?P<minor>\d+)\.(?P<patch>\d)+)?[\-_\w]*)?"?.*',
match = re.match(r'(java|openjdk) (version )?"?(?P<major>\d+)((\.(?P<minor>\d+)\.(?P<patch>\d)+)?[\-_\w]*)?"?.*',
versionLine)
if match is None:
raise Exception("Unable to determine java version from string " + lines[0])
Expand Down
2 changes: 1 addition & 1 deletion other/wrapper/nzbhydra2wrapperPy3.py
Original file line number Diff line number Diff line change
Expand Up @@ -581,7 +581,7 @@ def getJavaVersion(javaExecutable):
if len(lines) == 0:
raise Exception("Unable to get output from call to java -version")
versionLine = lines[0].replace("\n", "").replace("\r", "")
match = re.match('(java|openjdk) (version )?"?(?P<major>\d+)((\.(?P<minor>\d+)\.(?P<patch>\d)+)?[\-_\w]*)?"?.*', versionLine)
match = re.match(r'(java|openjdk) (version )?"?(?P<major>\d+)((\.(?P<minor>\d+)\.(?P<patch>\d)+)?[\-_\w]*)?"?.*', versionLine)
if match is None:
raise Exception("Unable to determine java version from string " + lines[0])
javaMajor = int(match.group("major"))
Expand Down

0 comments on commit fbddaf2

Please sign in to comment.