Commit Graph

2245 Commits

Author SHA1 Message Date
David Hewitt 747d791f1f
introduce trampolines for methods (#2705) 2022-10-25 07:22:36 +01:00
David Hewitt 1c3c5f2c5f
Merge pull request #2661 from davidhewitt/std-conversions
refactor: move std conversions into common module
2022-10-20 07:58:02 +01:00
David Hewitt 39a68cf7ac
Merge pull request #2687 from saethlin/main
Avoid calling slice::from_raw_parts with a null pointer
2022-10-20 07:34:39 +01:00
David Hewitt fb34ed1694 add more coverage 2022-10-20 07:29:42 +01:00
David Hewitt c76916a084 refactor: move std conversions into common module 2022-10-19 21:36:39 +01:00
Ben Kimock 7ff5ab770a Avoid calling slice::from_raw_parts with a null pointer 2022-10-18 17:09:27 -04:00
Georg Brandl 676227d2a1
Make `is_instance()` and `is_subclass()` take `&PyAny` (#2695) 2022-10-18 19:22:23 +02:00
Bruno Kolenbrander 4a04603c2c
Don't use intocallback in method macros (#2664)
* Don't use intocallback in method macros

Co-authored-by: mejrs <>
2022-10-16 10:35:58 +01:00
David Hewitt 125af9b7de
Merge pull request #2676 from PyO3/exact-iter
Add more implementations of ExactSizeIterator when iterating built-in Python data structures.
2022-10-13 21:28:04 +01:00
Adam Reichold f456ed7586 Also relax the PySequence check when extracting fixed-sized arrays. 2022-10-13 09:43:45 +02:00
Adam Reichold 9847530cc8 Fix code blocks containing HTML-related characters missing backticks. 2022-10-13 07:33:11 +02:00
Adam Reichold cd361dc5cc Add more implementations of ExactSizeIterator when iterating built-in Python data structures. 2022-10-11 18:21:02 +02:00
David Hewitt 372176630e guide: doctest function/ subpages 2022-09-27 07:52:14 +01:00
smheidrich bc00e9ff12 Improve PyLong/PyFloat doc links to PyAny::extract 2022-09-24 20:59:04 +02:00
smheidrich 9572220f6c Fix links to ToPyObject in types docs 2022-09-24 20:08:43 +02:00
Federico Dolce eced1593f5 Fixed wrong proptest in chrono conversion module 2022-09-22 14:48:55 +02:00
Federico Dolce 63f7df905d
Add chrono 0.4 integration (#2612)
Co-authored-by: Ivan Tham <pickfire@riseup.net>
Co-authored-by: David Hewitt <1939362+davidhewitt@users.noreply.github.com>
2022-09-22 09:00:09 +02:00
David Hewitt 81a79778a2
Merge pull request #2631 from PyO3/relax-extract-sequence-pre-0.17
Relax extract_sequence to the status quo before 0.17 was released
2022-09-21 11:52:34 +02:00
David Hewitt a0be791577
Merge pull request #2630 from davidhewitt/option-pyclass-arg
pyfunction: fix compile error for Option<&T> argument with a default
2022-09-21 11:44:55 +02:00
Adam Reichold b6c6f7f2b6 Fix #2615 by relaxing the type check in extract_sequence.
This allows us to handle types like one-dimensional NumPy arrays which implement
just enough of the sequence protocol to support the extract_sequence function
but are not an instance of the sequence ABC.
2022-09-21 09:47:05 +02:00
David Hewitt c445eba28d pyfunction: fix compile error for Option<&T> argument with a default 2022-09-20 15:44:55 +02:00
Mario Rugiero d72989f986
Enable BigInt conversion for PyPy (#2626)
* Enable bigint conversion for PyPy

* Update src/conversions/num_bigint.rs

* Add a changelog entry for PyPy `num-bigint` support

Co-authored-by: messense <messense@icloud.com>
2022-09-20 18:55:14 +08:00
David Hewitt ab8f940e46 docs: require docs on all public APIs 2022-09-07 07:42:23 +01:00
Ivan “CLOVIS” Canet 453e3559d3
Python types: use Cow instead of bare references 2022-09-06 21:30:39 +02:00
Ivan “CLOVIS” Canet 0e6ae6489f
Declare the Python type of Rust collections 2022-09-06 21:30:38 +02:00
Ivan “CLOVIS” Canet 2ffc4bb6f6
Declare the Python type of Rust primitives 2022-09-06 21:30:38 +02:00
Ivan “CLOVIS” Canet d7c1a2906a
IntoPy and FromPyObject allow the retrieval of the type information 2022-09-06 21:30:36 +02:00
Ivan “CLOVIS” Canet 8898bc9900
Represent Python types
The TypeInfo structure represents Python types used in hints. Its Display implementation converts it to the exact syntax for it to appear in a type hint.
2022-09-06 21:30:16 +02:00
David Hewitt 5718adeec7 pyproto: remove deprecated feature 2022-09-06 08:38:44 +01:00
Eric Jolibois 611ecc15fa
fix: export new dict views types (#2590)
* fix: export new dict views types

* fix exposed PyDictItems

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

* add changelog entry

Co-authored-by: David Hewitt <1939362+davidhewitt@users.noreply.github.com>
2022-08-25 09:03:57 +01:00
David Hewitt f7ebda8ce3 docs: note with_gil auto-creates thread state 2022-08-23 20:49:14 +01:00
David Hewitt af60a359c5 guide: don't use `::pyo3` 2022-08-23 20:49:14 +01:00
mejrs ae50da1e3e Mention a concrete pyo3 version 2022-08-22 21:14:07 +02:00
mejrs db8b55a3fc pyproto is no longer enabled by default 2022-08-21 17:51:11 +02:00
David Hewitt d0492b7c72
Merge pull request #2570 from davidhewitt/pyclass-frozen-tidy
pyclass: tidy up frozen implementation
2022-08-21 09:35:51 +01:00
David Hewitt 24456f3f41 pyclass: tidy up frozen implementation 2022-08-21 08:21:06 +01:00
David Hewitt fd8026c7bb pyclass: add `sequence` option to implement `sq_length` 2022-08-20 07:14:26 +01:00
David Hewitt 5d44c5225c
rebase of #2553 - created a builder for creating types, allowing for more flexibility (#2565)
* Rewrote `create_type_object_impl` to use a builder, allowing for more flexibility.

* Fixed clippy warning about complex type

* Removed `with_` prefix from `PyTypeBuilder`

* Fixed misnamed function call

Co-authored-by: Aidan Grant <mraidangrant@gmail.com>
2022-08-19 11:33:04 +01:00
mejrs fc6121eafe Deprecate acquire_gil 2022-08-15 03:34:47 +02:00
David Hewitt a3f093d7f0 safety: abort on uncaught panics 2022-08-14 13:47:46 +01:00
David Hewitt de8fa18946 clippy: fixes flagged by beta toolchain 2022-08-14 07:44:11 +01:00
David Hewitt c58ff7758c pypy: disable PyFunction 2022-08-13 17:51:10 +01:00
Ashley Anderson 5d88e1d1c4
Update PyTryFrom for PyMapping and PySequence to more accurately check types (#2477)
Co-authored-by: David Hewitt <1939362+davidhewitt@users.noreply.github.com>
2022-08-10 21:03:18 +01:00
David Hewitt 78ba70d2b4 pymodule: only allow initializing once per process 2022-08-09 19:52:25 +01:00
dswij 480fe7ef05
Expose `PyDict_GetItemWithError` on `PyDict` object (#2536)
* Expose `PyDict_GetItemWithError` on `PyDict` object

* Expose only on non-pypy

* use `unwrap_err` on `GetItemWithError` test

* Add changes info to changelog

* Ignore import for pypy ignored test
2022-08-07 00:19:02 +08:00
David Hewitt 2aa44b5c16 types: rework PyCapsule for soundness 2022-07-23 20:54:31 +01:00
mejrs 984fdf57c7 Use Python:;with_gil in tests 2022-07-19 19:34:23 +02:00
David Hewitt fa19f322d2
Merge pull request #2503 from davidhewitt/extract_argument_holder
pyfunction: use extract_argument with holder to avoid extractext
2022-07-17 07:14:53 +01:00
messense a00e9d553d
Update Python to 3.11.0b4 in emscripten test (#2507)
* Update Python to 3.11.0b4 in emscripten test

* Print traceback when import exception failed

* Try `ALLOW_MEMORY_GROWTH=1`
2022-07-15 20:39:58 +01:00
David Hewitt 5ff494c855
Merge pull request #2283 from davidhewitt/0.15-deprecations
refactor: remove all 0.15 deprecations
2022-07-15 07:49:51 +01:00
David Hewitt d5e99b635d refactor: remove all 0.15 deprecations 2022-07-15 06:33:14 +01:00
David Hewitt 209c942277 pyfunction: use extract_argument with holder to avoid extractext 2022-07-14 08:42:22 +01:00
David Hewitt 2623ed5ac6 fix formatting in datetime tests 2022-07-14 08:35:24 +01:00
David Hewitt 7babd13830 datetime: support timezone bindings 2022-07-13 22:05:17 +01:00
Jérome Eertmans 308ffa25b0
Prevent `str` from converting to `Vec<&str>` and `Vec<String>` (#2500) 2022-07-13 21:44:44 +01:00
David Hewitt c4a2c6c912 clippy: fix some warnings from beta toolchain 2022-07-12 23:02:47 +01:00
Ivan Krivosheev 1cd1dbfe8b
Add super object (#2486) 2022-07-03 19:21:15 +01:00
Bruno Kolenbrander 58d4ba833e
Rust 1.62 (#2489)
* Rust 1.62

* Make rust happy

* Just use a doctest instead

Co-authored-by: mejrs <>
2022-07-02 16:08:01 +01:00
Bruno Kolenbrander 8babae655e
Merge pull request #2468 from mejrs/frozen
Add frozen documentation
2022-06-30 14:45:45 +02:00
David Hewitt d5ac565f33 security: fix use-after-free in PyCapsule implementation 2022-06-26 07:18:23 +01:00
David Hewitt ab0bc95152 sanitizers: fix use-after-free in test 2022-06-26 07:16:23 +01:00
David Hewitt 4da9c3a55f llvm-lines: use iterator to collect class items 2022-06-25 22:03:28 +01:00
David Hewitt 2bf2d49329 llvm-lines: use fn() pointers in extract_argument expansion 2022-06-25 22:03:28 +01:00
David Hewitt 2096e30bca opt: fix generic code bloat in LazyStaticType::get_or_init 2022-06-25 22:03:28 +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
Ashley Anderson bde5102eb8
Increasing test coverage (#2462)
* cov: src/buffer.rs - add tests for debug and element from format

* cov: src/buffer.rs - add some fortran-specific calls in test_array_buffer

* fix issues in MSRV

* cov: src/types/function.rs - directly call PyCFunction::new and PyCFunction::new_with_keywords

* docs: clarify docs of PyCFunction::new and PyCFunction::new_with_keywords

* revert added rust-version for MSRV in Cargo.toml

* cov: src/types/slice.rs - simple tests for PySliceIndices::new

* fix for multi-platform

* Update src/types/function.rs

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

* cov: src/buffer.rs - a better PyBuffer Debug test

Co-authored-by: David Hewitt <1939362+davidhewitt@users.noreply.github.com>
2022-06-23 21:30:22 +01:00
David Hewitt 3d9b78062e opt: remove some generic code bloat 2022-06-22 22:53:32 +01:00
mejrs e4e7e6e51c Add frozen documentation 2022-06-22 01:47:40 +02:00
Georg Brandl 53b83cccbf
add `CompareOp::matches` (#2460) 2022-06-21 15:36:20 +02:00
David Hewitt 2fd5364646 pycell: add more test coverage 2022-06-19 21:18:15 +01:00
David Hewitt 7725f17c46 pyclass: switch from immutable to frozen 2022-06-19 21:18:15 +01:00
mejrs 2d94cb4a2d use memoffset instead 2022-06-12 18:28:21 +02:00
mejrs 2d3a5852ed Avoid UB in *_offset methods 2022-06-12 15:11:39 +02:00
mejrs 56c218f70e Fix annoying inference errors 2022-06-12 01:39:34 +02:00
Hood Chatham da5b9814cc
Set up CI for wasm32-emscripten target (#2436)
* ci: test on emscripten target

This adds CI to build libpython3.11 for wasm32-emscripten and
running tests against it. We need to patch instant to work
around the emscripten_get_now:
https://github.com/sebcrozet/instant/pull/47

We also have to patch emscripten to work aroung the "undefined
symbol gxx_personality_v0" error:
https://github.com/emscripten-core/emscripten/issues/17128

I set up a nox file to download and install emscripten,
download and build cpython, set appropriate environment variables
then run cargo test. The workflow just installs python, rust,
node, and nox and runs the nox session.

I xfailed all the test failures. There are problems with datetime.
iter_dict_nosegv and test_filenotfounderror should probably be
fixable. The tests that involve threads or asyncio probably can't
be fixed.

* Some cleanup

* Remove instant patch

* Add explanations for xfails
2022-06-08 05:59:18 +01:00
David Hewitt 866ddaca8a ffi: tidy descrobject.rs 2022-06-07 19:45:36 +01:00
David Hewitt cdf86482d8 ffi: many fixes to pypy definitions 2022-06-04 12:47:40 +01:00
David Hewitt a746411b24
Merge pull request #2422 from davidhewitt/frompyobject-fixes
frompyobject: improve error messages of derived impls
2022-06-02 13:30:03 +01:00
David Hewitt f50406a034
Merge pull request #2413 from davidhewitt/simpler-interned
macros: simpler expansion for `intern!`
2022-06-02 12:54:11 +01:00
David Hewitt 0aa4f95a98 frompyobject: improve error messages of derived impls 2022-06-02 11:13:35 +01:00
David Hewitt 261c0c5f56 macros: simpler expansion for `intern!` 2022-06-02 09:57:58 +01:00
David Hewitt 6a9f5fd705 ffi: remove PyArena on 3.10 and up 2022-06-02 09:35:35 +01:00
David Hewitt e4ec720d51 frompyobject: tidy up generated code 2022-06-02 08:54:20 +01:00
David Hewitt cfb91057af frompyobject: improve error message for tuple case 2022-06-02 08:54:20 +01:00
Alex Gaynor f6a24972e9 Added new PyCode and PyFrame objects.
They currently do not expose any APIs, but are significantly easier to work with than raw pointers :-)
2022-05-31 16:57:10 -04:00
Bruno Kolenbrander 4f9d3d7306
Protect iterators against concurrent modification (#2380) 2022-05-31 20:13:04 +01:00
David Hewitt eafbbc5417
Merge pull request #2399 from davidhewitt/avoid-duplicate-pymethods
pymethods: prevent methods sharing the same name
2022-05-24 22:22:31 +01:00
David Hewitt a306365db8 pymethods: prevent methods sharing the same name 2022-05-24 21:15:30 +01:00
David Hewitt 126bf49b8b
Merge pull request #2377 from herquan/herquan_cr1
Add macro append_to_inittab (issue #2359)
2022-05-24 08:02:47 +01: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 a21bd6f967
Merge pull request #2385 from davidhewitt/classattr-results
Allow `#[classattr]` methods to be fallible
2022-05-21 19:09:07 +01:00
David Hewitt 82b26b7cfa datetime: remove reference to leap seconds 2022-05-17 21:21:15 +01:00
David Hewitt 0de0e3f8d6 Allow `#[classattr]` methods to be fallible 2022-05-17 21:19:41 +01:00
David Hewitt 570107d103 docs: fix nightly build 2022-05-17 19:48:40 +01:00
David Hewitt 7a9e70e2c7 wrap_x: change macros back to `macro_rules!` 2022-05-14 20:42:07 +01:00
David Hewitt 1482b526de
types: add dict views (#2358) 2022-05-11 20:34:22 +01:00
messense 76c09ac3ed
Remove `#[doc(hidden)]` from trait impl items (#2365)
See https://github.com/rust-lang/rust/pull/96008
2022-05-10 19:26:53 +01:00
Bruno Kolenbrander c57e5098b8
Fix IntoPyCallbackOutput paper cuts (#2326)
* Implement IntoPy for arrays of IntoPy

* Improve `IntoPyCallbackOutput` compile error
2022-05-09 18:15:43 +01:00
David Hewitt bc8641c790
Merge pull request #2350 from mejrs/ignore-less
Expand on AsPyPointer docs and un-ignore doc examples
2022-05-06 06:51:54 +01:00
mejrs f1e5d4c9a1 Un-ignore and expand on doc examples 2022-05-03 00:47:09 +02:00
mejrs f34b92a368 Expand conversions documentation 2022-05-03 00:46:53 +02:00
Alex Gaynor c6055c03f1
fixed comment in string.rs 2022-05-02 11:12:19 -06:00
Bruno Kolenbrander dce4377eb4
Allow more methods to take interned arguments (#2312)
* Allow more methods to take interned arguments

* Changelog

* Unify name bounds

* Resolve merge conflict

* reduce use of py_decref

* Add some attr tests

* Update migration
2022-05-02 11:13:15 +02:00
David Hewitt 1596ab8a4b
Merge pull request #2333 from davidhewitt/remove-toborrowedobject
remove `ToBorrowedObject` trait
2022-04-26 06:23:35 +01:00
David Hewitt 71f9f18d54 remove toborrowedobject trait 2022-04-26 05:48:34 +01:00
David Hewitt 4168feed1b opt: tidy some generic code bloat 2022-04-26 05:36:57 +01:00
cuishuang 19e32a0621 fix some typos
Signed-off-by: cuishuang <imcusg@gmail.com>
2022-04-24 22:06:32 +08:00
David Hewitt e05cec01e4 cleanup: unused cls.rs 2022-04-24 09:20:20 +01:00
David Hewitt 7e2d3117ce cleanup: deprecate PyTypeObject trait 2022-04-23 13:36:32 +01:00
David Hewitt ca8958c347
Merge pull request #1979 from mejrs/immutable
Opt out of PyCell borrow tracking
2022-04-23 13:34:02 +01:00
David Hewitt b196aa1d5a remove some redundant traits 2022-04-23 06:27:55 +01:00
David Hewitt e9bd41efb2 better mutability inheritance rules 2022-04-21 20:51:28 +01:00
David Hewitt 7118e94947 Merge branch 'main' into immutable 2022-04-19 19:00:33 +01:00
pigeon dea9eb7af6
Implement ToPyObject for [T; N] (#2313) 2022-04-19 15:09:54 +02:00
Adam Reichold 0d0089ea29 Remove redundant use statements and add missing calls to add_function in datetime test. 2022-04-13 09:40:16 +02:00
Ivan Tham a1f97f164d Add PyTzInfoAccess 2022-04-13 00:00:08 +08:00
Bruno Kolenbrander bc6bd6099c
Merge branch 'main' into immutable 2022-04-12 14:22:33 +02:00
mejrs b7745dffc8 Fix everything 2022-04-12 14:19:02 +02:00
Adam Reichold 551db72b55
Merge pull request #2279 from PyO3/extract-error-is-slow
Add benchmark highlighting the costs of failed calls to FromPyObject::extract.
2022-04-10 17:10:50 +02:00
Adam Reichold 10c285b283 Add PyDowncastErrorArguments to delay formatting downcast errors. 2022-04-10 13:13:03 +02:00
David Hewitt 1d9d60a766 ffi: fix segfault in _GET_TZINFO methods 2022-04-10 10:27:50 +01:00
David Hewitt 1971dd7a8a
Merge pull request #2286 from RicoHageman/main
Gather test coverage with stable rust
2022-04-08 19:28:13 +01:00
Rico Hageman c281275a29 Gather test coverage with stable rust 2022-04-08 14:24:10 +02:00
Adam Reichold 6a4ebbf2d7 Replace unhinted spin loops by sleeping events. 2022-04-08 11:16:40 +02:00
David Hewitt 9774a7c1c1
Merge pull request #2273 from PyO3/dog-food-intern
Make use of intern! macro for attribute names used internally
2022-04-05 00:41:35 +01:00
David Hewitt d3ac71a42b
Merge pull request #2269 from PyO3/intern-macro
RFC: Add intern! macro which can be used to amortize the cost of creating Python objects by storing them inside a GILOnceCell.
2022-04-05 00:34:37 +01:00
Adam Reichold f02a060a3d Add a hint on using intern! to Py{,Any}::{set,get}attr. 2022-04-04 23:11:38 +02:00
Adam Reichold 5434bbc3f6 Intern the __all__ and __name__ identifiers used by PyModule. 2022-04-04 22:26:14 +02:00
Adam Reichold 821b28daff Intern the __qualname__ identifier used by PyType::name. 2022-04-04 22:05:03 +02:00
Adam Reichold 89577a27d9 Isolate interned strings from their dynamic environment to avoid calling multiple times them with different text values yielding inconsistent results. 2022-04-04 22:04:46 +02:00
David Hewitt 981eb2d90e
Merge pull request #2265 from davidhewitt/pyclass-mapping
pyclass: mapping flag
2022-04-04 19:54:37 +01:00
Adam Reichold 7b99af9b34 Execute the example for intern macro to ensure it is correct. 2022-04-04 20:25:47 +02:00
Adam Reichold 30d414fd49 Add intern macro to hygiene tests and ensure it can handle stringified identifiers. 2022-04-04 18:53:31 +02:00
Adam Reichold f777372eed Limit the intern! macro to strings and intern the string contents in addition to the reference. 2022-04-04 10:11:52 +02:00
Adam Reichold 125bf416a2 Separate the fast and slow path of GILOnceCell::get_or_init. 2022-04-03 21:18:09 +02:00
Adam Reichold db109867d3 Add intern! macro which can be used to amortize the cost of creating Python objects by storing them inside a GILOnceCell. 2022-04-03 21:16:42 +02:00
Adam Reichold d3dcbd72ba
Add PyString::intern to enable access to Python's built-in string interning. (#2268) 2022-04-03 21:07:58 +02:00
David Hewitt c16cc35b30 pyclass: mapping flag 2022-04-02 16:15:44 +01:00
mejrs 086424b88c Merge branch 'main' of https://github.com/mejrs/pyo3 into immutable 2022-04-01 23:11:02 +02:00
mejrs 9ab1e6927a Merge branch 'immutable' of https://github.com/mejrs/pyo3 into immutable 2022-04-01 22:59:59 +02:00
Bruno Kolenbrander 78efebd993
Expand some documentation (#2256)
* use `is` where appropriate

* Rework safety docs
2022-03-30 12:56:14 +02:00
mejrs 00ea040834 Feedback 2022-03-23 13:30:32 +01:00
mejrs 6f1cf1b662 Add more lints 2022-03-23 08:07:28 +01:00
Alex Gaynor 69655454c1 Added an as_bytes method for Py<PyBytes>
This allows for obtaining a slice that's not lexically bound to the GIL which can be helpful to avoid copying.
2022-03-19 13:28:06 -04:00
David Hewitt 88cd9152b2 pypy: support 7.3.8 2022-03-08 21:09:16 +00:00
David Hewitt 2bd64c4962 guide: tidy up doctests 2022-03-04 22:50:12 +00:00
Bruno Kolenbrander 39534ba96d
Make gil tests not racy (#2190)
* Make tests not racy

* be a bit more resilient to other tests
2022-03-03 12:33:21 +01:00
David Hewitt ddf13ea98f clippy: enable some more lints 2022-03-03 07:23:28 +00:00
David Hewitt b59ee9b54b misc: tidy ups pre 0.16 2022-02-27 10:02:28 +00:00
Georg Brandl dc4f114d67 Address review comments 2022-02-26 20:10:33 +01:00
Georg Brandl 0678f11266 Protocols: implement __getattribute__
converting tp_getattro to a shared slot

Fixes #2186
2022-02-26 20:05:50 +01:00
Georg Brandl 03dc96bff1
Py/PyAny: remove PartialEq impl and add is() (#2183) 2022-02-25 19:39:45 +00:00
Tommaso Thea Cioni 487345979b
Added `eq`, `ne`, `gt` etc. methods. (#2175) 2022-02-25 18:52:20 +01:00
mejrs 39bd9991e8 Add some underscores 2022-02-25 07:28:22 +00:00
mejrs 071c31f140 Undo rename 2022-02-25 07:28:22 +00:00
David Hewitt f98f116131 pypy: support released 3.9 2022-02-25 07:28:22 +00:00
David Hewitt 7c865fcc25
Merge pull request #2173 from davidhewitt/deprecate-pyproto
pyproto: deprecate protocol traits
2022-02-24 23:54:40 +00:00
David Hewitt 3d7080b0b5
Merge pull request #2184 from davidhewitt/rust-1.59
rust: clippy fixes 1.59
2022-02-24 21:21:04 +00:00
David Hewitt 642fe5bb56 rust: clippy fixes 1.59 2022-02-24 20:17:05 +00:00
mejrs be84e0fbb9 Add numeric and object protocol examples 2022-02-23 10:09:45 +01:00
David Hewitt 253507b5dd migration: add note on pymethods -> pyproto 2022-02-23 07:50:55 +00:00
David Hewitt 24445df633 pyproto: deprecate protocol traits 2022-02-23 07:50:52 +00:00
David Hewitt d8ee35e19c
Merge pull request #2165 from mejrs/auto_trait
Implement Auto trait
2022-02-23 07:16:17 +00:00
mejrs ec275d49cb Explicitly (un)implement Ungil 2022-02-22 22:43:40 +01:00
mejrs 90281f88d3 Make conversion from String private 2022-02-22 22:43:40 +01:00
mejrs 97205bd11a Update docs 2022-02-22 22:43:40 +01:00
mejrs 9e29c1058c Gut specialization and implement auto trait
Implement auto trait

Implement auto trait

Undo oopsie

Fix versions

Fix CI errors

Fix CI

Remove more specialization remnants
2022-02-22 22:43:23 +01:00
Rico Hageman 3fbdc863cb Include the causes when throwing a PyTypeError when argument parsing failed 2022-02-22 09:48:41 +01:00
Rico Hageman 597e3e17a9 Pass detailed error message to python when parsing an argument fails 2022-02-21 23:22:40 +01:00
Bruno Kolenbrander 01788b7220
Merge pull request #2172 from mejrs/addr
Use addr_of_mut in pyo3-ffi
2022-02-19 17:56:09 +01:00
David Hewitt 79123b396c pyclass: deprecate gc option 2022-02-15 08:01:46 +00:00
David Hewitt 676295b8de pymethods: support gc protocol 2022-02-15 08:01:23 +00:00
David Hewitt 7851e865ae
Merge pull request #2166 from mejrs/union
Implement ml_meth as an union.
2022-02-15 07:55:24 +00:00
mejrs e5000e470a Use addr_of_mut instead 2022-02-14 23:18:22 +01:00
mejrs 718b0fd02f Remove options and rename struct 2022-02-14 15:14:49 +01:00
mejrs dadbc22b2e Implement nl_meth as an union. 2022-02-14 00:03:33 +01:00
Jacob Zhong 9a775c4380 Update src/conversions/num_bigint.rs
Co-authored-by: David Hewitt <1939362+davidhewitt@users.noreply.github.com>
2022-02-12 13:27:40 -05:00
Jacob Zhong d99a001b7d Fix the signature of _PyLong_NumBits 2022-02-12 13:27:40 -05:00
David Hewitt c5ef24bbea fix: memory leak in Option<T>::as_ptr 2022-02-11 22:18:11 +00:00
David Hewitt c93ee00130 refactor: inline handle_panic into macro output 2022-02-10 20:20:03 +00:00
David Hewitt f5b2a88a70 refactor: include __new__ as slot 2022-02-09 08:07:14 +00:00
David Hewitt 75e44585de refactor: pass tp_alloc and tp_free via slots 2022-02-09 08:07:14 +00:00
David Hewitt 4d471077b4 refactor: inline pyclass_default_items trait 2022-02-08 19:39:37 +00:00
David Hewitt 6f39deaa37 finish off implementation 2022-02-08 18:17:44 +00:00
mejrs 7520b49ac1 Implement opt-in immutable pyclasses 2022-02-08 18:08:18 +00:00
mejrs 3c1a0c6b7e Rename python.rs to marker.rs 2022-02-08 14:59:36 +01:00
b05902132 78f5afc82e Finish implementation for pyclass enums 2022-02-07 22:17:11 +00:00
David Hewitt 9def53317f
Merge pull request #2153 from davidhewitt/simplify-intrinsic-items
refactor: inline pyclass_intrinsic_items
2022-02-07 00:05:30 +00:00
David Hewitt e39881c208 refactor: inline pyclass_intrinsic_items 2022-02-06 23:26:57 +00:00
David Hewitt f75579a489 python-3.11: support buffer API on abi3 2022-02-06 22:46:45 +00:00
James Hilton-Balfe b2f9e28331
Add Mapping::contains (#2133)
* Add Mapping::contains

* Fix typo

* Add a changelog entry

* Use PyAny::contatins instead

* Update mapping.rs
2022-02-06 00:35:43 +00:00
David Hewitt ecfd2c2434 pyclass: simplify generated code for PyClassImpl 2022-02-05 16:58:01 +00:00
David Hewitt 558549e1c2 pyproto: split into new feature 2022-02-05 16:51:31 +00:00
David Hewitt 53c170078d pymethods: seq methods from mapping methods 2022-02-05 15:59:22 +00:00
David Hewitt 4305a9a45a
Merge pull request #2145 from davidhewitt/merge-pytests
pytests: merge benchmark and test crates
2022-02-05 12:27:56 +00:00
David Hewitt 5dd46e9fa9
Merge pull request #2146 from davidhewitt/pypy-ffi-cleanup
pypy: support fast long conversion
2022-02-05 11:24:44 +00:00
David Hewitt 8b47f4f120 pytests: merge benchmark and test crates 2022-02-05 10:16:46 +00:00
David Hewitt 71e5a12fa2 pypy: support fast long conversion 2022-02-05 10:14:14 +00:00
David Hewitt 02b7f99d28
Merge pull request #2144 from davidhewitt/cleanup-ffi-call
chore: cleanup old todo
2022-02-05 10:00:18 +00:00
David Hewitt 3a70406448 chore: cleanup old todo 2022-02-05 09:00:00 +00:00
David Hewitt abd7eafafb
Merge pull request #2134 from davidhewitt/optimize-extract-argument
opt: improve generated code for argument extraction
2022-02-05 00:33:45 +00:00
David Hewitt 1beb2bbb2d opt: optimize argument extraction 2022-02-04 20:53:49 +00:00
David Hewitt 199cc989d4
Merge pull request #2126 from DSPOM2/main
move ffi module to separate crate
2022-01-31 23:27:36 +00:00
DSPOM 6a9a9ba38a
move ffi module to separate crate 2022-01-31 13:27:16 +01:00
mejrs 86feca0bfd Fix clippy error 2022-01-25 13:22:04 +01:00
mejrs d4e3faa8ac Use owned pointer types instead 2022-01-25 13:10:07 +01:00
mejrs 0debb622d6 Clarify purpose of FaultyIter 2022-01-24 23:30:20 +01:00
mejrs edca8e9148 Fix PyPy cfg 2022-01-24 22:55:53 +01:00
mejrs 6ec1c0f596 Fix imports 2022-01-24 22:05:14 +01:00
mejrs d53a985f79 Fix soundness issues w/r `ExactSizeIterator` 2022-01-24 21:14:54 +01:00
David Hewitt 5444848cdc
Merge pull request #2119 from mejrs/lints
Remove useless allow(lint)'s
2022-01-21 00:41:39 +00:00
mejrs e569e5074a Remove useless allow(lint)'s 2022-01-21 01:08:36 +01:00
Ashley Anderson 1fd3c6177a Add 'contains' method to PyAny impl. 2022-01-19 21:19:01 -05:00
Jakub Kołodziejczak 020488efee
docs: example how to include multiple Python files into the binary and at runtime (#2095) 2022-01-17 10:57:39 +01:00
David Hewitt 1d50a7cca8 cleanup: always enable #[track_caller] 2022-01-16 19:16:36 +00:00
mejrs 2006ee0d21 Fix ci 2022-01-13 22:25:23 +01:00
David Hewitt de8174684f pyfunction: allow wrap_pyfunction to work on imports (even cross-crate) 2022-01-07 08:43:05 +00:00
David Hewitt 2cee7feaaf
Merge pull request #2083 from aviramha/magic_methods
verify py method args count
2022-01-07 00:13:05 +00:00
Aviram Hassan cbfb5acc43
fix guide 2022-01-06 10:02:53 +02:00
Aviram Hassan 9ae31f2b87
fix tests 2022-01-06 09:59:10 +02:00
David Hewitt a9b98b7433 pymethods: __ipow__ always receive None on Python 3.7 2022-01-04 22:59:08 +00:00
David Hewitt be70e5441b
Merge pull request #2085 from davidhewitt/opt-argument-extraction
opt: move fastcall boilerplate out of generated code
2022-01-03 08:13:31 +00:00
Aviram Hassan 50659b6b02
`__ipow__` now supports modulo argument on Python 3.8+.
`pyo3-macros-backend` is now compiled with PyO3 cfgs to enable different magic method definitions based on version.
Add check for correct number of arguments on magic methods.
2022-01-03 09:53:56 +02:00
David Hewitt 1a782ce4db opt: move fastcall boilerplate out of generated code 2022-01-03 00:07:32 +00:00
David Hewitt cf965155f4 pymethods: support buffer protocol 2021-12-30 15:48:55 +00:00
David Hewitt e33b3e6a5b opt: don't emit T::dict_offset and T::weakref_offset without attributes 2021-12-30 14:57:27 +00:00
David Hewitt 807e126178 pyclass: no need to try inherit base dict and weaklist 2021-12-30 14:17:58 +00:00
David Hewitt 90e8ef79e2 opt: reduce generated code for type object creation 2021-12-30 14:17:58 +00:00
David Hewitt ff37f24625 macros: accept paths in wrap_x macros 2021-12-30 12:46:57 +00:00
mejrs 8c2970939d Resolve merge conflicts 2021-12-28 05:38:45 +01:00
Bruno Kolenbrander 4d1d859a64
Merge branch 'main' into aliases 2021-12-24 22:28:22 +01:00
David Hewitt 90479ddae4 opt: make argument extraction code smaller 2021-12-24 01:52:15 +00:00
David Hewitt 33a618914f opt: reduce class creation generated code 2021-12-24 01:12:59 +00:00
David Hewitt 5be5d77589 opt: improve handle_panic generated code 2021-12-24 00:17:04 +00:00
mejrs 6afd80a26f Create full feature and change doc rendering 2021-12-22 12:09:16 +01:00
David Hewitt 492b7e4c0f macros: optimize generated code for #[derive(FromPyObject)] 2021-12-22 08:34:05 +00:00
David Hewitt 3858a63b80
Merge pull request #2064 from davidhewitt/test-hygiene-coverage-try-2
ci: ignore coverage for test_hygiene, try 2
2021-12-20 22:37:33 +00:00
David Hewitt 75fe8e50ed ci: ignore coverage for test_hygiene, try 2 2021-12-20 21:13:42 +00:00
David Hewitt 5cab5d4da3 misc: remove some more *const -> *mut pointer casts 2021-12-20 20:36:46 +00:00
Amanieu d'Antras 1fb20dab91 Avoid UB in PySlice::indices
Mutating a variables that is not declared with `mut` is undefined
behavior.
2021-12-20 18:28:36 +01:00
David Hewitt 4cec3a2ecf ci: no coverage necessary for hygiene tests 2021-12-18 08:56:22 +00:00
Bruno Kolenbrander 39cac9075b
Organize examples + add __call__ example (#2043)
* Add decorator example crate and split off chapter

* Move not-examples to their own folder

* Add some readme's

* Make black happy

* Make clippy happy

* Add decorator example crate and split off chapter

* Fix ci

* Add empty workspace key

* Try fix ci

* fix ci

* reuse target dir for examples CI

* add pytests folder to makefile recipes

* fix ci, try 2

* add missing pyproject.toml

* remove TOX_TESTENV_PASSENV from Makefile

Co-authored-by: David Hewitt <1939362+davidhewitt@users.noreply.github.com>
2021-12-15 00:45:26 +00:00
Bruno Kolenbrander 24d761d267
Merge branch 'PyO3:main' into exception_docstring 2021-12-14 17:13:24 +01:00
Daniel Henry-Mantilla 2d49dc33b7 Fix the `#[macro_export]` absolute path within the same crate issue 2021-12-09 07:36:48 +01:00
Georg Brandl a5b76bc365 pyo3_path, part 4: rename to `crate` to keep consistent with serde 2021-12-09 07:36:48 +01:00
Georg Brandl 681217d8d9 pyo3_path, part 3: move test_hygiene into lib crate
This removes the crate-root `pyo3` item to ensure that our
selected pyo3_path needs to be taken into account.
2021-12-09 07:36:48 +01:00
Bruno Kolenbrander 7dbbf7194a
Fix the main branch (#2046) 2021-12-09 01:03:50 +01:00
David Hewitt 6433d884fc dev: remove self dev dependency 2021-12-08 07:48:58 +00:00
David Hewitt 4c8abd1426 rust: support 1.57 2021-12-08 07:10:16 +00:00
mejrs 0ee13c1c1b Make new_type return Py<PyType> instead 2021-12-04 12:52:19 +01:00