You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Add private _PyThreadState_UncheckedGet() to get the current thread state #70342
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
assignee=Noneclosed_at=<Date2016-01-20.10:21:22.684>created_at=<Date2016-01-19.12:30:33.161>labels= []
title='Add private _PyThreadState_UncheckedGet() to get the current thread state'updated_at=<Date2016-04-25.15:16:37.222>user='https://github.com/vstinner'
Attached patches adds a new private _PyThreadState_FastGet() function to get the current thread state but don't call Py_FatalError() if it is NULL.
The patch also uses replace direct access to _PyThreadState_Current with _PyThreadState_FastGet(), except inside ceval.c and pystate.c.
Calling Py_FatalError() to handle errors is not really a great API... Bad that's a different story, I don't want to break anything here.
I want to add the private function to Python 3.5.2 because I consider that the removal of the _PyThreadState_Current symbol is a regression introduced in Python 3.5.1.
We have no rule for the Python private API, it can change *anytime*.
Overall +1 to this private API. I like the UncheckedGet name better than FastGet but don't really care what the name is so long as it keeps this property: It must be non-blocking and safe to call from a signal handler. Returning NULL in the event the value could not be obtained in such a manner is fine (unlikely to happen from the looks of the 3.5 code).
They are private and this fixes the regression in 3.5.1. people (ab)using these private APIs should be fine writing conditional compilation code to deal with that.
We've got a similar patch on our CPython 2.7 interpreter at work (more complicated as it must do a non-blocking lock acquire in the old 2.7 code).
changed the title [-]Add private _PyThreadState_FastGet() to get the current thread state[/-][+]Add private _PyThreadState_UncheckedGet() to get the current thread state[/+]on Jan 20, 2016
wenzel commented on Apr 25, 2016
wenzelmannequin
Mannequin
More actions
I've also run into this regression. FWIW this is what I've ended up using to work around it (it's a mess, but what are we to do..)
Activity
vstinner commentedon Jan 19, 2016
The issue bpo-25150 modified pystate.h to hide _PyThreadState_Current. Sadly, this change broke the vmprof project:
https://mail.python.org/pipermail/python-dev/2016-January/142767.html
Attached patches adds a new private _PyThreadState_FastGet() function to get the current thread state but don't call Py_FatalError() if it is NULL.
The patch also uses replace direct access to _PyThreadState_Current with _PyThreadState_FastGet(), except inside ceval.c and pystate.c.
Calling Py_FatalError() to handle errors is not really a great API... Bad that's a different story, I don't want to break anything here.
I want to add the private function to Python 3.5.2 because I consider that the removal of the _PyThreadState_Current symbol is a regression introduced in Python 3.5.1.
We have no rule for the Python private API, it can change *anytime*.
njsmith commentedon Jan 19, 2016
Name should be _PyThreadState_UncheckedGet
gpshead commentedon Jan 19, 2016
Overall +1 to this private API. I like the UncheckedGet name better than FastGet but don't really care what the name is so long as it keeps this property: It must be non-blocking and safe to call from a signal handler. Returning NULL in the event the value could not be obtained in such a manner is fine (unlikely to happen from the looks of the 3.5 code).
They are private and this fixes the regression in 3.5.1. people (ab)using these private APIs should be fine writing conditional compilation code to deal with that.
We've got a similar patch on our CPython 2.7 interpreter at work (more complicated as it must do a non-blocking lock acquire in the old 2.7 code).
python-dev commentedon Jan 20, 2016
New changeset f9461f1e0559 by Victor Stinner in branch '3.5':
Add _PyThreadState_UncheckedGet()
https://hg.python.org/cpython/rev/f9461f1e0559
New changeset d4f13c9a2b07 by Victor Stinner in branch 'default':
Merge 3.5
https://hg.python.org/cpython/rev/d4f13c9a2b07
vstinner commentedon Jan 20, 2016
Function added
@fijal: Sorry for the annoyance of the Python 3.5.1 regression.
[-]Add private _PyThreadState_FastGet() to get the current thread state[/-][+]Add private _PyThreadState_UncheckedGet() to get the current thread state[/+]wenzel commentedon Apr 25, 2016
I've also run into this regression. FWIW this is what I've ended up using to work around it (it's a mess, but what are we to do..)