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) {
121121// PyThreadState functions
122122
123123PyAPI_FUNC (PyThreadState * ) _PyThreadState_New (PyInterpreterState * interp );
124- PyAPI_FUNC (int ) _PyThreadState_IsBound (PyThreadState * tstate );
125124PyAPI_FUNC (void ) _PyThreadState_Bind (PyThreadState * tstate );
126- PyAPI_FUNC (void ) _PyThreadState_Unbind (PyThreadState * tstate );
127125// We keep this around exclusively for stable ABI compatibility.
128126PyAPI_FUNC (void ) _PyThreadState_Init (
129127 PyThreadState * tstate );
Original file line number Diff line number Diff line change @@ -14585,41 +14585,26 @@ _PyUnicode_InitTypes(PyInterpreterState *interp)
1458514585}
1458614586
1458714587
14588- static PyThreadState *
14589- get_interned_tstate (void )
14590- {
14591- return & _PyRuntime .cached_objects .main_tstate ;
14592- }
14593-
1459414588static inline PyObject *
1459514589store_interned (PyObject * obj )
1459614590{
1459714591 PyObject * interned = get_interned_dict ();
1459814592 assert (interned != NULL );
1459914593
1460014594 /* 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 );
1461414597
14598+ /* This might trigger a resize, which is why we must "acquire"
14599+ the global object state. */
1461514600 PyObject * t = PyDict_SetDefault (interned , obj , obj );
1461614601 if (t == NULL ) {
1461714602 PyErr_Clear ();
1461814603 }
1461914604
1462014605 /* Swap back. */
1462114606 if (oldts != NULL ) {
14622- PyThreadState_Swap (oldts );
14607+ _Py_ReleaseGlobalObjectsState (oldts );
1462314608 }
1462414609
1462514610 return t ;
Original file line number Diff line number Diff line change @@ -1923,12 +1923,6 @@ PyThreadState_Swap(PyThreadState *newts)
19231923}
19241924
19251925
1926- int
1927- _PyThreadState_IsBound (PyThreadState * tstate )
1928- {
1929- return tstate_is_bound (tstate );
1930- }
1931-
19321926void
19331927_PyThreadState_Bind (PyThreadState * tstate )
19341928{
@@ -1940,14 +1934,6 @@ _PyThreadState_Bind(PyThreadState *tstate)
19401934 }
19411935}
19421936
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-
19511937
19521938/***********************************/
19531939/* routines for advanced debuggers */
You can’t perform that action at this time.
0 commit comments