Commit Graph

6130 Commits

Author SHA1 Message Date
David Hewitt f04ad56df4
implement `PyTypeMethods` (#3705)
* implement `PyTypeMethods`

* introduce `PyType` bound constructors

* `from_type_ptr_bound` instead of `from_type_ptr_borrowed`

* correct conditional code

* just make `from_type_ptr_bound` create an owned `Bound`

* correct docstrings

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

* Rework as `PyType::from_borrowed_type_ptr`

* correct doc link to `from_borrowed_type_ptr`

Co-authored-by: Lily Foote <code@lilyf.org>

* remove unneeded lifetime name

---------

Co-authored-by: Icxolu <10486322+Icxolu@users.noreply.github.com>
Co-authored-by: Lily Foote <code@lilyf.org>
2024-02-18 03:07:48 +00:00
Icxolu 1d295a12a0
port `PyObject::downcast` to `Bound` API (#3856)
* port `PyObject::downcast` to `Bound` API

* relax traits bounds for unchecked variant in `Bound` API

* deprecate `Python::(checked_)cast_as`

* reword deprecation warning
2024-02-18 01:11:43 +00:00
Lily Foote 0dd568d397
Use the new bound API instead of .as_ref(py) (#3853)
* Use the new bound API instead of .as_ref(py)

* Move import into a nested scope

* Use to_cow instead of to_str for compatibility

`to_str` is not available before Python 3.10 on the limited api.

* Relax &self lifetimes

* Use Bound<'py, PyAny> in test Mapping signatures

* Use .as_bytes(py)

* Simplify ThrowCallback::throw signature

* Avoid .as_any call with Py api instead of Bound
2024-02-18 00:09:56 +00:00
Lily Foote 5f42c02e4f
Remove stray " character from docstring (#3852) 2024-02-17 17:04:35 +00:00
Icxolu c33d330b18
deprecate `PyFrozenSet::empty` (#3851) 2024-02-17 13:40:54 +00:00
Icxolu 1d8d81db2d
port `PyFrozenSetBuilder` to `Bound` API (#3850) 2024-02-17 12:21:41 +00:00
David Hewitt eb90b81d44
always use a Python iterator for sets and frozensets (#3849)
* always use a Python iterator for sets and frozensets

* add newsfragment
2024-02-17 10:57:53 +00:00
David Hewitt 65cf5808d9
docs: add note about mapping to dangling pointer with `Bound` API (#3805) 2024-02-17 10:35:28 +00:00
Lily Foote 940804fe0d
Pyerr value bound (#3820)
* Implement PyErr::value_bound

* Use PyErr::value_bound in conversions

* Implement PyErr::from_value_bound

* Remove unnecessary clone

* Return a reference from PyErr::value_bound

* Avoid clone in PyErr::from_value_bound

* Use PyErr::from_value_bound instead of from_value

* Remove unnecessary .as_borrowed() calls

* Remove unused import

* Simplify UnraisableCapture.hook

* Use Bound::from_owned_ptr_or_opt in fn cause

* Update PyErrState::lazy to take Py<PyAny>

This is easier to work with elsewhere than `&PyAny` or
`Bound<'py, PyAny>`.

* Add Bound PyUnicodeDecodeError constructors

* Update PyErr::from_value_bound to take Bound

* Simplify PyErr::from_value

* Simplify PyErr::value

* Remove unnecessary reference

* Simplify Pyerr::cause implementation

* Simplify PyUnicodeDecodeError::new_bound
2024-02-17 00:27:45 +00:00
alm c24478e8bc
docs: fix link in Contributing.md (#3845) 2024-02-16 16:53:25 +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
Icxolu 05aedc9032
port `PyErr::warn` to `Bound` API (#3842)
* port `PyErr::new_type`

* port `PyErr::warn` and `PyErr::warn_explicit`
2024-02-16 00:12:43 +00:00
David Hewitt dc8b948201
add `PyBackedStr` and `PyBackedBytes` (#3802)
* 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>
2024-02-15 07:58:20 +00:00
Icxolu f3ddd023c9
convert `PyBuffer` to `Bound` API (#3836) 2024-02-14 22:10:59 +00:00
Icxolu 9902633116
allow `from_py_with` on function args to take a `fn(&Bound) -> PyResult` (#3837) 2024-02-14 22:03:04 +00:00
Icxolu 0c12d9137f
port `Python::import` to `Bound` API (#3832)
* port `Python::import` to `Bound` API

* tidy up imports in tests/test_datetime_import.rs

---------

Co-authored-by: David Hewitt <mail@davidhewitt.dev>
2024-02-14 00:24:37 +00:00
Lily Foote a1e77c5a66
Document using as_borrowed in the Bound migration (#3833) 2024-02-13 23:30:16 +00:00
David Hewitt f5eafe23f2
add maximum Python version check (#3821)
* add maximum Python version check

* restore dependency of `pyo3-macros-backend` on `pyo3-build-config`

* fix clippy-all noxfile job
2024-02-13 21:52:53 +00:00
David Hewitt e308c8d3ac
ci: don't test gevent on pypy (#3830) 2024-02-13 00:14:55 +00:00
Icxolu fbfeb2ff03
update `#[derive(FromPyObject)]` to use `extract_bound` (#3828)
* update `#[derive(FromPyObject)]` to use `extract_bound`

* type inference for `from_py_with` using function pointers
2024-02-13 00:09:41 +00:00
David Hewitt 94b7d7e434
add `DowncastIntoError::into_inner` (#3829) 2024-02-12 21:40:05 +00:00
David Hewitt 5b9b76fe58
add `_bound` constructors for datetime types (#3778)
* add `_bound` constructors for datetime types

* review: Icxolu feedback

* update uses of deprecated timezone_utc
2024-02-12 20:49:58 +00:00
Lily Foote 1279467d27
Pyerr isinstance (#3826)
* Implement PyErr::is_instance_bound

* Update is_instance_bound to take a reference

Co-authored-by: David Hewitt <mail@davidhewitt.dev>

* Remove spurious clone

---------

Co-authored-by: David Hewitt <mail@davidhewitt.dev>
2024-02-12 08:32:51 +00:00
Icxolu c359f5ca1d
deprecate `PyDict::new` constructor (#3823)
* deprecate `PyDict::new`

* update benchmarks

* convert `test_frompyobject`
2024-02-11 23:55:56 +00:00
Kushal Das c983dc9773
Adds johnnycanencrypt project link (#3822) 2024-02-11 22:52:56 +00:00
Lily Foote baf5c8ec0a
Implement PyErr::get_type_bound (#3819)
* Implement PyErr::get_type_bound

* Update docs for PyErr::get_type_bound

* Fix doctest for cloning PyErr

* Import the whole prelude in docs example

Co-authored-by: David Hewitt <mail@davidhewitt.dev>

* Remove unnecessary self lifetime

Co-authored-by: David Hewitt <mail@davidhewitt.dev>

* Remove more unnecessary self lifetimes

* Use variables to avoid dangling pointers

Co-authored-by: David Hewitt <mail@davidhewitt.dev>

* Avoid using ffi in fn ptype on Py_3_12

Co-authored-by: David Hewitt <mail@davidhewitt.dev>

* Add missing imports to fn ptype

---------

Co-authored-by: David Hewitt <mail@davidhewitt.dev>
2024-02-11 21:07:28 +00:00
Jose c56cd3dd65
docs: clarify --pretty option to expand (#3810)
* Update debugging.md

Added clarification. --pretty no longer works, and it breaks even on nightly at least on cargo 1.78.0-nightly (cdf84b69d 2024-02-02) and
rustc 1.78.0-nightly (256b6fb19 2024-02-06).

* Update guide/src/debugging.md

Co-authored-by: David Hewitt <mail@davidhewitt.dev>

---------

Co-authored-by: David Hewitt <mail@davidhewitt.dev>
2024-02-11 20:52:49 +00:00
Jose f721c8c2b7
docs: fix link to README on building_and_distribution.md (#3809)
* Update building_and_distribution.md

Link to README not working.

* Update guide/src/building_and_distribution.md

Co-authored-by: David Hewitt <mail@davidhewitt.dev>

---------

Co-authored-by: David Hewitt <mail@davidhewitt.dev>
2024-02-11 20:52:14 +00:00
David Hewitt 55488d3880
Merge pull request #3818 from davidhewitt/datetime-segv
fix segmentation fault when `datetime` module is invalid
2024-02-11 09:04:32 +00:00
David Hewitt 5b1104131f fix segmentation fault when `datetime` module is invalid 2024-02-11 02:44:31 +00:00
David Hewitt 07ea89d460
Merge pull request #3817 from Icxolu/into-pydict
port `IntoPyDict` to `Bound` API
2024-02-11 02:26:03 +00:00
David Hewitt 6ee9c4ec5a
Merge pull request #3812 from Hamatti/docs-clarify-nox-installation
docs: Clarify the requirement to install nox before building documentation
2024-02-11 01:55:58 +00:00
Icxolu e45fbe493c port `IntoPyDict` to `Bound` API 2024-02-10 15:47:26 +01:00
Juha-Matti Santala 559761b2f1 docs: Clarify the requirement to install nox
Installing nox was mentioned in a later section when building
the user guide but not at this point earlier in the guide where
nox was needed for the first time.
2024-02-10 16:20:37 +02:00
David Hewitt fa53d81e5f
Merge pull request #3801 from davidhewitt/encode-utf8
add `PyStringMethods::encode_utf8`
2024-02-10 14:16:32 +00:00
David Hewitt 45f2b0aba5
Merge pull request #3816 from Icxolu/python-run
port `Python::run` to `Bound` API
2024-02-09 21:42:51 +00:00
Icxolu 4d423b0c67 port `Python::run` to `Bound` API 2024-02-09 22:09:16 +01:00
David Hewitt b7fb9e672e
Merge pull request #3782 from davidhewitt/type-check-bound
add `bound` method variants for `PyTypeInfo`
2024-02-09 20:22:44 +00:00
David Hewitt 2fedea24b3
Merge pull request #3806 from Icxolu/python-eval
port `Python::eval` to `Bound` API
2024-02-09 17:18:57 +00:00
Icxolu 33dc33ecec port `Python::eval` to `Bound` API 2024-02-09 17:52:00 +01:00
David Hewitt 367eeaeeab add `bound` method variants for `PyTypeInfo` 2024-02-08 22:27:05 +00:00
David Hewitt 9bb001108b
Merge pull request #3813 from davidhewitt/nightly-2024-02-08
ci: allow some dead code warnings on nightly
2024-02-08 21:32:57 +00:00
David Hewitt bcb7b88c23 ci: updates for rust 1.76 2024-02-08 21:13:58 +00:00
David Hewitt 3541506a16 ci: allow some dead code warnings on nightly 2024-02-08 20:52:03 +00:00
David Hewitt 030a618e0d
Merge pull request #3800 from snuderl/PyCFunction-bound-api
PyCFunction bound api
2024-02-06 18:28:40 +00:00
Blaž Šnuderl aa3c938b5e PyCFunction bound api 2024-02-06 18:44:53 +01:00
David Hewitt 059e485a95
Merge pull request #3560 from Jgfrausing/patch-1
docs: Include section on how to disable signals in python
2024-02-06 09:01:17 +00:00
Jonatan G. Frausing b74d733244 docs: include section that disables signal in python 2024-02-06 08:33:44 +00:00
David Hewitt f7bfa9ab11
Merge pull request #3804 from davidhewitt/chrono-conversions
docs: add `chrono` conversions to types table
2024-02-06 08:12:53 +00:00
David Hewitt dd4df29bad docs: add `chrono` conversions to types table 2024-02-05 21:50:25 +00:00