summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Misc/NEWS.d/next/Library/2023-06-09-21-04-39.gh-issue-105375.bTcqS9.rst1
-rw-r--r--Modules/errnomodule.c7
2 files changed, 6 insertions, 2 deletions
diff --git a/Misc/NEWS.d/next/Library/2023-06-09-21-04-39.gh-issue-105375.bTcqS9.rst b/Misc/NEWS.d/next/Library/2023-06-09-21-04-39.gh-issue-105375.bTcqS9.rst
new file mode 100644
index 0000000..3030477
--- /dev/null
+++ b/Misc/NEWS.d/next/Library/2023-06-09-21-04-39.gh-issue-105375.bTcqS9.rst
@@ -0,0 +1 @@
+Fix bugs in :mod:`pickle` where exceptions could be overwritten.
diff --git a/Modules/errnomodule.c b/Modules/errnomodule.c
index fddde96..301ad83 100644
--- a/Modules/errnomodule.c
+++ b/Modules/errnomodule.c
@@ -81,9 +81,12 @@ end:
static int
errno_exec(PyObject *module)
{
- PyObject *module_dict = PyModule_GetDict(module);
+ PyObject *module_dict = PyModule_GetDict(module); // Borrowed ref.
+ if (module_dict == NULL) {
+ return -1;
+ }
PyObject *error_dict = PyDict_New();
- if (!module_dict || !error_dict) {
+ if (error_dict == NULL) {
return -1;
}
if (PyDict_SetItemString(module_dict, "errorcode", error_dict) < 0) {