Skip to content

Commit

Permalink
Pass str instead of bytes to str.startswith and str.endswith
Browse files Browse the repository at this point in the history
…in winappdbg

In Python 3, `str.startswith` and `str.endswith`  methods no longer accept `bytes`, resulting in `TypeError: startswith first arg must be str or a tuple of str, not bytes`
  • Loading branch information
artemmukhin authored and fabioz committed Oct 7, 2023
1 parent 1cf4e31 commit 21e6b3d
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions pydevd_attach_to_process/winappdbg/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -293,10 +293,10 @@ def native_to_win32_pathname(name):
# XXX TODO
# There are probably some native paths that
# won't be converted by this naive approach.
if name.startswith(compat.b("\\")):
if name.startswith(compat.b("\\??\\")):
if name.startswith("\\"):
if name.startswith("\\??\\"):
name = name[4:]
elif name.startswith(compat.b("\\SystemRoot\\")):
elif name.startswith("\\SystemRoot\\"):
system_root_path = os.environ['SYSTEMROOT']
if system_root_path.endswith('\\'):
system_root_path = system_root_path[:-1]
Expand All @@ -312,10 +312,10 @@ def native_to_win32_pathname(name):
win32.ERROR_PATH_NOT_FOUND):
continue
raise
if not device_native_path.endswith(compat.b('\\')):
device_native_path += compat.b('\\')
if not device_native_path.endswith('\\'):
device_native_path += '\\'
if name.startswith(device_native_path):
name = drive_letter + compat.b('\\') + \
name = drive_letter + '\\' + \
name[ len(device_native_path) : ]
break
return name
Expand Down

0 comments on commit 21e6b3d

Please sign in to comment.