https://github.com/python/cpython/commit/014c7f90478780b18d0e33d456483178c8dcc665 commit: 014c7f90478780b18d0e33d456483178c8dcc665 branch: main author: Victor Stinner <vstin...@python.org> committer: vstinner <vstin...@python.org> date: 2025-04-16T13:56:58Z summary:
gh-130052: Fix search_map_for_section() error handling (#132594) * Don't call close() if the file descriptor is negative. * If close() fails, chain the existing exception. files: M Modules/_testexternalinspection.c diff --git a/Modules/_testexternalinspection.c b/Modules/_testexternalinspection.c index e90cfb9132b51d..01fe700fa490f1 100644 --- a/Modules/_testexternalinspection.c +++ b/Modules/_testexternalinspection.c @@ -400,8 +400,10 @@ search_map_for_section(pid_t pid, const char* secname, const char* map) } exit: - if (close(fd) != 0) { + if (fd >= 0 && close(fd) != 0) { + PyObject *exc = PyErr_GetRaisedException(); PyErr_SetFromErrno(PyExc_OSError); + _PyErr_ChainExceptions1(exc); } if (file_memory != NULL) { munmap(file_memory, file_stats.st_size); _______________________________________________ Python-checkins mailing list -- python-checkins@python.org To unsubscribe send an email to python-checkins-le...@python.org https://mail.python.org/mailman3/lists/python-checkins.python.org/ Member address: arch...@mail-archive.com