From 68947cc4dc0663d978e1a6d057453c6b16d770ca Mon Sep 17 00:00:00 2001 From: Egor Eliseev Date: Thu, 2 Mar 2023 12:20:10 +0200 Subject: [PATCH] PY-57217 Breakpoints are ignored with Python 3.11 IJ-CR-103963 GitOrigin-RevId: 18faf5bc5c995decc948cbe1314773b0776ffc63 --- python/helpers/pydev/_pydev_bundle/pydev_monkey.py | 12 +++++++++++- .../helpers/pydev/_pydevd_bundle/pydevd_constants.py | 2 ++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/python/helpers/pydev/_pydev_bundle/pydev_monkey.py b/python/helpers/pydev/_pydev_bundle/pydev_monkey.py index c581e6f5b24f..4578f549621f 100644 --- a/python/helpers/pydev/_pydev_bundle/pydev_monkey.py +++ b/python/helpers/pydev/_pydev_bundle/pydev_monkey.py @@ -5,7 +5,7 @@ import traceback from _pydev_imps._pydev_saved_modules import threading from _pydevd_bundle.pydevd_constants import get_global_debugger, IS_WINDOWS, IS_MACOS, \ IS_JYTHON, IS_PY36_OR_LESSER, IS_PY36_OR_GREATER, IS_PY38_OR_GREATER, \ - get_current_thread_id + get_current_thread_id, IS_PY311_OR_GREATER from _pydev_bundle import pydev_log try: @@ -63,6 +63,16 @@ def _is_already_patched(args): def _is_py3_and_has_bytes_args(args): if not isinstance('', type(u'')): return False + + if len(args) == 0: + return False + + # PY-57217 Uvicorn with '-reload' flag when starting a new process in Python3.11 passes the path to the interpreter as bytes + if IS_PY311_OR_GREATER and isinstance(args[0], bytes): + interpreter = args[0].decode('utf-8') + if is_python(interpreter): + args[0] = interpreter + for arg in args: if isinstance(arg, bytes): return True diff --git a/python/helpers/pydev/_pydevd_bundle/pydevd_constants.py b/python/helpers/pydev/_pydevd_bundle/pydevd_constants.py index 2067f7d02846..0e91d042c3a4 100644 --- a/python/helpers/pydev/_pydevd_bundle/pydevd_constants.py +++ b/python/helpers/pydev/_pydevd_bundle/pydevd_constants.py @@ -127,6 +127,7 @@ IS_PY38_OR_GREATER = False IS_PY38 = False IS_PY39_OR_GREATER = False IS_PY311 = False +IS_PY311_OR_GREATER = False IS_PY2 = True IS_PY27 = False IS_PY24 = False @@ -142,6 +143,7 @@ try: IS_PY38_OR_GREATER = sys.version_info >= (3, 8) IS_PY39_OR_GREATER = sys.version_info >= (3, 9) IS_PY311 = sys.version_info[0] == 3 and sys.version_info[1] == 11 + IS_PY311_OR_GREATER = sys.version_info >= (3, 11) elif sys.version_info[0] == 2 and sys.version_info[1] == 7: IS_PY27 = True elif sys.version_info[0] == 2 and sys.version_info[1] == 4: