8000 [3.12] gh-71587: Drop local reference cache to `_strptime` module in `_datetime` (GH-120224) by neonene · Pull Request #120431 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

[3.12] gh-71587: Drop local reference cache to _strptime module in _datetime (GH-120224) #120431

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jun 13, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
backport without test_embed case
  • Loading branch information
neonene committed Jun 12, 2024
commit 1bc1a9573c9e139c15f46346961b879441f9edc0
1 change: 1 addition & 0 deletions Include/internal/pycore_global_objects_fini_generated.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Include/internal/pycore_global_strings.h
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,7 @@ struct _Py_global_strings {
STRUCT_FOR_ID(_showwarnmsg)
STRUCT_FOR_ID(_shutdown)
STRUCT_FOR_ID(_slotnames)
STRUCT_FOR_ID(_strptime)
STRUCT_FOR_ID(_strptime_datetime)
STRUCT_FOR_ID(_swappedbytes_)
STRUCT_FOR_ID(_type_)
Expand Down
1 change: 1 addition & 0 deletions Include/internal/pycore_runtime_init_generated.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions Include/internal/pycore_unicodeobject_generated.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Fix crash in C version of :meth:`datetime.datetime.strptime` when called again
on the restarted interpreter.
14 changes: 7 additions & 7 deletions Modules/_datetimemodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -5209,19 +5209,19 @@ datetime_utcfromtimestamp(PyObject *cls, PyObject *args)
static PyObject *
datetime_strptime(PyObject *cls, PyObject *args)
{
static PyObject *module = NULL;
PyObject *string, *format;
PyObject *string, *format, *result;

if (!PyArg_ParseTuple(args, "UU:strptime", &string, &format))
return NULL;

PyObject *module = PyImport_Import(&_Py_ID(_strptime));
if (module == NULL) {
module = PyImport_ImportModule("_strptime");
if (module == NULL)
return NULL;
return NULL;
}
return PyObject_CallMethodObjArgs(module, &_Py_ID(_strptime_datetime),
cls, string, format, NULL);
result = PyObject_CallMethodObjArgs(module, &_Py_ID(_strptime_datetime),
cls, string, format, NULL);
Py_DECREF(module);
return result;
}

/* Return new datetime from date/datetime and time arguments. */
Expand Down
1 change: 0 additions & 1 deletion Tools/c-analyzer/cpython/globals-to-fix.tsv
Original file line number Diff line number Diff line change
Expand Up @@ -422,7 +422,6 @@ Modules/_ctypes/_ctypes.c CreateSwappedType suffix -
Modules/_ctypes/_ctypes.c - _unpickle -
Modules/_ctypes/_ctypes.c PyCArrayType_from_ctype cache -
Modules/_cursesmodule.c - ModDict -
Modules/_datetimemodule.c datetime_strptime module -
Modules/_datetimemodule.c - PyDateTime_TimeZone_UTC -
Modules/_datetimemodule.c - PyDateTime_Epoch -
Modules/_datetimemodule.c - us_per_ms -
Expand Down
Loading
0