Skip to content

Commit f8420ea

Browse files
Use _Py_ID() for INTERP_KEY.
1 parent da24674 commit f8420ea

File tree

5 files changed

+11
-5
lines changed

5 files changed

+11
-5
lines changed

Include/internal/pycore_global_objects_fini_generated.h

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Include/internal/pycore_global_strings.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -319,6 +319,7 @@ struct _Py_global_strings {
319319
STRUCT_FOR_ID(c_call)
320320
STRUCT_FOR_ID(c_exception)
321321
STRUCT_FOR_ID(c_return)
322+
STRUCT_FOR_ID(cached_datetime_module)
322323
STRUCT_FOR_ID(cached_statements)
323324
STRUCT_FOR_ID(cadata)
324325
STRUCT_FOR_ID(cafile)

Include/internal/pycore_runtime_init_generated.h

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Include/internal/pycore_unicodeobject_generated.h

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Modules/_datetimemodule.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ get_module_state(PyObject *module)
9898
}
9999

100100

101-
#define INTERP_KEY "cached-datetime-module"
101+
#define INTERP_KEY ((PyObject *)&_Py_ID(cached_datetime_module))
102102

103103
static PyObject *
104104
get_current_module(PyInterpreterState *interp)
@@ -108,7 +108,7 @@ get_current_module(PyInterpreterState *interp)
108108
return NULL;
109109
}
110110
PyObject *ref = NULL;
111-
if (PyDict_GetItemStringRef(dict, INTERP_KEY, &ref) < 0) {
111+
if (PyDict_GetItemRef(dict, INTERP_KEY, &ref) < 0) {
112112
return NULL;
113113
}
114114
if (ref == NULL) {
@@ -144,7 +144,7 @@ set_current_module(PyInterpreterState *interp, PyObject *mod)
144144
if (ref == NULL) {
145145
return -1;
146146
}
147-
int rc = PyDict_SetItemString(dict, INTERP_KEY, ref);
147+
int rc = PyDict_SetItem(dict, INTERP_KEY, ref);
148148
Py_DECREF(ref);
149149
return rc;
150150
}
@@ -163,7 +163,7 @@ clear_current_module(PyInterpreterState *interp, PyObject *expected)
163163

164164
if (expected != NULL) {
165165
PyObject *ref = NULL;
166-
if (PyDict_GetItemStringRef(dict, INTERP_KEY, &ref) < 0) {
166+
if (PyDict_GetItemRef(dict, INTERP_KEY, &ref) < 0) {
167167
goto error;
168168
}
169169
if (ref != NULL) {
@@ -178,7 +178,7 @@ clear_current_module(PyInterpreterState *interp, PyObject *expected)
178178
}
179179
}
180180

181-
if (PyDict_DelItemString(dict, INTERP_KEY) < 0) {
181+
if (PyDict_DelItem(dict, INTERP_KEY) < 0) {
182182
if (!PyErr_ExceptionMatches(PyExc_KeyError)) {
183183
goto error;
184184
}

0 commit comments

Comments
 (0)