Commit graph

2686 commits

Author SHA1 Message Date
Alex Gaynor 93cfb51ebb
feature gate deprecated APIs for PyMemoryView (#4152) 2024-05-03 16:02:19 +00:00
Icxolu cd3f3ed67c
ci: updates for Rust 1.78 (#4150)
* ci: updates for Rust 1.78

* ci: fix clippy

* restrict `invalid_pymethods_duplicates` to unlimited api with `full`
2024-05-03 07:42:30 +00:00
Icxolu a454f6e9cc
feature gate deprecated APIs for PyFloat and PyComplex (#4145) 2024-05-01 17:13:49 +00:00
Alex Gaynor 5534a7bee8
feature gate deprecated APIs for PyBuffer (#4144) 2024-05-01 12:18:12 +00:00
Icxolu dc9a41521a
feature gate deprecated APIs for Py (#4142) 2024-05-01 10:57:03 +00:00
Alex Gaynor 261d27d197
feature gate deprecated APIs for PySlice (#4141) 2024-04-30 23:55:43 +00:00
Icxolu 2f3a33fda1
feature gate deprecated APIs for PyList (#4127) 2024-04-30 22:00:31 +00:00
Icxolu 82c00a2fe4
port PyAny tests to Bound API (#4140) 2024-04-30 21:49:00 +00:00
Icxolu 4616838ee1
port PySequence tests to Bound API (#4139) 2024-04-30 18:53:40 +00:00
Icxolu 22c5cff039
feature gate deprecated APIs for PyErr and exceptions (#4136) 2024-04-30 16:58:53 +00:00
Icxolu d5452bcd8d
feature gate deprecated APIs for PyType, PyTypeInfo and PySuper (#4134) 2024-04-28 21:03:51 +00:00
Alex Gaynor 9e1960ea34
Update MSRV to 1.63 (#4129)
* Bump MSRV to 1.63

* Drop parking_lot in favor of std::sync

* Make portable-atomic dep conditional

* Remove no longer required cfg
2024-04-28 16:11:28 +00:00
Icxolu 6fb972b232
feature gate deprecated APIs for PyEllipsis, PyNone and PyNotImplemented (#4132) 2024-04-27 15:34:13 +00:00
Icxolu 059c8b3862
feature gate deprecated APIs for PyBytes and PyPyByteArray (#4131) 2024-04-27 11:34:27 +00:00
David Matos c66ed292ec
Disable PyUnicode_DATA on PyPy (#4116)
* Disable PYUNICODE_DATA on PyPy

* Add newsfragment

* Adjust import on PyString
2024-04-26 06:00:13 +00:00
Icxolu 8734b76f60
feature gate deprecated APIs for PyIterator (#4119) 2024-04-25 17:44:42 +00:00
Icxolu 6c2e6f8bcc
feature gate deprecated APIs for PyFrozenSet (#4118) 2024-04-24 21:13:27 +00:00
Icxolu c951bf86de
feature gate deprecated APIs for PyCapsule (#4112) 2024-04-24 17:34:19 +00:00
Icxolu 013a4476ea
feature gate deprecated APIs for datetime types (#4111) 2024-04-24 17:33:53 +00:00
Icxolu 5d2f5b5702
feature gate deprecated APIs for PyDict (#4108) 2024-04-23 05:48:27 +00:00
Icxolu da2d1aa8b4
feature gate deprecated APIs for PyString (#4101) 2024-04-22 07:20:32 +00:00
Icxolu b0ad1e10aa
feature gate deprecated APIs for PyTuple (#4107) 2024-04-22 07:19:01 +00:00
David Hewitt 947b372dcc
change PyAnyMethods::dir to be fallible (#4100) 2024-04-19 19:35:52 +00:00
David Hewitt cd28e1408e
add #[track_caller] to all Py/Bound/Borrowed methods which panic (#4098) 2024-04-19 11:44:36 +00:00
Icxolu d42c00d21d
feature gate deprecated APIs for PySet (#4096) 2024-04-19 07:24:26 +00:00
Jacob Zhong 03c50a1839
Change the types of PySliceIndices and `PySlice::indices (#3761)
* Change the type of `PySliceIndices::slicelength` and `PySlice::indices()`

* Fix example

* Fix fmt
2024-04-18 07:33:07 +00:00
Icxolu 03f59eaf45
fix declarative module compile error with create_exception! (#4086)
* fix declarative module compile error with `create_exception!`

* add newsfragment
2024-04-16 20:12:18 +00:00
David Hewitt a5201c04af
Deprecate the PySet::empty gil-ref constructor (#4082)
* Deprecate the `PySet::empty` gil-ref constructor

* add newsfragment
2024-04-14 21:38:40 +00:00
David Matos 8ed5c17b93
Allow use of scientific notation on rust decimal (#4079)
* Allow use of scientific notation on rust decimal

* Add newsfragment

* Pull out var

* Fix clippy warning

* Modify let bindings location
2024-04-14 20:07:17 +00:00
Adam Reichold 721100a9e9
Suppress non_local_definitions lint as we often want the non-local effects in macro code (#4074)
* Resolve references to legacy numerical constants and use the associated constants instead

* Suppress non_local_definitions lint as we often want the non-local effects in macro code
2024-04-13 12:59:44 +00:00
Joseph Perez 2f0869a6d6
fix: allow impl of Ungil for deprecated PyCell in nightly (#4053) 2024-04-06 22:36:52 +00:00
Icxolu 8f87b8636d
refactor #[setter] argument extraction (#4002) 2024-04-01 12:10:18 +00:00
Icxolu 63ba371db0
added various std traits for PyBackedStr and PyBackedBytes (#4020)
* added various std traits for `PyBackedStr` and `PyBackedBytes`

* add newsfragment

* add tests
2024-04-01 07:10:40 +00:00
David Hewitt 336b1c982b
add import_exception_bound! macro (#4027)
* add `import_exception_bound!` macro

* newsfragment and tidy up
2024-03-31 19:55:31 +00:00
David Hewitt 9d932c1061
add #[inline] hints on many Bound and Borrowed methods (#4024) 2024-03-30 22:10:21 +00:00
David Hewitt c6f25e42a2
ci: relax check in pyobject_drop test (#4014) 2024-03-29 15:51:38 +00:00
Alex Gaynor ae3ac7d872
Fixed error string when failing to import an exception (#4012) 2024-03-29 15:49:50 +00:00
David Hewitt cf74624de9
refactor to remove add_to_module functions from generated code (#4009)
* refactor to remove add_to_module functions from generated code

* mrsv, newsfragment

* clippy
2024-03-29 11:54:33 +00:00
David Hewitt b053e83c08
implement Send and Sync for PyBackedStr and PyBackedBytes (#4007) 2024-03-29 11:28:42 +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
Icxolu 54ffaecd65
add AsRef impls for PyBackedStr and PyBackedBytes (#3991)
* add `AsRef` impls for `PyBackedStr` and `PyBackedBytes`

* add newsfragment
2024-03-25 16:21:27 +00:00
Lily Foote 009cd32a44
Add into_mapping and into_sequence methods to Bound types (#3982)
* Add Bound<'py, PyDict>.into_mapping method

* Add Bound<'py, PyTuple>.into_sequence method

* Add Bound<'py, PyList>.into_sequence method

* Add newsfragment

* Add tests for into_mapping and into_sequence
2024-03-23 01:13:24 +00:00
David Hewitt 20e477a7cd
avoid reference count cycle in tuple extraction (#3976) 2024-03-22 22:43:05 +00:00
David Hewitt 351c6a0a49
deprecate optional GIL Ref in function argument (#3975) 2024-03-21 07:24:40 +00:00
David Hewitt 870a4bb20d
deprecate GIL refs in function argument (#3847)
* deprecate GIL Refs in function arguments

* fix deprecated gil refs in function arguments

* add notes on deprecations limitations to migration guide

* Apply suggestions from code review

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

* review: Icxolu

* fix proto method extract failure for option

* fix gil refs in examples

---------

Co-authored-by: Icxolu <10486322+Icxolu@users.noreply.github.com>
2024-03-20 22:35:08 +00:00
David Hewitt cedac43dbb
add Bound::as_unbound (#3973)
* add Bound::as_unbound

* Update src/instance.rs
2024-03-20 12:52:09 +00:00
David Hewitt caf80eca66
handle clippy new_without_default warnings (#3971)
* handle clippy `new_without_default` warnings

* add newsfragment
2024-03-19 21:41:27 +00:00
David Hewitt 02e188e4b4
adjust path for GIL Refs deprecation warnings (#3968) 2024-03-19 21:08:20 +00:00
David Hewitt cbed7c11b6
ci: tidy ups for 3.7 (#3969) 2024-03-19 19:36:22 +00:00
Icxolu b06e95727b
deprecate gil-refs in from_py_with (#3967)
* deprecate gil-refs in `from_py_with`

* review feedback davidhewitt
2024-03-19 08:58:41 +00:00
Icxolu da24f0cf93
exposes Borrowed::to_owned as public API (#3963)
* exposes `Borrowed::to_owned` as public API

* add newsfragment
2024-03-17 09:17:09 +00:00
David Hewitt dcba984b51
deprecate GILPool (#3947)
* deprecate `GILPool`

* review: adamreichold

* fix deprecation warnings in tests
2024-03-15 10:25:27 +00:00
Icxolu 5c86dc35c1
allow borrowed extracts with gil-refs disabled (#3959) 2024-03-15 07:53:52 +00:00
Bruno Kolenbrander 989d2c53ab
Fix non_local_definitions lint triggers (#3955) 2024-03-12 22:59:33 +00:00
Icxolu ee89b2e8e2
deprecate wrap_pyfunction with py argument (#3954)
* deprecate `wrap_pyfunction` with `py` argument

The Python token in `wrap_pyfunction` is not handled automatically by
`WrapPyFunctionArg`, for backwards compatibility. This uses deref
specialization to deprecate this variant.

* merge `Extractor`s

* add deprecation ui test, revert closure variant due to test failure

* fix nightly
2024-03-12 22:57:03 +00:00
Georg Brandl a7fa1bdf22
fix: remove "track_caller" cfg check (#3951)
This "cfg" value does not seem to exist (any more?), and #[track_caller]
is used a lot elsewhere without cfg_attr.

Found using cargo check -Zcheck-cfg.
2024-03-11 12:40:26 +00:00
David Hewitt 9145fcfe19
docs: major rewrite for Bound API (#3906)
* wip bound docs

* Update guide/src/python_from_rust/calling-existing-code.md

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

* continue to move and tidy up

* Apply suggestions from code review

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

* update URL

* complete python-from-rust.md

* progress on types.md; probably more to go

* update doctest paths

* review: Icxolu

* finish updating `types.md` to Bound API

* update remainder of the guide to Bound API

* Update guide/src/performance.md

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

* Update guide/src/types.md

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

* Update src/lib.rs

* review: Icxolu

* Update guide/src/python-from-rust.md

Co-authored-by: Adam Reichold <adamreichold@users.noreply.github.com>

* Update guide/src/async-await.md

Co-authored-by: Adam Reichold <adamreichold@users.noreply.github.com>

* review: adamreichold

---------

Co-authored-by: Lily Foote <code@lilyf.org>
Co-authored-by: Icxolu <10486322+Icxolu@users.noreply.github.com>
Co-authored-by: Adam Reichold <adamreichold@users.noreply.github.com>
2024-03-10 15:51:51 +00:00
David Hewitt 75af678f43
docs: use kebab-case instead of snake_case for guide URLs (#3942)
* guide: use kebab-case instead of snake_case

* fixup doctest names

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

* review: Icxolu

* fix relative url

* also remap latest pyo3

* fixup python_from_rust

---------

Co-authored-by: Icxolu <10486322+Icxolu@users.noreply.github.com>
2024-03-09 20:10:58 +00:00
David Hewitt 14d1d2a9ee
docs: use lychee to check link URLs (#3941)
* guide: install `mdbook-linkcheck`

* use `shutil` to copy license files

* move from `mdbook-linkcheck` to `lychee`

* clean guide & doc build products before build

* fix more broken links

* review: mejrs
2024-03-08 14:10:47 +00:00
David Hewitt 770d9b7f01
add FromPyObjectBound trait for extracting &str without GIL Refs (#3928)
* add `FromPyObjectBound` adjustment for `&str` without GIL Refs

* review: alex, Icxolu feedback

* add newsfragment

* add newsfragment for `FromPyObject` trait change

* make some examples compatible with abi3 < 3.10

* seal `FromPyObjectBound`

* fixup chrono_tz conversion
2024-03-08 07:43:48 +00:00
Icxolu 31c4820010
deprecate &PyModule as #[pymodule] argument type (#3936)
* deprecate `&PyModule` as `#[pymodule]` argument type

* cleanup

* add ui tests

* fix deprecations in tests

* fix maturin and setuptools-rust starters

* run `deprecated` ui test only when `gil-refs` as disabled
2024-03-08 00:28:11 +00:00
Thomas Tanon fbd531195a
PyAddToModule: Properly propagate initialization error (#3919)
Better than panics
2024-03-06 18:20:02 +00:00
Thomas Tanon 0f7ddb19a5
PyPy: remove PyCode (PyCode_Type does not exist) (#3934) 2024-03-06 18:19:43 +00:00
Thomas Tanon d35f41e0bf
Chrono: allow deprecation warning until upgrading to 0.4.35+ (#3935)
* Chrono: allow deprecation warning until upgrading to 0.4.35+

Requiring 0.4.35 is blocked on MSRV (Chrono: 1.61, PyO3: 1.56)

* also allow deprecated chrono in example

---------

Co-authored-by: David Hewitt <mail@davidhewitt.dev>
2024-03-06 17:49:43 +00:00
David Hewitt 57bbc32e7c
add experimental-async feature (#3931)
* add `experimental-async` feature

* gate async doctests on feature
2024-03-06 00:54:45 +00:00
David Hewitt b08ee4b7e1
remove gil-refs feature from full feature (#3930) 2024-03-04 22:23:35 +00:00
Lily Foote 811a3e5d00
Add IntoIterator for &Bound types (#3923)
* Add IntoIterator for &Bound<'py, PyList>

* Add a test for Bound<'_, PyList>.into_iter

* Implement IntoIterator for more &Bound types

* Remove some explicit .iter() calls

* Implement IntoIterator for &Bound<'py, PyIterator>
2024-03-04 21:24:38 +00:00
Icxolu 70a7aa808d
deprecate the use of PyCell in favor of Bound and Py (#3916)
* deprecate the use of `PyCell` in favor of `Bound` and `Py`

* update `FromPyObject` for `T: PyClass + Clone` impl

* move `PyCell` deprecation to the `gil-refs` feature gate and add a migration note
2024-03-03 14:47:25 +00:00
David Hewitt 2e56f659ed
split PyCell and PyClassObject concepts (#3917)
* add test for refguard ref counting

* split `PyCell` and `PyClassObject` concepts

* rework `create_cell` to `create_class_object`

* Apply suggestions from code review

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

* review: Icxolu feedback

---------

Co-authored-by: Icxolu <10486322+Icxolu@users.noreply.github.com>
2024-03-03 07:00:59 +00:00
Lily Foote d94827720e
Delete duplicate test code (#3926)
These used to explicitly call `.iter()`, but that was removed in b65cbb9
to remove lints.
2024-03-02 22:53:28 +00:00
Icxolu 1c5265e1c2
deprecate from_borrowed_ptr methods (#3915)
* deprecate `from_borrowed_ptr` methods

This deprecates the methods on the `Python`
marker, aswell as `FromPyPointer`

* use `BoundRef` to defer ref cnt inc until after the error case
2024-03-01 20:51:53 +00:00
Icxolu 1d224610c3
docs: update Python classes section of the guide (#3914)
* docs: update `Python classes` section of the guide

* review feedback davidhewitt

* migration guide entry
2024-03-01 09:21:47 +00:00
Lily Foote 56683ed553
deprecate Py::as_ref (#3864)
* Deprecate Py::as_ref

* Reword as_ref deprecation note

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

* Tidy up remaining uses of Py::as_ref

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

* Pass hello into println! explicitly

---------

Co-authored-by: David Hewitt <mail@davidhewitt.dev>
2024-02-29 07:15:34 +00:00
Matthew Neeley 68ec6de0c9
Use single-arg form of #[pymodule] function in docs and tests (#3899)
* Use single-arg form for `#[pymodule]` functions in docs and tests

* Update guide/src/function.md

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

* Add test of two-argument module function

* Fix new test

---------

Co-authored-by: Icxolu <10486322+Icxolu@users.noreply.github.com>
2024-02-28 22:36:50 +00:00
Icxolu 55833365b5
seals PyAnyMethods and friends (#3909)
* seals `PyAnyMethods` and friends

This seals these new traits, preventing downstream
crates from implementing them on their types.
These traits are mainly a workaround for arbitrary
self receiver types, so this gives us more
flexibility if these need to be changed in the
future.

* move `PyResultExt` seal
2024-02-28 19:36:55 +00:00
David Hewitt 8a12970c96
update extract_argument to use Bound APIs (#3708)
* update `extract_argument` to use `Bound` APIs

* tidy up borrow in macros expression

* update `trybuild` output

* more concise form for `DowncastError::new`

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

* use `Borrowed` instead of newtype

* use `Borrowed::from_ptr` methods in extract_argument

* update UI tests

* avoid double-negative `#[cfg]` clauses

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

* review: LilyFoote, Icxolu feedback

---------

Co-authored-by: Lily Foote <code@lilyf.org>
2024-02-28 19:36:20 +00:00
Matthew Neeley a15e4b1a11
Allow pymodule functions to take a single Bound<'_, PyModule> arg (#3905) 2024-02-27 22:24:14 +00:00
Icxolu 6f03a5464f
cleans up PyCFunction::internal_new (#3910)
This deduplicates some code around `PyCFunction::internal_new`
2024-02-27 22:15:35 +00:00
Lily Foote a3ad28b70c
Pymodule bound (#3897)
* Support Bound in pymodule and pyfunction macros

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

* Remove spurious $ character

Co-authored-by: Matthew Neeley <mneeley@gmail.com>

* Rework PyCFunction::new_bound signatures

This allows us to remove the awkward `PyFunctionArgumentsBound` enum.

* Use BoundRef instead of BoundModule

* support argument deduction for `wrap_pyfunction_bound!`

* support `wrap_pyfunction!` with `Bound` input/output

* Fix docs link to `wrap_pyfunction_bound!`

* Revert back to wrap_pyfunction!

---------

Co-authored-by: David Hewitt <mail@davidhewitt.dev>
Co-authored-by: Matthew Neeley <mneeley@gmail.com>
2024-02-27 19:19:52 +00:00
David Hewitt 93704047a5
store Bound<T> inside PyRef and PyRefMut (#3860)
* store `Bound<T>` inside `PyRef` and `PyRefMut`

* update `FromPyObject` for `PyRef` to use `extract_bound`

* review: Icxolu feedback
2024-02-27 18:56:22 +00:00
Lily Foote 5c41ea0ade
Implement From<Bound<'py, T>> for PyErr (#3881)
* Implement `From<Bound<'py, T>>` for PyErr

* Replace PyErr::from_value_bound calls with .into

* Fix From<MyError> expected error message

* Add a trait bound to From<Bound<'py, T>> for PyErr
2024-02-26 23:14:41 +00:00
David Hewitt 8e2219b0d9
silence non-local-definitions nightly lint (#3901)
* silence non-local-definitions nightly lint

* add newsfragment

* add FIXMEs for `non_local_definitions`

* also allow `non_local_definitions` in doctests
2024-02-26 20:28:04 +00:00
Icxolu 7c10ff4327
allow Bound<'_, T> in #[pymethods] self position (#3896)
* allow `Bound<'_, T>` in #[pymethods] `self` position

* rename `TryFromPyCell` -> `TryFromBoundRef`

* remove unneccessary unsafe
2024-02-25 07:13:36 +00:00
Thomas Tanon e0e3981e17
#[pymodule] mod some_module { ... } v3 (#3815)
* #[pymodule] mod some_module { ... } v3

Based on #2367 and #3294

Allows to export classes, native classes, functions and submodules and provide an init function

See test/test_module.rs for an example

Future work:
- update examples, README and guide
- investigate having #[pyclass] and #[pyfunction] directly in the #[pymodule]

Co-authored-by: David Hewitt <mail@davidhewitt.dev>
Co-authored-by: Georg Brandl <georg@python.org>

* tests: group exported imports

* Consolidate pymodule macro code to avoid duplicates

* Makes pymodule_init take Bound<'_, PyModule>

* Renames #[pyo3] to #[pymodule_export]

* Gates #[pymodule] mod behind the experimental-declarative-modules feature

* Properly fails on functions inside of declarative modules

---------

Co-authored-by: David Hewitt <mail@davidhewitt.dev>
Co-authored-by: Georg Brandl <georg@python.org>
2024-02-24 13:50:18 +00:00
Icxolu c06bb8f1f1
reexport PyAnyMethods and friends from pyo3::types (#3895)
* reexport `PyAnyMethods` and friends from `pyo3::types`

* remove duplicated imports
2024-02-24 13:46:59 +00:00
David Matos 0f29feca8f
Tidy up deprecation message on bound api (#3893) 2024-02-24 13:25:06 +00:00
Lily Foote e145ae851a
Update new_closure_bound closure signature (#3883)
* Update new_closure_bound closure signature

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

* Use anonymous lifetimes in closure bounds

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

* Take &Bound in PyCFunction closures

---------

Co-authored-by: Icxolu <10486322+Icxolu@users.noreply.github.com>
Co-authored-by: David Hewitt <mail@davidhewitt.dev>
2024-02-23 14:07:54 +00:00
Icxolu 6a815875a0
port PyErr::from_type to Bound API (#3885) 2024-02-23 06:31:51 +00:00
David Hewitt 5ca810236d
ci: rework GitHub caching strategy (#3886)
* ci: rework GitHub caching strategy

* clean up some more redundant imports flagged by nightly
2024-02-23 00:51:50 +00:00
Lily Foote 22a23ffb31
Tidy some usage of py.from_borrowed_ptr and py.from_borrowed_ptr_or_opt (#3877)
* Tidy some usage of py.from_borrowed_ptr

* Add BoundRef::ref_from_ptr_or_opt
2024-02-22 23:06:55 +00:00
Icxolu 8bd82da939
add missing deprecation for PyDict::from_sequence (#3884) 2024-02-22 22:52:25 +00:00
Icxolu 4f8ee96881
fix AsRef and Deref impls on Bound<T> (#3879)
* fix `AsRef` and `Deref` of `Bound<T>` to `Bound<PyAny>`

* cleanup unnessesary `.as_any()` calls

* remove trait bound on `AsRef` impl

* add comment for `Deref` trait bound

* rename marker trait
2024-02-22 22:38:42 +00:00
David Hewitt 9e74c858c2
add PyModule::new_bound and PyModule::import_bound (#3775)
* add `PyModule::new` and `PyModule::import_bound`

* review: Icxolu feedback
2024-02-22 09:35:47 +00:00
David Hewitt c4f66657c5
fix either feature conditional compilation, again (#3834)
* fix `either` feature conditional compilation, again

* test feature powerset in CI

* install `rust-src` for feature powerset tests

* review: adamreichold feedback

* Fix one more case of redundant imports.

* just check feature powerset for now

---------

Co-authored-by: Adam Reichold <adam.reichold@t-online.de>
2024-02-22 08:05:37 +00:00
Lily Foote 5ddcd46980
Deprecate py.from_owned_ptr methods (#3875)
* Deprecate `py.from_owned_ptr` methods

* Refactor PyString.to_str

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

---------

Co-authored-by: David Hewitt <mail@davidhewitt.dev>
2024-02-22 00:05:08 +00:00
Juniper Tyree 885883bf68
Add Py::drop_ref method (#3871)
* add Py::drop_ref method

* add changelog entry

* fix ffi import

* integrate review feedback

* Add a test

* Fix some build errors

* Fix some more build errors
2024-02-21 22:56:03 +00:00
Icxolu 61bc02d927
deprecate PyCell::new in favor of Py::new or Bound::new (#3872)
* deprecate `PyCell::new` in favor of `Py::new` or `Bound::new`

* update deprecation warning

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

---------

Co-authored-by: David Hewitt <mail@davidhewitt.dev>
2024-02-20 07:45:47 +00:00
Lily Foote a93900686e
Deprecate Py::into_ref (#3867)
* Migrate into_ref calls to Bound api

* Mark Py::into_ref as deprecated
2024-02-20 07:10:45 +00:00
David Hewitt 8ac7834f98
docs: update example for storing Py<T> in structs (#3876) 2024-02-20 07:08:49 +00:00
Lily Foote 76dabd4e60
Replace as_ref(py) with Bound APIs (#3863) 2024-02-19 22:39:54 +00:00