File tree Expand file tree Collapse file tree 3 files changed +5
-36
lines changed Expand file tree Collapse file tree 3 files changed +5
-36
lines changed Original file line number Diff line number Diff line change @@ -121,9 +121,7 @@ static inline PyInterpreterState* _PyInterpreterState_GET(void) {
121
121
// PyThreadState functions
122
122
123
123
PyAPI_FUNC (PyThreadState * ) _PyThreadState_New (PyInterpreterState * interp );
124
- PyAPI_FUNC (int ) _PyThreadState_IsBound (PyThreadState * tstate );
125
124
PyAPI_FUNC (void ) _PyThreadState_Bind (PyThreadState * tstate );
126
- PyAPI_FUNC (void ) _PyThreadState_Unbind (PyThreadState * tstate );
127
125
// We keep this around exclusively for stable ABI compatibility.
128
126
PyAPI_FUNC (void ) _PyThreadState_Init (
129
127
PyThreadState * tstate );
Original file line number Diff line number Diff line change @@ -14585,41 +14585,26 @@ _PyUnicode_InitTypes(PyInterpreterState *interp)
14585
14585
}
14586
14586
14587
14587
14588
- static PyThreadState *
14589
- get_interned_tstate (void )
14590
- {
14591
- return & _PyRuntime .cached_objects .main_tstate ;
14592
- }
14593
-
14594
14588
static inline PyObject *
14595
14589
store_interned (PyObject * obj )
14596
14590
{
14597
14591
PyObject * interned = get_interned_dict ();
14598
14592
assert (interned != NULL );
14599
14593
14600
14594
/* Swap to the main interpreter, if necessary. */
14601
- PyThreadState * oldts = NULL ;
14602
- if (!_Py_IsMainInterpreter (_PyInterpreterState_GET ())) {
14603
- PyThreadState * main_tstate = get_interned_tstate ();
14604
- int bound = _PyThreadState_IsBound (main_tstate );
14605
- if (!bound ) {
14606
- _PyThreadState_Bind (main_tstate );
14607
- }
14608
- oldts = PyThreadState_Swap (main_tstate );
14609
- assert (oldts != NULL );
14610
- if (!bound ) {
14611
- _PyThreadState_Unbind (main_tstate );
14612
- }
14613
- }
14595
+ PyInterpreterState * interp = _PyInterpreterState_GET ();
14596
+ PyThreadState * oldts = _Py_AcquireGlobalObjectsState (interp );
14614
14597
14598
+ /* This might trigger a resize, which is why we must "acquire"
14599
+ the global object state. */
14615
14600
PyObject * t = PyDict_SetDefault (interned , obj , obj );
14616
14601
if (t == NULL ) {
14617
14602
PyErr_Clear ();
14618
14603
}
14619
14604
14620
14605
/* Swap back. */
14621
14606
if (oldts != NULL ) {
14622
- PyThreadState_Swap (oldts );
14607
+ _Py_ReleaseGlobalObjectsState (oldts );
14623
14608
}
14624
14609
14625
14610
return t ;
Original file line number Diff line number Diff line change @@ -1923,12 +1923,6 @@ PyThreadState_Swap(PyThreadState *newts)
1923
1923
}
1924
1924
1925
1925
1926
- int
1927
- _PyThreadState_IsBound (PyThreadState * tstate )
1928
- {
1929
- return tstate_is_bound (tstate );
1930
- }
1931
-
1932
1926
void
1933
1927
_PyThreadState_Bind (PyThreadState * tstate )
1934
1928
{
@@ -1940,14 +1934,6 @@ _PyThreadState_Bind(PyThreadState *tstate)
1940
1934
}
1941
1935
}
1942
1936
1943
- void
1944
- _PyThreadState_Unbind (PyThreadState * tstate )
1945
- {
1946
- /* For now, we do not allow the initial tstate to be unbound. */
1947
- assert (gilstate_tss_get (tstate -> interp -> runtime ) != tstate );
1948
- unbind_tstate (tstate );
1949
- }
1950
-
1951
1937
1952
1938
/***********************************/
1953
1939
/* routines for advanced debuggers */
You can’t perform that action at this time.
0 commit comments