Commit Graph

2523 Commits

Author SHA1 Message Date
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
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
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
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
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
Icxolu e45fbe493c port `IntoPyDict` to `Bound` API 2024-02-10 15:47:26 +01:00
David Hewitt fa53d81e5f
Merge pull request #3801 from davidhewitt/encode-utf8
add `PyStringMethods::encode_utf8`
2024-02-10 14:16:32 +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
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 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 86f294f6e6 expose `Bound::from_owned_ptr` etc 2024-02-05 18:27:43 +00:00
David Hewitt 662eecfb44 add `PyStringMethods::encode_utf8` 2024-02-05 13:28:46 +00:00
David Hewitt 02f1df69b5
Merge pull request #3792 from davidhewitt/bound-pyclass-2
pyclass methods for `Bound`
2024-02-05 10:38:30 +00:00
Adam Reichold c995426c81
Merge pull request #3799 from davidhewitt/move-cow
move `Cow[u8]` conversions into `conversions::std::slice` module
2024-02-05 10:18:33 +00:00
David Hewitt 42843de47b pyclass methods for `Bound` 2024-02-05 09:41:22 +00:00
David Hewitt 7281268840 move `Cow[u8]` conversions into `conversions::std::slice` module 2024-02-05 08:52:07 +00:00
Bruno Kolenbrander 7938d4cadc
Merge pull request #3798 from davidhewitt/beta-map-clone
ci: fix beta clippy `map_clone` warning
2024-02-05 08:48:14 +00:00
David Hewitt de93d15eeb ci: fix beta clippy `map_clone` warning 2024-02-05 07:57:27 +00:00
Blaž Šnuderl f1384f3582 Implement PyNone.get() using PyNone.get_bound() 2024-02-05 08:06:59 +01:00
Blaž Šnuderl 1fd0aa2b19 Use new method to implement old 2024-02-05 08:03:25 +01:00
Blaz Snuderl 8388b14369 PyNotImplemented get_bound 2024-02-04 20:08:52 +01:00
Blaz Snuderl 8354590ae6 PyEllipsis get_bound method 2024-02-04 20:01:15 +01:00
David Hewitt 5dbb51b9ce
Merge pull request #3784 from davidhewitt/more-extract-bound
migrate many `FromPyObject` implementations to `Bound` API
2024-02-04 15:58:22 +00:00
Icxolu 304c8e655a convert `marshal` to `Bound` API 2024-02-04 16:25:00 +01:00
David Hewitt 0d4df9c19d adjust `FromPyObject` implementations to always use `'py` lifetime 2024-02-04 14:22:03 +00:00
David Hewitt 2a741a21e6 migrate many `FromPyObject` implementations to `Bound` API 2024-02-04 14:22:03 +00:00
Blaž Šnuderl d1e967e9ea Uncomment a test 2024-02-04 07:31:29 +01:00
Blaž Šnuderl eca943ea35 Add new get_bound and mark old get as deprecated 2024-02-04 07:30:28 +01:00
Blaž Šnuderl 7efd412a63 Merge branch 'main' into PyNone-new-api 2024-02-04 07:29:32 +01:00
David Hewitt 76d1b34cd5 Revert "Merge pull request #3578 from davidhewitt/typed-helpers"
This reverts commit 7b07d6d21b, reversing
changes made to 99858236bd.
2024-02-03 20:56:23 +00:00
Blaz Snuderl b1863c73df clippy 2024-02-03 21:25:47 +01:00
Blaz Snuderl 507ea28b27 test 2024-02-03 21:14:31 +01:00
Blaž Šnuderl 9641b11752 hmm 2024-02-03 20:57:46 +01:00
Blaž Šnuderl a2a6062adc fmt 2024-02-03 20:48:25 +01:00
Blaž Šnuderl 5e9d97d1c6 Implement new API for PyNone #3684 2024-02-03 19:09:12 +01:00