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
Skip __index__ handling in PyLong_AsNativeBytes #121115
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 in PyLong_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 a TypeError, which is safe, rather than a crash or native threading related issue, which is unsafe.
changed the title [-]Allow skipping __index__ handling in PyLong_AsNativeBytes[/-][+]Skip __index__ handling in PyLong_AsNativeBytes[/+]on Jun 28, 2024
Activity
[-]Allow skipping __index__ handling in PyLong_AsNativeBytes[/-][+]Skip __index__ handling in PyLong_AsNativeBytes[/+]pythongh-121115: Skip __index__ in PyLong_AsNativeBytes by default
gh-121115: Skip __index__ in PyLong_AsNativeBytes by default (GH-121118)
pythongh-121115: Skip __index__ in PyLong_AsNativeBytes by default (p…
gh-121115: Skip __index__ in PyLong_AsNativeBytes by default (GH-121118)
pythongh-121115: Skip __index__ in PyLong_AsNativeBytes by default (p…
pythongh-121115: Skip __index__ in PyLong_AsNativeBytes by default (p…
pythongh-121115: Skip __index__ in PyLong_AsNativeBytes by default (p…