* graalpy: recognize graalpy implementation when building
* graalpy: global Ellipse, None, NotImplemented, True, and False are only available as pointers
* graalpy: PyObject struct is opaque, use functions for everything
* graalpy: missing many of the same functions as pypy
* graalpy: do not have 128bit conversion functions
* graalpy: add functions for datetime accessor macros
* graalpy: add implementations for list macro functions
* graalpy: skip tuple macros
* graalpy: always use extern Py_CompileString function
* graalpy: disable assertion that does not apply to graalpy
* graalpy: floatobject structure is opaque on graalpy
* graalpy: ignore gc dependent test
* graalpy: add CI config
* graalpy: run rust fmt
* graalpy: add changelog entry
* graalpy: discover interpreter on PATH
* graalpy: interpreter id is not applicable to graalpy (just like pypy)
* graalpy: skip tests that cannot work on GraalPy
* graalpy: fix constructing normalized Err instances
Co-authored-by: David Hewitt <mail@davidhewitt.dev>
* graalpy: correct capi library name, but skip rust tests due to missing symbols
* graalpy: no support for C extensions on windows in latest release
* graalpy: declare support versions
* graalpy: frame, code, method, and function objects access from C API is mostly missing
* graalpy: take care only to expose C structure that GraalPy allocates
* graalpy: Bail out if graalpy version is less than what we support
---------
Co-authored-by: David Hewitt <mail@davidhewitt.dev>
* add `FromPyObjectBound` adjustment for `&str` without GIL Refs
* review: alex, Icxolu feedback
* add newsfragment
* add newsfragment for `FromPyObject` trait change
* make some examples compatible with abi3 < 3.10
* seal `FromPyObjectBound`
* fixup chrono_tz conversion
* #[pymodule] mod some_module { ... } v3
Based on #2367 and #3294
Allows to export classes, native classes, functions and submodules and provide an init function
See test/test_module.rs for an example
Future work:
- update examples, README and guide
- investigate having #[pyclass] and #[pyfunction] directly in the #[pymodule]
Co-authored-by: David Hewitt <mail@davidhewitt.dev>
Co-authored-by: Georg Brandl <georg@python.org>
* tests: group exported imports
* Consolidate pymodule macro code to avoid duplicates
* Makes pymodule_init take Bound<'_, PyModule>
* Renames #[pyo3] to #[pymodule_export]
* Gates #[pymodule] mod behind the experimental-declarative-modules feature
* Properly fails on functions inside of declarative modules
---------
Co-authored-by: David Hewitt <mail@davidhewitt.dev>
Co-authored-by: Georg Brandl <georg@python.org>
* fix `either` feature conditional compilation, again
* test feature powerset in CI
* install `rust-src` for feature powerset tests
* review: adamreichold feedback
* Fix one more case of redundant imports.
* just check feature powerset for now
---------
Co-authored-by: Adam Reichold <adam.reichold@t-online.de>
* add `PyBackedStr` and `PyBackedBytes`
* review: adamreichold feedback
* use `NonNull<[u8]>`
* clippy and newsfragment
* drop binding unused after refactoring
---------
Co-authored-by: Adam Reichold <adam.reichold@t-online.de>
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.