pop-os / system76-driver

System76 Driver for Pop!_OS
Other
111 stars 28 forks source link

Fix some invalid string escapes which are now warnings in Python 3.12 #297

Closed khumba closed 1 month ago

khumba commented 2 months ago

Hey,

Debian testing/sid and Gentoo now have Python 3.12 by default. One of the changes in 3.12 is that invalid string escape sequences now produce a SyntaxWarning (and in some future Python this will become an error). There are some invalid escapes in actions.py that cause the user-visible messages below. This PR fixes these two. I don't see warnings for any others in my build log.

Setting up system76-driver (20.04.91-0kh13.1) ...
WARNING invalid sys_vendor: 'Dell Inc.'
WARNING invalid product_version: None
/usr/lib/python3/dist-packages/system76driver/actions.py:46: SyntaxWarning: invalid escape sequence '\['
LSPCI_RE = re.compile('^(.+) \[(.+)\]$')
/usr/lib/python3/dist-packages/system76driver/actions.py:1132: SyntaxWarning: invalid escape sequence '\:'
LIMIT_TDP_SCRIPT = """#!/bin/sh

Thanks.

crawfxrd commented 1 month ago

Should all instances of regex use escaped strings? i.e., the CMDLINE_* lines above the changed lines.

jacobgkau commented 1 month ago

The issue with the ones being changed here seems to be the backslashes. Since the other strings don't have backslashes, Python doesn't think they contain escape sequences, so raw mode isn't really needed. I don't think it would hurt anything, though.

khumba commented 1 month ago

Thanks folks!