From 21e6b3d9f27fa72eaac78d76e893bf2f1520c840 Mon Sep 17 00:00:00 2001 From: Artem Mukhin Date: Wed, 7 Jun 2023 13:23:49 +0200 Subject: [PATCH] Pass `str` instead of `bytes` to `str.startswith` and `str.endswith` 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` --- pydevd_attach_to_process/winappdbg/util.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/pydevd_attach_to_process/winappdbg/util.py b/pydevd_attach_to_process/winappdbg/util.py index 4a9a9842a..dbde5ad3d 100644 --- a/pydevd_attach_to_process/winappdbg/util.py +++ b/pydevd_attach_to_process/winappdbg/util.py @@ -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] @@ -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