8000 gh-117398: Use Per-Interpreter State for the _datetime Static Types by ericsnowcurrently · Pull Request #119929 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

gh-117398: Use Per-Interpreter State for the _datetime Static Types #119929

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
Changes from 1 commit
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
8463ae8
Use the static types directly.
ericsnowcurrently May 28, 2024
ead0083
Use the UTC singleton directly.
ericsnowcurrently May 28, 2024
4c52d5d
Add module state.
ericsnowcurrently May 27, 2024
6b291c8
Clear the module state when destroying the module.
ericsnowcurrently May 28, 2024
69c7e1f
Create PyDateTime_IsoCalendarDateType in init_state().
ericsnowcurrently May 29, 2024
36dbeea
Track the "current" module in the internal per-interpreter dict.
ericsnowcurrently May 29, 2024
d0c0b2d
Copy the "current" module state, if available.
ericsnowcurrently May 29, 2024
0599dd6
Make state usage explicit.
ericsnowcurrently May 29, 2024
1f1f6fc
Reduce churn.
ericsnowcurrently May 29, 2024
d44d6e9
Drop _datetime_global_state.
ericsnowcurrently May 29, 2024
a309474
Drop datetime_state.initialized.
ericsnowcurrently May 29, 2024
ede4415
Fix refleaks.
ericsnowcurrently May 30, 2024
5a8b1aa
Clear the "current" module when finalizing the module.
ericsnowcurrently May 30, 2024
3de1cd3
Use a weakref when tracking the "current" module.
ericsnowcurrently May 30, 2024
62b3d5e
Fix clear_current_module().
ericsnowcurrently May 30, 2024
5c25927
Give each module its own heap types.
ericsnowcurrently May 31, 2024
da24674
Consolidate into init_state().
ericsnowcurrently May 31, 2024
f8420ea
Use _Py_ID() for INTERP_KEY.
ericsnowcurrently May 31, 2024
2a2c0b1
Handle PyWeakref_GetRef() returning None.
ericsnowcurrently May 31, 2024
c519e3c
Fix refleak.
ericsnowcurrently May 31, 2024
05acc56
Make sure the module exists in static type methods.
ericsnowcurrently May 31, 2024
07e3b65
Don't bother making the module temporary.
ericsnowcurrently May 31, 2024
1e3005d
_PyStaticType_Dealloc() -> _PyStaticType_FiniBuiltin()
ericsnowcurrently May 31, 2024
ab38857
Add _PyStaticType_InitForExtension() and _PyStaticType_FiniForExtensi…
ericsnowcurrently May 31, 2024
0fb6bb3
Use them for the _datetime module.
ericsnowcurrently Jun 1, 2024
9e4eee6
Mark the module as safe for subinterpreters.
ericsnowcurrently Jun 1, 2024
293fd2e
Add a NEWS entry.
ericsnowcurrently Jun 1, 2024
f0db33a
Ignore the new global vars in the C analyzer tool.
ericsnowcurrently Jun 1, 2024
326d957
Fix a smelly name.
ericsnowcurrently Jun 1, 2024
04eb383
Fix a comment.
ericsnowcurrently Jun 3, 2024
0e8c3b1
Fix callback_for_interp_exit().
ericsnowcurrently Jun 3, 2024
67812dc
Pass around "initial" instead of using _Py_IsMainInterpreter().
ericsnowcurrently Jun 3, 2024
e5ab548
Finalize the static types if PyUnstable_AtExit() fails.
ericsnowcurrently Jun 3, 2024
4f21a28
Make sure we're using the right index for extension static types.
ericsnowcurrently Jun 3, 2024
0fd9fae
Use PyErr_WriteUnraisable().
ericsnowcurrently Jun 3, 2024
3905ae8
Clean up clear_current_module() a little.
ericsnowcurrently Jun 3, 2024
7216e24
Update a TODO comment.
ericsnowcurrently Jun 3, 2024
349f910
Merge branch 'main' into datetime-static-types
ericsnowcurrently Jun 3, 2024
e057548
Update Misc/NEWS.d/next/Library/2024-06-01-16-58-43.gh-issue-117398.k…
ericsnowcurrently Jun 3, 2024
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
Prev Previous commit
Next Next commit
Fix clear_current_module().
  • Loading branch information
ericsnowcurrently committed May 31, 2024
commit 62b3d5e1fc565dc869fd92d72a7a309ebcae843e
16 changes: 9 additions & 7 deletions Modules/_datetimemodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -166,13 +166,15 @@ clear_current_module(PyInterpreterState *interp, PyObject *expected)
if (PyDict_GetItemStringRef(dict, INTERP_KEY, &ref) < 0) {
goto error;
}
int rc = PyWeakref_GetRef(ref, &current);
Py_DECREF(ref);
if (rc < 0) {
goto error;
}
if (current != expected) {
goto finally;
if (ref != NULL) {
int rc = PyWeakref_GetRef(ref, &current);
Py_DECREF(ref);
if (rc < 0) {
goto error;
}
if (current != expected) {
goto finally;
}
}
}

Expand Down
0