Commit Graph

200 Commits

Author SHA1 Message Date
David Hewitt e28403e772 call PyObject_GC_Untrack before deallocating 2023-09-09 22:29:58 +01:00
David Hewitt ad042f3bae add comments to ffi def structures
Co-authored-by: Bruno Kolenbrander <59372212+mejrs@users.noreply.github.com>
2023-09-06 08:56:51 +01:00
David Hewitt 9336e5b605
Merge pull request #3403 from davidhewitt/ffi-objimpl
update definitions for objimpl.h
2023-08-19 12:02:32 +00:00
Adam Reichold e6293a9608
Merge pull request #3405 from davidhewitt/debug-3.11
fix compile warning on pre-3.12 debug builds
2023-08-19 05:25:57 +00:00
David Hewitt 69475b0a83 update definitions for objimpl.h 2023-08-18 22:17:53 +01:00
David Hewitt 7fce07935c fix compile warning on pre-3.12 debug builds 2023-08-18 22:15:29 +01:00
David Hewitt eba2c59778 tidy up some file locations after dual licensing 2023-08-16 08:22:51 +01:00
David Hewitt ff823ac3df
Merge pull request #3390 from puradox/fix/ffi-license
Replace pyo3-ffi LICENSE with ACKNOWLEDGEMENTS
2023-08-15 23:07:55 +00:00
Sam Balana 0607905771
Replace pyo3-ffi LICENSE with ACKNOWLEDGEMENTS
Replace the Python license from pyo3-ffi/LICENSE with an
ACKNOWLEDGEMENTS file. Relicense under the parent Apache 2.0 license.

pyo3-ffi contains a Rust reproduction of the CPython header files, only
copying what is absolutely necessary for binary compatibility. As such,
it is unnecessary to include the Python license.

Fixes #3124
2023-08-15 15:29:53 -07:00
DataTriny 3c3e9401a3 Dual-license 2023-08-15 23:39:45 +02:00
David Hewitt b0f5901ce3 update structmember.rs for Python 3.12 2023-08-11 11:54:16 +01:00
David Hewitt acb1bf7c0a update fileobject.rs for Python 3.12 2023-08-11 11:54:16 +01:00
David Hewitt 5d7dfe2e95 update pydebug.rs for Python 3.12 2023-08-11 11:54:16 +01:00
Adam Reichold 1df7270e15
Merge pull request #3374 from Tpt/pathlike
Makes PathBuf FromPyObject implementation work on all os.PathLike
2023-08-09 14:50:28 +00:00
Tpt dd04d2c4cc Fixes linking of `PyOS_FSPath` on PyPy. 2023-08-09 16:19:17 +02:00
Alex Gaynor 51fdf3afef
Update constants for py3.12, which fixes struct sizes
See 766d2518ae8384c6bd7f82727defeb86847ccf64
2023-08-08 15:07:59 -04:00
David Hewitt 284c42d840 release: 0.19.2 2023-08-01 07:29:04 +01:00
David Hewitt 4e957e8bd4 update object.h definitions for Python 3.12 2023-07-30 15:37:06 +01:00
David Hewitt e2c88d5a4e optimize `float` -> `f64` conversions on non-abi3 2023-07-28 20:45:37 +01:00
David Hewitt 7a2fc86186
Merge pull request #3342 from davidhewitt/3.12-ffi-check-fixes
fix ffi check failures for 3.12.0b4
2023-07-25 11:59:55 +00:00
David Hewitt 655de94749 fix ffi check failures for 3.12.0b4 2023-07-25 08:25:34 +01:00
David Hewitt 3fa705a3c6 remove PyUnicode_WCHAR_KIND from docs on Py_3_12 2023-07-25 07:35:57 +01:00
Adam Reichold 8ce6c26c81
Merge pull request #3334 from davidhewitt/pyerr-display
add PyErr::display
2023-07-25 05:56:21 +00:00
David Hewitt a15614844d add PyErr::display 2023-07-24 22:14:55 +01:00
Marc Mueller f8ca456f5f Add PyType_GetDict for Python 3.12 2023-07-23 17:00:50 +02:00
David Hewitt 45ff25cd2a clippy: deny / fix used-underscope-binding lint 2023-07-16 20:49:45 +01:00
Adam Reichold bd7aed4b12 Add implementation of Iterator::size_hint for PyIterator
When the Python iterator backing `PyIterator` has a `__length_hint__` special
method, we can use this as a lower bound for Rust's `Iterator::size_hint` to
e.g. support pre-allocation of collections.

This is implemented using `PyObject_LengthHint` which is not available in the
stable ABI and hence so is `Iterator::size_hint`. This should be fine since this
is an optimization in any case and the stable ABI is expected to have slightly
worse performance overall.
2023-07-09 10:16:20 +02:00
David Hewitt f7f3ff8820 fix FFI definition `Py_EnterRecursiveCall` 2023-07-05 22:52:41 +01:00
David Hewitt 82712aed32 fix `SystemError` raised from `PyUnicodeDecodeError_Create` on PyPy 3.10 2023-07-05 11:10:02 +01:00
David Hewitt 6666c335e6 add PyState_*Module definitions for PyPy 2023-07-04 08:57:50 +01:00
David Hewitt 7d357ad992 release: 0.19.1 2023-07-03 16:18:24 +01:00
David Hewitt db91642bae add `PyDict::get_item_with_error` for PyPy 2023-06-25 19:26:08 +01:00
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