Commit Graph

168 Commits

Author SHA1 Message Date
ijl 9e9a6e9ebd Add PyErr_GetRaisedException(), PyErr_SetRaisedException() to FFI
These are new and part of the stable API as of v3.12.0a6.

PyErr_Fetch(), PyErr_Restore(), and PyErr_NormalizeException()
were simultaneously deprecated in favor of these.

python/cpython@feec49c407
2023-06-16 14:49:22 +00:00
Adam Reichold a053489c8b
Merge pull request #2709 from davidhewitt/py3.12
ci: add Python 3.12-dev jobs
2023-06-12 08:59:35 +00:00
David Hewitt 621898b07d ci: add Python 3.12-dev jobs 2023-06-11 21:57:17 +01:00
David Hewitt 46942b9a14 docs: remove workarounds for `#[doc = concat!(...)]` following msrv bump 2023-06-08 21:04:49 +01:00
David Hewitt 72d1805109 fix pypy 3.10 ffi definitions 2023-06-08 07:51:10 +01:00
Adam Reichold 0d30bb7d3d Bump Rust edition to 2021 and make current Clippy happy. 2023-06-07 21:15:38 +02:00
Adam Reichold 6f987263c1 Remove cfg addr_of made unnecessary by MSRV bump. 2023-06-05 11:12:06 +02:00
Adam Reichold eb04f54683 Remove cfg min_const_generics made unnecessary by MSRV bump. 2023-06-05 09:42:40 +02:00
Adam Reichold 5738edfdd4 Bump MSRV to 1.56 2023-06-04 23:02:30 +01:00
David Hewitt 2500e22e13 release: 0.19.0 2023-05-31 13:53:37 +01:00
Adrian Garcia Badaracco 16d333f9d0
Add BaseExceptionGroup for Python >= 3.11 2023-05-07 15:08:43 -05:00
David Hewitt bfcc1f8c27 update release notes for 0.18.3 2023-04-13 22:47:55 +01:00
ijl 88b46a7029 PEP 623: wstr, wstr_length, state changes
https://peps.python.org/pep-0623/

	Following members are removed from the Unicode structures:

	    wstr
	    wstr_length
	    state.compact
	    state.ready

Note state.compact is still present as of v3.12.0a7.

state.interned has changed width from 2 to 1 bits.
2023-04-11 12:51:42 +00:00
ijl 6ee2174fec Define _PyDict_Contains_KnownHash() FFI for CPython 3.10 or later 2023-04-09 14:36:42 +00:00
bors[bot] ba6261c8e7
Merge #3015
3015: Implement wrapper for `PyASCIIObject.state` bitfield accesses r=davidhewitt a=decathorpe

This is a first draft of my attempt to fix #1824 "properly" by writing a C wrapper for the `PyASCIIObject.state` bitfield accesses, as proposed here: https://github.com/PyO3/pyo3/issues/1824#issuecomment-1406909504

---

The original argument for making these functions `unsafe` is still valid, though - bitfield memory layout is not guaranteed to be stable across different C compilers, as it is "implementation defined" in the C standard. However, short of having CPython upstream provide non-inlined public functions to access this bitfield, this is the next best thing, as far as I can tell.

I've removed the `#[cfg(target_endian = "little")]` attributes from all things that are un-blocked by fixing this issue on big-endian systems, except for three tests, which look like expected failures considering that they do not take bit/byte order into account (for example, when writing to the bitfield).

- `ffi::tests::ascii_object_bitfield`
- `types::string::tests::test_string_data_ucs2_invalid`
- `types::string::tests::test_string_data_ucs4_invalid`

All other tests now pass on both little-endian and big-endian systems.

---

I am aware that some parts of this PR are probably not in a state that's acceptable for merging as-is, which is why I'm filing this as a draft. Feedback about how to better integrate this change with pyo3-ffi would be great. :)

In particular, I'm unsure whether the `#include` statements in the C files are actually correct across different systems. I have only tested this on Fedora Linux so far.

I'm also open to changing the names of the C functions that are implemented in the wrapper. For now I chose the most obvious names that shouldn't cause collisions with other symbols.

