Commit Graph

44 Commits

Author SHA1 Message Date
jatoben 7c2f5e80de
Don't raise `TypeError` from generated equality method (#4287)
* Don't raise TypeError in derived equality method

* Add newsfragment
2024-06-26 05:41:42 +00:00
Aneesh Agrawal c67625d683
Revamp PyType name functions to match PEP 737 (#4196)
* Revamp PyType name functions to match PEP 737

PyType::name uses `tp_name`, which is not consistent.
[PEP 737](https://peps.python.org/pep-0737/) adds a new path forward,
so update PyType::name and add PyType::{module,fully_qualified_name}
to match the PEP.

* refactor conditional code to handle multiple Python versions better

* return `Bound<'py, str>`

* fixup

---------

Co-authored-by: David Hewitt <mail@davidhewitt.dev>
2024-06-22 22:10:27 +00:00
David Hewitt a2f9399906
make datetime from timestamp tests compare against Python result (#4275)
* attemp to fix range for st.datetime

* remove example

* try fixing to utc

* make datetime from timestamp tests compare against Python result

---------

Co-authored-by: Cheukting <cheukting.ho@gmail.com>
2024-06-22 22:09:59 +00:00
Alex Gaynor baae9291cc
Update tests for numpy 2.0 (#4258) 2024-06-17 00:05:55 +00:00
David Hewitt 0b2f19b3c9
fix `__dict__` on Python 3.9 with limited API (#4251)
* fix `__dict__` on Python 3.9 with limited API

* [review] Icxolu suggestions

Co-authored-by: Icxolu <10486322+Icxolu@users.noreply.github.com>

* [review] Icxolu

* missing import

---------

Co-authored-by: Icxolu <10486322+Icxolu@users.noreply.github.com>
2024-06-16 07:57:44 +00:00
David Hewitt 388d1760b5
ci: start testing on 3.13-dev (#4184)
* ci: start testing on 3.13-dev

* ffi fixes for 3.13 beta 1

* support 3.13

* move gevent to be binary-only

* adjust for div_ceil

* fixup pytests
2024-05-25 22:41:26 +00:00
newcomertv 88f2f6f4d5
feat: support pyclass on tuple enums (#4072)
* feat: support pyclass on tuple enums

* cargo fmt

* changelog

* ruff format

* rebase with adaptation for FnArg refactor

* fix class.md from pr comments

* add enum tuple variant getitem implementation

* fmt

* progress toward getitem and len impl on derive pyclass for complex enum tuple

* working getitem and len slots for complex tuple enum pyclass derivation

* refactor code generation

* address PR concerns
- take py from function argument on get_item
- make more general slot def implementation
- remove unnecessary function arguments
- add testcases for uncovered cases including future feature match_args

* add tracking issue

* fmt

* ruff

* remove me

* support match_args for tuple enum

* integrate FnArg now takes Cow

* fix empty and single element tuples

* use impl_py_slot_def for cimplex tuple enum slots

* reverse erroneous doc change

* Address latest comments

* formatting suggestion

* fix :
- clippy beta
- better compile error (+related doc and test)

---------

Co-authored-by: Chris Arderne <chris@translucent.app>
2024-05-17 02:59:00 +00:00
Icxolu 21c02484d0
feature gate APIs using `into_gil_ref` (Part 2) (#4166) 2024-05-09 22:21:48 +00:00
Icxolu 7beb64a8ca
allow constructor customization of complex enum variants (#4158)
* allow `#[pyo3(signature = ...)]` on complex enum variants to specify constructor signature

* rename keyword to `constructor`

* review feedback

* add docs in guide

* add newsfragment
2024-05-09 21:08:23 +00:00
David Hewitt 22e8dd10e1
add benchmark for class / method calls (#4016) 2024-03-30 20:29:39 +00:00
Tim Felgentreff 9a38e709bb
Basic GraalPy Support (#3247)
* 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>
2024-03-25 18:54:52 +00:00
David Hewitt ec6d587218
support `Bound` for `classmethod` and `pass_module` (#3831)
* support `Bound` for `classmethod` and `pass_module`

* `from_ref_to_ptr` -> `ref_from_ptr`

* add detailed docs to `ref_from_ptr`
2024-02-16 00:36:11 +00:00
David Hewitt e308c8d3ac
ci: don't test gevent on pypy (#3830) 2024-02-13 00:14:55 +00:00
Mate Kovacs 3ed5ddb0ec feat: support pyclass on complex enums 2024-01-18 22:04:42 +09:00
David Hewitt 46fa1b2b80 add test which is broken with gevent 2023-12-23 22:07:48 +00:00
Adam Reichold 4177dfcc81 Apply __bool__ conversion only to numpy.bool_ to avoid false positives. 2023-12-19 18:55:28 +01:00
Adam Reichold 2fdd52003e Add PyType::full_name which is tp_name and has an abi3 fallback. 2023-12-19 15:47:21 +01:00
David Hewitt 3042ab1621 ci: switch from black to ruff 2023-10-26 21:04:49 +01:00
messense 5b94241bd7
Add `PyMemoryView` type 2023-10-15 17:32:09 +08:00
David Hewitt e1d4173827 Fix bug in default implementation of `__ne__` 2023-10-11 09:48:06 +01:00
David Hewitt 2daddb4734 unify 3.12 and pre-3.12 exception handling pathways 2023-09-30 23:27:27 +01:00
David Hewitt f335f42197
Merge pull request #3446 from davidhewitt/relax-import-check
relax multiple-import check to only prevent subinterpreters
2023-09-29 16:35:31 +00:00
David Hewitt 1a349c2eb7 adjust cfgs for windows 3.9 2023-09-29 14:23:18 +01:00
David Hewitt 1e8833e15e always normalize exceptions before raising 2023-09-24 13:38:23 +01:00
David Hewitt f17e703167 return existing module on Python 3.9 and up 2023-09-23 11:13:39 +01:00
David Hewitt 1338020511 relax multiple-import check to only prevent subinterpreters 2023-09-23 11:13:39 +01:00
Tpt 1e5a49557d Makes PathBuf FromPyObject implementation work on all os.PathLike
PyOS_FSPath is in abi3-py36
2023-08-08 22:15:56 +02:00
David Hewitt d395fe8653 ci: avoid failure to build numpy on 3.12 2023-07-22 21:38:57 +01:00
David Hewitt 4f3fcdbf0f remove all functionality deprecated in PyO3 0.18 2023-06-13 22:27:43 +01:00
David Hewitt 8850d5d384 support ordering magic methods for `#[pyclass]` 2023-06-04 13:58:18 +01:00
Stu Hood 20c5618160
Add support for combining the `#[new]` and `#[classmethod]` method types. 2023-05-16 15:51:14 -07:00
David Hewitt dd24c9ea71 remove `Python::acquire_gil` 2023-05-09 09:39:23 +02:00
David Hewitt 0362855773 make rust benchmarks more similar to the Python ones 2023-01-20 07:24:05 +00:00
David Hewitt 16d347d96a remove benchmarks from deprecated_pyfunctions 2023-01-20 07:19:13 +00:00
Alex Gaynor f7a487b809
Use a TypeError, rather than a ValueError, when refusing to treat a str as a Vec
This is far more consistent with how these exceptions are usually used
2022-11-07 07:48:13 -05:00
David Hewitt 8e8b484169
add `#[pyo3(signature = (...))]` attribute (#2702) 2022-10-25 07:23:21 +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 b2da5b20b1 Add a Python test exploring from which types a Vec can be extracted. 2022-09-21 09:47:05 +02:00
mejrs fc6121eafe Deprecate acquire_gil 2022-08-15 03:34:47 +02:00
David Hewitt 78ba70d2b4 pymodule: only allow initializing once per process 2022-08-09 19:52:25 +01:00
Ivan Tham a1f97f164d Add PyTzInfoAccess 2022-04-13 00:00:08 +08:00
Bruno Kolenbrander 16ad15e04f
Expand on xtask (#2176)
* Fix Windows OSError

* Ignore .pyd files

* Put things in modules

* Rename functions to `run`

* Expand on cargo xtask

* Try to work around missing installs

* Run all things by default, but not llvm-cov

* Test msrv

* Fix more OSErrors

* Various refinements and docs

* Various refinements

* Various refinements
2022-03-18 22:13:23 +00:00
David Hewitt 3ed0df1169 update black to 22.1.0 2022-02-14 07:42:06 +00:00
David Hewitt 8b47f4f120 pytests: merge benchmark and test crates 2022-02-05 10:16:46 +00:00