Skip to content

Commit a33d166

Browse files
committed
Raise on unsupported platforms in GetPyRuntimeAddress
1 parent 85f12d0 commit a33d166

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

Lib/test/test_external_inspection.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -997,5 +997,20 @@ def main_work():
997997
"GIL holder should be among all threads")
998998

999999

1000+
class TestUnsupportedPlatformHandling(unittest.TestCase):
1001+
@unittest.skipIf(
1002+
sys.platform in ("linux", "darwin", "win32"),
1003+
"Test only runs on unsupported platforms (not Linux, macOS, or Windows)",
1004+
)
1005+
def test_unsupported_platform_error(self):
1006+
with self.assertRaises(RuntimeError) as cm:
1007+
RemoteUnwinder(os.getpid())
1008+
1009+
self.assertIn(
1010+
"Reading the PyRuntime section is not supported on this platform",
1011+
str(cm.exception)
1012+
)
1013+
1014+
10001015
if __name__ == "__main__":
10011016
unittest.main()

Python/remote_debug.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -888,7 +888,9 @@ _Py_RemoteDebug_GetPyRuntimeAddress(proc_handle_t* handle)
888888
_PyErr_ChainExceptions1(exc);
889889
}
890890
#else
891-
Py_UNREACHABLE();
891+
_set_debug_exception_cause(PyExc_RuntimeError,
892+
"Reading the PyRuntime section is not supported on this platform");
893+
return 0;
892894
#endif
893895

894896
return address;

0 commit comments

Comments
 (0)