add newsfragment
formatting
skip slow path on 3.8+
formatting
cfg if,else
formatting again
dedicated macro, change int_convert_u64_or_i64 too
add float tests
force index call for PyLong_AsUnsignedLongLong
perform PyLong check for 3.8 too
perform PyLong check for <3.10
This API is available starting in 3.11. It is not part of the Stable ABI.
PyType_GetModuleByDef searches the MRO of the given type for a module
matching the given module spec. It can be useful for users use that
`pyo3_ffi` directly and want to support multiple interpreters/per
interpreter GIL. It is useful to obtain access to the module state from
special methods like `tp_new` that can't use the METH_METHOD calling
convention.
This API is not supported on PyPy yet, but guess the symbol name for the future.
Adds a "threadsafe" variant of `PyCell::try_borrow` which will fail instead of
panicking if called on the wrong thread and use it in `call_traverse` to turn GC
traversals of unsendable pyclasses into no-ops if on the wrong thread.
This can imply leaking the underlying resource if the originator thread has
already exited so that the GC will never run there again, but it does avoid hard
aborts as we cannot raise an exception from within `call_traverse`.
I decided to not implement the full protocol for truth value testing [1] as it
seems confusing in the context of function arguments if basically any instance
of custom class or non-empty collection turns into `true`.
[1] https://docs.python.org/3/library/stdtypes.html#truth
Closes#3615
This simply adds a new method which uses the existence of a `PyVisit`
object as proof that the GIL is held instead of a `Python` object. This
allows `GILProtected` to be used in instances where contained Python
objects need to participate in garbage collection. Usage in this
situation should be valid since no Python calls are made and this does
not provide any additional mechanism for accessing a `Python` object.
I chose to make the dependency mandatory instead of optional as portable-atomic
itself just forwards to the native atomics when they are available so making
that choice part of our build system is not really necessary. Personally, I was
unable to perceive any noticeable compile-time hit from adding it.