diff --git a/Misc/NEWS.d/next/Library/2026-10-22-19-38-00.gh-issue-119696.FrameworkInspection.rst b/Misc/NEWS.d/next/Library/2026-10-22-19-38-00.gh-issue-119696.FrameworkInspection.rst new file mode 100644 index 000000000000000..b4d65b298dac965 --- /dev/null +++ b/Misc/NEWS.d/next/Library/2026-10-22-19-38-00.gh-issue-119696.FrameworkInspection.rst @@ -0,0 +1,2 @@ +On macOS, remote inspection in a framework build now searches for its +configured framework name. diff --git a/Python/remote_debug.h b/Python/remote_debug.h index a4a3a010926a7bc..a17c31c95144e50 100644 --- a/Python/remote_debug.h +++ b/Python/remote_debug.h @@ -1173,8 +1173,15 @@ _Py_RemoteDebug_GetPyRuntimeAddress(proc_handle_t* handle) } } #elif defined(__APPLE__) && defined(TARGET_OS_OSX) && TARGET_OS_OSX - // On macOS, try libpython first, then fall back to python - const char* candidates[] = {"libpython", "python", "Python", NULL}; + // Search image names by the usual Python prefixes and the configured + // framework name. + const char* candidates[] = { + "libpython", "python", "Python", +#ifdef WITH_NEXT_FRAMEWORK + _PYTHONFRAMEWORK, +#endif + NULL + }; for (const char** candidate = candidates; *candidate; candidate++) { PyErr_Clear(); address = search_map_for_section(handle, "PyRuntime", *candidate, @@ -1188,7 +1195,7 @@ _Py_RemoteDebug_GetPyRuntimeAddress(proc_handle_t* handle) PyObject *exc = PyErr_GetRaisedException(); PyErr_Format(PyExc_RuntimeError, "Failed to find the PyRuntime section in process %d " - "on macOS platform (tried both libpython and python)", + "on macOS platform", handle->pid); _PyErr_ChainExceptions1(exc); }