phillipberndt / autorandr

Auto-detect the connected display hardware and load the appropriate X11 setup using xrandr
2.51k stars 124 forks source link

autorandr /usr/bin/autorandr:210: SyntaxWarning: invalid escape sequence '\s' XRANDR_OUTPUT_REGEXP = """(?x) /usr/bin/autorandr:236: SyntaxWarning: invalid escape sequence '\s' """ + XRANDR_PROPERTIES_REGEXP + """ | # Properties to include in the profile /usr/bin/autorandr:248: SyntaxWarning: invalid escape sequence '\S' XRANDR_OUTPUT_MODES_REGEXP = """(?x) /usr/bin/autorandr:592: SyntaxWarning: invalid escape sequence '\s' version = re.search("xrandr program version\s+([0-9\.]+)", version_string).group(1) /usr/bin/autorandr:888: SyntaxWarning: invalid escape sequence '\+' match = re.match("(?P<w>[0-9]+)x(?P<h>[0-9]+)(?:\+(?P<x>[0-9]+))?(?:\+(?P<y>[0-9]+))?.*", output.options["panning"]) #383

Open Castas115 opened 7 months ago

Castas115 commented 7 months ago

On a fresh install of autorandr I'm getting this error: /usr/bin/autorandr:210: SyntaxWarning: invalid escape sequence '\s' XRANDR_OUTPUT_REGEXP = """(?x) /usr/bin/autorandr:236: SyntaxWarning: invalid escape sequence '\s' """ + XRANDR_PROPERTIES_REGEXP + """ | # Properties to include in the profile /usr/bin/autorandr:248: SyntaxWarning: invalid escape sequence '\S' XRANDR_OUTPUT_MODES_REGEXP = """(?x) /usr/bin/autorandr:592: SyntaxWarning: invalid escape sequence '\s' version = re.search("xrandr program version\s+([0-9.]+)", version_string).group(1) /usr/bin/autorandr:888: SyntaxWarning: invalid escape sequence '+' match = re.match("(?P[0-9]+)x(?P[0-9]+)(?:+(?P[0-9]+))?(?:+(?P[0-9]+))?.*", output.options[panning"])

Python 3.12.2

hughdavenport commented 7 months ago

For what it is worth, it works for me on python 3.10.12 and python3.11.0rc1. Perhaps you could try an earlier version to see if you get the same issue or not to rule out the python version.

peter-fowles commented 7 months ago

I am encountering the exact same warning on a fresh install of autorandr, also on python 3.12.2 autorandr still runs just fine. It just outputs that same chain of SyntaxWarnings every time I run it.

reneas commented 7 months ago

I have the exact same warning but it only occured after upgrading from ubuntu 22.04 to 24.04 so maybe that is the problem?

i300220 commented 6 months ago

Every python code not ported to python 3.12 does that. Therefore autorandr is affected on Fedora 39 and 40. Not a autorandr bug per se.

pnickerson-cashstar commented 6 months ago

Here's a dumb, make it work for now fix:

See what versions of Python you have available:

ls -l /usr/bin/python*

If you have a Python version before 3.12, then you can try that. Use sudo and open the text file /usr/bin/autorandr for editing:

sudo nano /usr/bin/autorandr

At the top, where you see:

#! /usr/bin/python3 -sP

Change it to the earlier version of Python that you have. For example:

#! /usr/bin/python3.11 -sP

Write out and exit. I don't know whether this will mess up any future updates of autorandr that might show up in your OS's package manager.

patrick96 commented 6 months ago

Seems to be caused by the following:

A backslash-character pair that is not a valid escape sequence now generates a SyntaxWarning, instead of DeprecationWarning. For example, re.compile("\d+.\d+") now emits a SyntaxWarning ("\d" is an invalid escape sequence, use raw strings for regular expression: re.compile(r"\d+.\d+")). In a future Python version, SyntaxError will eventually be raised, instead of SyntaxWarning. (Contributed by Victor Stinner in gh-98401.)

From https://docs.python.org/3/whatsnew/3.12.html#other-language-changes

autorandr should probably switch to using raw strings when defining regular expressions

jlombera commented 4 months ago

This seems to be a duplicate of #368 , which is already fixed in upstream. Distributions just have to upgrade autorandr (or pull the fix) if they are using python 3.12 by default. (I was just affected too on Debian testing).