-
-
Notifications
You must be signed in to change notification settings - Fork 30.7k
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
Skip __index__ handling in PyLong_AsNativeBytes #121115
Comments
zooba
added
3.13
bugs and security fixes
3.14
new features, bugs and security fixes
labels
Jun 28, 2024
zooba
changed the title
Allow skipping __index__ handling in PyLong_AsNativeBytes
Skip __index__ handling in PyLong_AsNativeBytes
Jun 28, 2024
zooba
added a commit
to zooba/cpython
that referenced
this issue
Jun 28, 2024
zooba
added a commit
that referenced
this issue
Jun 28, 2024
miss-islington
pushed a commit
to miss-islington/cpython
that referenced
this issue
Jun 28, 2024
…ythonGH-121118) (cherry picked from commit 2894aa1) Co-authored-by: Steve Dower <steve.dower@python.org>
zooba
added a commit
that referenced
this issue
Jun 28, 2024
mrahtz
pushed a commit
to mrahtz/cpython
that referenced
this issue
Jun 30, 2024
noahbkim
pushed a commit
to hudson-trading/cpython
that referenced
this issue
Jul 11, 2024
estyxx
pushed a commit
to estyxx/cpython
that referenced
this issue
Jul 17, 2024
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
As per the discussion in capi-workgroup/decisions#32 (and some other bugs here that I haven't bothered to look up), having int conversion functions call back into Python to evaluate
__index__
can be problematic or unexpected (Python code may cause the GIL to be released, which could break threading invariants in the calling code).We should disable
__index__
handling by default inPyLong_AsNativeBytes
and provide a flag to reenable it. In general, calling__index__
is only really useful on user-provided arguments, which are easily distinguishable from "private" variables in the caller's code.This allows the caller to omit
PyLong_Check
before calling the conversion function (if they need to guarantee they retain the thread), or to provide a single flag if they will allow it. They'll discover they need the flag due to aTypeError
, which is safe, rather than a crash or native threading related issue, which is unsafe.Linked PRs
The text was updated successfully, but these errors were encountered: