movescreen icon indicating copy to clipboard operation
movescreen copied to clipboard

Python SyntaxWarning error Xubuntu 24.04

Open IainMcCracken opened this issue 1 year ago • 2 comments

I just built a new VM with Xubuntu 24.04. I changed the shebang to point to python3, but I get a new error (didn't get this error in Xubuntu 22.04):

/usr/local/bin/movescreen.py:49: SyntaxWarning: invalid escape sequence '+' reg = re.compile(" connected( primary)? ([0-9]+)x([0-9]+)+([0-9]+)+([0-9]+)")

Not being a Python programmer, I don't know what changed. Python version is 3.12.3.

IainMcCracken avatar Sep 14 '24 18:09 IainMcCracken

I could not try yet with more recent python versions but after searching a bit, the solution might be :

Change the original line: reg = re.compile(" connected( primary)? ([0-9]+)x([0-9]+)\+([0-9]+)\+([0-9]+)") to (double the backslahs): reg = re.compile(" connected( primary)? ([0-9]+)x([0-9]+)\\+([0-9]+)\\+([0-9]+)") or maybe (declare the string as raw): reg = re.compile(r" connected( primary)? ([0-9]+)x([0-9]+)\\+([0-9]+)\\+([0-9]+)")

calandoa avatar Sep 16 '24 12:09 calandoa

I'm using Python 3.12.3 on Linux Mint 22 (Ubuntu 24.04). Second solution works well:

reg = re.compile(" connected( primary)? ([0-9]+)x([0-9]+)\\+([0-9]+)\\+([0-9]+)")

nitso avatar Jan 30 '25 10:01 nitso