Skip to content

Commit a190082

Browse files
Alez87shuahkh
authored andcommitted
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: dacf1d7 ("kselftest: Add test to verify probe of devices from discoverable buses") Reviewed-by: Nícolas F. R. A. Prado <[email protected]> Signed-off-by: Alessandro Zanni <[email protected]> Signed-off-by: Shuah Khan <[email protected]>
1 parent 160c826 commit a190082

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

tools/testing/selftests/devices/probe/test_discoverable_devices.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ def find_pci_controller_dirs():
4545

4646

4747
def find_usb_controller_dirs():
48-
usb_controller_sysfs_dir = "usb[\d]+"
48+
usb_controller_sysfs_dir = r"usb[\d]+"
4949

5050
dir_regex = re.compile(usb_controller_sysfs_dir)
5151
for d in os.scandir(sysfs_usb_devices):
@@ -91,7 +91,7 @@ def get_acpi_uid(sysfs_dev_dir):
9191

9292

9393
def get_usb_version(sysfs_dev_dir):
94-
re_usb_version = re.compile("PRODUCT=.*/(\d)/.*")
94+
re_usb_version = re.compile(r"PRODUCT=.*/(\d)/.*")
9595
with open(os.path.join(sysfs_dev_dir, "uevent")) as f:
9696
return int(re_usb_version.search(f.read()).group(1))
9797

0 commit comments

Comments
 (0)