mirror of
git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2025-04-13 09:59:31 +00:00
kselftest/devices/probe: Fix SyntaxWarning in regex strings for Python3
Insert raw strings to prevent Python3 from interpreting string literals
as Unicode strings and "\d" as invalid escaped sequence.
Fix the warnings:
tools/testing/selftests/devices/probe/test_discoverable_devices.py:48:
SyntaxWarning: invalid escape sequence '\d' usb_controller_sysfs_dir =
"usb[\d]+"
tools/testing/selftests/devices/probe/test_discoverable_devices.py: 94:
SyntaxWarning: invalid escape sequence '\d' re_usb_version =
re.compile("PRODUCT=.*/(\d)/.*")
Fixes: dacf1d7a78
("kselftest: Add test to verify probe of devices from discoverable buses")
Reviewed-by: Nícolas F. R. A. Prado <nfraprado@collabora.com>
Signed-off-by: Alessandro Zanni <alessandro.zanni87@gmail.com>
Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>
This commit is contained in:
parent
160c826b4d
commit
a19008256d
1 changed files with 2 additions and 2 deletions
|
@ -45,7 +45,7 @@ def find_pci_controller_dirs():
|
|||
|
||||
|
||||
def find_usb_controller_dirs():
|
||||
usb_controller_sysfs_dir = "usb[\d]+"
|
||||
usb_controller_sysfs_dir = r"usb[\d]+"
|
||||
|
||||
dir_regex = re.compile(usb_controller_sysfs_dir)
|
||||
for d in os.scandir(sysfs_usb_devices):
|
||||
|
@ -91,7 +91,7 @@ def get_acpi_uid(sysfs_dev_dir):
|
|||
|
||||
|
||||
def get_usb_version(sysfs_dev_dir):
|
||||
re_usb_version = re.compile("PRODUCT=.*/(\d)/.*")
|
||||
re_usb_version = re.compile(r"PRODUCT=.*/(\d)/.*")
|
||||
with open(os.path.join(sysfs_dev_dir, "uevent")) as f:
|
||||
return int(re_usb_version.search(f.read()).group(1))
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue