diff --git a/Lib/test/test_external_inspection.py b/Lib/test/test_external_inspection.py index eceae532422f3c..d048aac25e5dab 100644 --- a/Lib/test/test_external_inspection.py +++ b/Lib/test/test_external_inspection.py @@ -63,6 +63,8 @@ def foo(): stack_trace = get_stack_trace(p.pid) except PermissionError: self.skipTest("Insufficient permissions to read the stack trace") + except KeyError as exc: + self.skipTest(str(exc)) finally: os.remove(fifo) p.kill() @@ -147,6 +149,8 @@ def new_eager_loop(): except PermissionError: self.skipTest( "Insufficient permissions to read the stack trace") + except KeyError as exc: + self.skipTest(str(exc)) finally: os.remove(fifo) p.kill() @@ -212,6 +216,8 @@ async def main(): stack_trace = get_async_stack_trace(p.pid) except PermissionError: self.skipTest("Insufficient permissions to read the stack trace") + except KeyError as exc: + self.skipTest(str(exc)) finally: os.remove(fifo) p.kill() @@ -272,6 +278,8 @@ async def main(): except PermissionError: self.skipTest( "Insufficient permissions to read the stack trace") + except KeyError as exc: + self.skipTest(str(exc)) finally: os.remove(fifo) p.kill() diff --git a/Modules/_testexternalinspection.c b/Modules/_testexternalinspection.c index 25e0e9c64ec27d..0959b82f65ce3c 100644 --- a/Modules/_testexternalinspection.c +++ b/Modules/_testexternalinspection.c @@ -383,6 +383,10 @@ search_map_for_section(pid_t pid, const char* secname, const char* map) ); result = start_address + (uintptr_t)section->sh_addr - elf_load_addr; } + else { + PyErr_Format(PyExc_KeyError, + "cannot find map for section %s", secname); + } exit: if (close(fd) != 0) {