Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork33.7k
Description
As per the discussion incapi-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 omitPyLong_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.