Co-authored-by: Fabio Valentini <decathorpe@gmail.com>
2023-03-28 07:27:02 +00:00
Fabio Valentini 40d6d4797f
Add wrapper for PyASCIIObject state bitfield accesses based on bindgen 2023-03-26 17:11:01 +02:00
David Hewitt e7e58ba51e update release notes for 0.18.2 2023-03-24 20:40:06 +00:00
Matti Picus a7cc5952c7
Conditionally mangle the function name
Co-authored-by: David Hewitt <1939362+davidhewitt@users.noreply.github.com>
2023-03-14 09:21:35 +11:00
Matti Picus 0f1ff1d852 mangle exported functions for PyPy 2023-03-12 08:40:12 +11:00
David Hewitt fbebc285c0 fix const-ness of some FFI name & doc members 2023-03-10 16:02:52 +00:00
Matti Picus 8446414f3b mangle exported functions for PyPy 2023-03-10 07:27:38 +11:00
David Hewitt 92cca896de release notes for 0.18.1 2023-02-07 21:38:07 +00:00
David Hewitt 5bab0e9409 use simplified PyIter_Check on CPython 3.7 2023-02-03 07:55:44 +00:00
David Hewitt f4953224d8 correct ffi definition of PyIter_Check 2023-01-29 19:43:33 +00:00
Samuel Colvin 3c9ace03d8 add Ellipsis() and is_ellipsis() methods, fix #2906 2023-01-27 06:40:02 +00:00
David Hewitt 224a4160b4 release: 0.18.0 2023-01-17 19:04:30 +00:00
bors[bot] cedb5aecb2
Merge #2843
2843: remove functionality deprecated in 0.16 r=davidhewitt a=davidhewitt

Simple cleanup to remove all functionality marked deprecated in the 0.16 releases.

Co-authored-by: David Hewitt <1939362+davidhewitt@users.noreply.github.com>
2022-12-28 12:24:59 +00:00
David Hewitt f2608a923c remove functionality deprecated in 0.16 2022-12-28 12:23:53 +00:00
bors[bot] 31c42cc2c8
Merge #2838
2838: pypy: re-enable PyFunction on 3.8+ r=davidhewitt a=davidhewitt

