Skip to content

Commit

Permalink
Use raw strings for Python regexps to avoid Python 3.12 error
Browse files Browse the repository at this point in the history
  • Loading branch information
dhalbert committed Oct 29, 2023
1 parent 17e70bf commit a30269c
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions utils/uf2conv.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def is_hex(buf):
w = buf[0:30].decode("utf-8")
except UnicodeDecodeError:
return False
if w[0] == ':' and re.match(b"^[:0-9a-fA-F\r\n]+$", buf):
if w[0] == ':' and re.match(rb"^[:0-9a-fA-F\r\n]+$", buf):
return True
return False

Expand Down Expand Up @@ -208,7 +208,7 @@ def get_drives():
"get", "DeviceID,", "VolumeName,",
"FileSystem,", "DriveType"])
for line in to_str(r).split('\n'):
words = re.split('\s+', line)
words = re.split(r'\s+', line)
if len(words) >= 3 and words[1] == "2" and words[2] == "FAT":
drives.append(words[0])
else:
Expand Down Expand Up @@ -237,7 +237,7 @@ def has_info(d):
def board_id(path):
with open(path + INFO_FILE, mode='r') as file:
file_content = file.read()
return re.search("Board-ID: ([^\r\n]*)", file_content).group(1)
return re.search(r"Board-ID: ([^\r\n]*)", file_content).group(1)


def list_drives():
Expand Down

0 comments on commit a30269c

Please sign in to comment.