Skip to content

Commit 4eeff1c

Browse files
committed
errno.errorcode uses frozendict
1 parent 2ff7055 commit 4eeff1c

File tree

1 file changed

+12
-10
lines changed

1 file changed

+12
-10
lines changed

Modules/errnomodule.c

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,5 @@
11
/* Errno module */
22

3-
// Need limited C API version 3.13 for Py_mod_gil
4-
#include "pyconfig.h" // Py_GIL_DISABLED
5-
#ifndef Py_GIL_DISABLED
6-
# define Py_LIMITED_API 0x030d0000
7-
#endif
8-
93
#include "Python.h"
104
#include <errno.h> // EPIPE
115

@@ -96,10 +90,6 @@ errno_exec(PyObject *module)
9690
if (error_dict == NULL) {
9791
return -1;
9892
}
99-
if (PyDict_SetItemString(module_dict, "errorcode", error_dict) < 0) {
100-
Py_DECREF(error_dict);
101-
return -1;
102-
}
10393

10494
/* Macro so I don't have to edit each and every line below... */
10595
#define add_errcode(name, code, comment) \
@@ -947,6 +937,18 @@ errno_exec(PyObject *module)
947937
add_errcode("ENOTCAPABLE", ENOTCAPABLE, "Capabilities insufficient");
948938
#endif
949939

940+
PyObject *frozendict = PyFrozenDict_New(error_dict);
941+
if (frozendict == NULL) {
942+
Py_DECREF(error_dict);
943+
return -1;
944+
}
945+
if (PyDict_SetItemString(module_dict, "errorcode", frozendict) < 0) {
946+
Py_DECREF(error_dict);
947+
Py_DECREF(frozendict);
948+
return -1;
949+
}
950+
Py_DECREF(frozendict);
951+
950952
Py_DECREF(error_dict);
951953
return 0;
952954
}

0 commit comments

Comments
 (0)