Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
546b934
Factor out add_threadstate().
ericsnowcurrently Mar 21, 2023
0bcd136
Add _PyThreadState_InitDetached().
ericsnowcurrently Mar 21, 2023
35d5310
Add _PyThreadState_ClearDetached().
ericsnowcurrently Mar 21, 2023
cba9e34
Add _PyRuntime.cached_objects.main_tstate.
ericsnowcurrently Mar 21, 2023
3b1bb8b
Add _Py_AcquireGlobalObjectsState() and _Py_ReleaseGlobalObjectsState().
ericsnowcurrently Mar 22, 2023
eb42aa1
Add _Py_AddToGlobalDict().
ericsnowcurrently Mar 22, 2023
4e9da2d
Drop _Py_AcquireGlobalObjectsState() and _Py_ReleaseGlobalObjectsStat…
ericsnowcurrently Mar 22, 2023
6216207
Add acquire_global_objects_lock() and release_global_objects_lock().
ericsnowcurrently Mar 22, 2023
3c007c0
Add some TODO comments.
ericsnowcurrently Mar 13, 2023
7d95514
Factor out store_interned().
ericsnowcurrently Mar 20, 2023
5c20b84
Store a thread state to use just for interned strings.
ericsnowcurrently Mar 20, 2023
a3ae02a
Always use the main interpreter when possibly resizing the interned d…
ericsnowcurrently Mar 20, 2023
d5fbc37
Use _PyRuntime.cached_objects.main_tstate instead.
ericsnowcurrently Mar 21, 2023
459325f
Add _PyThreadState_IsBound() and _PyThreadState_Unbind().
ericsnowcurrently Mar 21, 2023
4f25244
Make sure the one-off tstate is bound before using it.
ericsnowcurrently Mar 21, 2023
e68535a
Use _Py_AcquireGlobalObjectsState() in store_interned().
ericsnowcurrently Mar 22, 2023
22753b3
Use _Py_AddToGlobalDict().
ericsnowcurrently Mar 22, 2023
5c7bfd7
Move the extensions dict to _PyRuntime.cached_objects.
ericsnowcurrently Mar 22, 2023
f1a33ce
Add _Py_GetFromGlobalDict().
ericsnowcurrently Mar 22, 2023
10e6d69
Add _Py_PopFromGlobalDict().
ericsnowcurrently Mar 22, 2023
7dbae68
Adjust _Py_AddToGlobalDict().
ericsnowcurrently Mar 22, 2023
3e08c1f
Use _Py_PopFromGlobalDict() in unicode_dealloc().
ericsnowcurrently Mar 22, 2023
1039a60
Use the global dict API in import.c.
ericsnowcurrently Mar 22, 2023
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
Add _Py_GetFromGlobalDict().
  • Loading branch information
ericsnowcurrently committed Mar 22, 2023
commit f1a33ce6f60e7e1dce6a9f0d1aeb1e27cc446d50
1 change: 1 addition & 0 deletions Include/internal/pycore_pystate.h
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ PyAPI_FUNC(void) _PyThreadState_DeleteExcept(PyThreadState *tstate);
extern void _PyThreadState_InitDetached(PyThreadState *, PyInterpreterState *);
extern void _PyThreadState_ClearDetached(PyThreadState *);

extern PyObject * _Py_GetFromGlobalDict(PyObject *, PyObject *);
extern PyObject * _Py_AddToGlobalDict(PyObject *, PyObject *, PyObject *);


Expand Down
17 changes: 17 additions & 0 deletions Python/pystate.c
Original file line number Diff line number Diff line change
Expand Up @@ -622,6 +622,23 @@ release_global_objects_lock(_PyRuntimeState *runtime)
assert(current_fast_get(runtime) != NULL);
}

PyObject *
_Py_GetFromGlobalDict(PyObject *dict, PyObject *key)
{
_PyRuntimeState *runtime = &_PyRuntime;

/* Due to interpreter isolation we must hold a global lock,
starting at this point and ending before we return.
Note that the operations in this function are very fucused
and we should not expect any reentrancy. */
acquire_global_objects_lock(runtime);
/* We don't worry about the global objects state
since there are no memory operations. */
PyObject *value = PyDict_GetItemWithError(dict, key);
release_global_objects_lock(runtime);
return value;
}

PyObject *
_Py_AddToGlobalDict(PyObject *dict, PyObject *key, PyObject *value)
{
Expand Down