PyPy [fixed the crashes associated with `PyFunction](https://foss.heptapod.net/pypy/pypy/-/issues/3776#note_191626)  in PyPy 7.3.10 (for 3.8+) - which I think is to be released shortly. So I think we should re-enable this API and treat it as a PyPy bug which users can mitigate by updating their PyPy.

Co-authored-by: David Hewitt <1939362+davidhewitt@users.noreply.github.com>
2022-12-27 21:40:57 +00:00
mejrs faa578a7c5 fix PyUnicodeDecodeError_Create 2022-12-27 16:13:32 +00:00
David Hewitt 24032fe110 pypy: re-enable PyFunction on 3.8+ 2022-12-27 14:32:43 +00:00
David Hewitt 4a6b24ea07 adjust vectorcall symbols for pypy 2022-12-17 11:07:30 +00:00
ijl d5a31706c6 Define _PyErr_ChainExceptions() FFI for CPython
This appears to be the only way to chain exceptions via the FFI. It
was introduced prior to CPython 3.7. It has some description of usage
in PEP 490. There was a discussion of whether it should be made stable
in BPO 44938.
2022-12-01 15:25:56 +00:00
David Hewitt 97487ffbb5 add abi3-py311 feature 2022-11-23 08:08:12 +00:00
Georg Brandl 4a2e6bd51a ffi: fixup bytesobject/dictobject on PyPy
Fixes #2758
2022-11-20 11:31:24 +01:00
Georg Brandl 68e82ec962 ffi: link to _PyPyBytes_Resize
Fixes #2737
2022-11-19 12:25:11 +01:00
Georg Brandl 1d20f2a531
Export warning classes and add PyErr::warn_explicit() (#2742) 2022-11-17 19:30:48 +01:00
Adam Reichold 694ef1ea39 Make Clippy happy again by removing supposedly unnecessary casts. 2022-11-15 21:50:29 +01:00
Itamar Turner-Trauring 6746ff8216
Python 3.7 support for PyCodeObject. (#2726)
* Python 3.7 support for PyCodeObject.

Co-authored-by: Itamar Turner-Trauring <itamar@pythonspeed.com>
2022-11-08 21:06:05 +00:00
David Hewitt 548e90fcec release: 0.17.3 2022-11-01 20:47:46 +00:00
messense 736e97556d
Disable `PyModule::filename` on PyPy 2022-10-31 15:45:50 +08:00
David Hewitt bd40011e93 release: 0.17.2 2022-10-04 08:13:53 +01:00
David Hewitt 8102ad1a1b rust: updates for 1.64 2022-09-22 21:03:34 +02:00
David Hewitt caaf7bbda7 release: 0.17.1 2022-08-28 08:27:56 +01:00
David Hewitt 04c1ac87f1 release: 0.17.0 2022-08-23 21:21:19 +01:00
mejrs 26fe75e9b5 Also update the readme 2022-08-23 13:54:11 +02:00
mejrs 5b845d3b1a Improve pyo3-ffi example 2022-08-22 22:27:05 +02:00
mejrs 3845e3fe33 Make a way to make const zeroed PyMethodDef 2022-08-22 22:25:02 +02:00
David Hewitt 88ad288345 ffi: swap field order in PyCodeObject for 3.11 2022-08-19 09:28:57 +01:00
David Hewitt 218ef6cd83 ffi: more fixes for Python 3.11 rc1 2022-08-16 18:17:50 +01:00
David Hewitt 1e73ef67f2 ffi: fixes to 3.11 bindings 2022-08-14 14:23:24 +01:00
David Hewitt c58ff7758c pypy: disable PyFunction 2022-08-13 17:51:10 +01:00
messense 3c0520da83
Add FFI definitions for `Py_EnterRecursiveCall` and `Py_LeaveRecursiveCall` (#2511)
* Add FFI definitions for `Py_EnterRecursiveCall` and
`Py_LeaveRecursiveCall`

* Update pyo3-ffi/src/ceval.rs

Co-authored-by: David Hewitt <1939362+davidhewitt@users.noreply.github.com>

Co-authored-by: David Hewitt <1939362+davidhewitt@users.noreply.github.com>
2022-07-15 15:45:15 +08:00
David Hewitt 7babd13830 datetime: support timezone bindings 2022-07-13 22:05:17 +01:00
Andrew Burkett 3fd0c0e142
Fix PyObject_CallNoArgs python version cfg (#2476)
* Fix PyObject_CallNoArgs python version cfg

PyObject_CallNoArgs was added to python 3.9 but not to limited api until 3.10 per https://docs.python.org/3/c-api/call.html#c.PyObject_CallNoArgs

* Update change log

* Fix uses of PyObject_CallNoArgs

Co-authored-by: Andrew Burkett <andrew.burkett@crowdstrike.com>
2022-06-23 21:31:44 +01:00
David Hewitt 866ddaca8a ffi: tidy descrobject.rs 2022-06-07 19:45:36 +01:00
Alex Gaynor 9cfbdeca78 ffi: fixes for field names/presence
pyo3-ffi-check now passes for me on 3.9
2022-06-05 07:39:17 -04:00
David Hewitt 6f4e84f25f ffi: more pypy fixes 2022-06-05 09:24:46 +01:00
David Hewitt 9300bff551 ffi: field fixes from pyo3-ffi-check 2022-06-05 08:17:14 +01:00
Alex Gaynor e1c8bda4ee
fixed name of initfunc field on _inittab 2022-06-04 22:15:51 -04:00
Alex Gaynor 485994fa90
ob_shash is available on CPython
This struct is opaque on PyPy anyways, so the conditional didn't make sense.
2022-06-04 15:01:54 -04:00
David Hewitt 9777faddc6
Merge pull request #2429 from alex/pyopccache-py311
_PyOpcache does not exist on Python 3.11
2022-06-04 18:22:42 +01:00
Bruno Kolenbrander 728d35aa7d
Expand on the C api definitions (#2409)
* Expand on the C api

* Fix Ci

* Fix PyCodeObject structure

* Add descrobjects

* Add None and NotImplemented type objects

* Update pyo3-ffi/src/cpython/object.rs

Co-authored-by: David Hewitt <1939362+davidhewitt@users.noreply.github.com>

* Fix PyPy definitions

* Fix CI

* Fix CI

* Fix CI

* Fix CI

* Fix CI

* Fix CI

Co-authored-by: David Hewitt <1939362+davidhewitt@users.noreply.github.com>
2022-06-04 18:22:18 +01:00
Alex Gaynor 12d38dbcf8 _PyOpcache does not exist on Python 3.11
NB: the definition of PyCodeObject is still quite wrong. This is the minimal change to get pyo3-ffi-check to compile at all!
2022-06-04 10:46:05 -04:00
David Hewitt cdf86482d8 ffi: many fixes to pypy definitions 2022-06-04 12:47:40 +01:00
David Hewitt 0d78e88b14 ffi: fix PyTypeObject definition on Python 3.8 2022-06-04 08:12:27 +01:00
David Hewitt f8a9837c3a ffi: fix PyFrameObject definition 2022-06-02 17:47:23 +01:00
David Hewitt 78cdc6d6ad ffi: many fixes caught by pyo3-ffi-check 2022-06-02 16:32:07 +01:00
David Hewitt 6a9f5fd705 ffi: remove PyArena on 3.10 and up 2022-06-02 09:35:35 +01:00
David Hewitt 6741104762 ffi: fix names of _Base datetime structs 2022-06-02 09:35:35 +01:00
David Hewitt 1d50ffd500
Merge pull request #2407 from alex/patch-2
Make Py_tracefunc an unsafe func
2022-06-02 08:55:07 +01:00
Alex Gaynor 7a7926c0ff
Update pyframe.rs 2022-05-28 22:45:50 -04:00
Alex Gaynor c2faef4b64
Make Py_tracefunc an unsafe func
There's basically no way to safely write a function with raw pointers for parameters.
2022-05-28 22:28:19 -04:00
Alex Gaynor b651502c11
Expose PyFrame_GetCode 2022-05-28 15:47:47 -04:00
herquan 2ec477344d Add macro append_to_inittab
Sometimes we need to debug in a real environment with our module installed. `append_to_inittab` will be a wrapper for PyImport_AppendInittab (https://docs.python.org/3/c-api/import.html#c.PyImport_AppendInittab) and help us to do this
2022-05-24 07:42:15 +01:00
David Hewitt 3dcbcb7a95 update main to reflect 0.16.5 release 2022-05-15 20:31:00 +01:00
David Hewitt 8636db67f5 add regression test for PEP 587 2022-05-15 16:08:21 +01:00
Gregory Szorc f1c477b536 ffi: add new 3.11 fields to PyConfig
These are the new fields in 3.11 so far. 3.11 is supposedly feature
frozen, so hopefully we don't need to revisit this struct before 3.11
final.
2022-05-13 17:52:31 -07:00
Gregory Szorc 03cb561d41 ffi: add PyConfig::warn_default_encoding to 3.10+
This field was added in 3.10 but we missed it. This was causing
offsets of subsequent fields to be wrong. This could lead to
unexpected behavior or even crashes.
2022-05-13 17:49:58 -07:00
messense c477718fe7
Add support for generating non-abi3 python import libraries for Windows
targets
2022-05-12 14:32:20 +08:00
David Hewitt 10b09297b1 ffi: remove eval.rs 2022-05-11 03:44:27 +01:00
David Hewitt 5d8fd4d30e ffi: remove with_thread cfg 2022-05-05 07:26:05 +01:00
messense 97a9121025
pyo3-ffi: forward `extension-module` feature to `pyo3-build-config` 2022-04-19 13:17:47 +08:00
messense 1276068891
Add `generate-abi3-import-lib` feature to `pyo3-ffi` 2022-04-19 13:17:43 +08:00
Adam Reichold d2caa056e9 release: 0.16.4 2022-04-14 07:56:42 +01:00
David Hewitt cb48557601
Merge pull request #2296 from davidhewitt/print-config-note
build: add hint when PYO3_PRINT_CONFIG is set
2022-04-12 08:27:49 +01:00
David Hewitt b35fed00d7 build: add hint when PYO3_PRINT_CONFIG is set 2022-04-12 07:54:23 +01:00
David Hewitt 391a375bae ffi: add BaseDateTime and BaseTime definitions 2022-04-12 07:46:38 +01:00
David Hewitt 1d9d60a766 ffi: fix segfault in _GET_TZINFO methods 2022-04-10 10:27:50 +01:00
David Hewitt 1ae0971a09 release: 0.16.3 2022-04-05 04:05:57 +01:00
David Hewitt c16cc35b30 pyclass: mapping flag 2022-04-02 16:15:44 +01:00
Sergey Kvachonok 9b45a19161 pyo3-build-config: Replace `TargetInfo` with `target_lexicon::Triple`
Add a new public crate function `cross_compile_from_to()` using
`target_lexicon::Triple` arguments instead of plain strings
used in `cross_compile()`.

Deprecate `pyo3_build_config::cross_compile()` since v0.17.

Attempt to extract common code patterns into methods and standalone
helper functions. Add docstrings to the new private items.
Make some of the new helper functions public within the PyO3 crate
and reuse them in the build scripts.

Add PYO3_CROSS_PYTHON_VERSION parsing unit test.

Add a ChangeLog entry mentioning the new `pyo3-build-config` API.
2022-04-01 09:36:49 +03:00
messense 23e220985a
Mark `METH_FASTCALL` as limited API on Python 3.10+
0b9c4c6fcf (diff-adb492ab0eb13648d50d0d79e4b6e5517b27f983ab3b21b63e77f54132c98e9dR76)
2022-03-26 21:27:49 +08:00
messense f3f0a612d8
Add FFI definition for `PyModule_AddType` 2022-03-26 21:27:49 +08:00
messense 92c132569f
Add FFI definitions for PEP 573 functions 2022-03-26 21:27:44 +08:00
David Hewitt 16ee22c7cc
Merge pull request #2244 from mejrs/lint-more
Add more lints
2022-03-23 13:40:35 +00:00
mejrs 00ea040834 Feedback 2022-03-23 13:30:32 +01:00
Ashley Anderson 4a62a62cae Improvements based on code review: API and documentation. 2022-03-21 12:55:39 -04:00
Ashley Anderson bbe7a493d6 Refactor to serialize the whole InterpreterConfig into DEP_PYTHON_PYO3_CONFIG 2022-03-17 12:10:38 -04:00
Adam Reichold 922bbfc92d release: 0.16.2 2022-03-15 19:20:00 +01:00