Commit Graph

6262 Commits

Author SHA1 Message Date
Paul Stemmet 1a65112ba7
src/impl_: add ff unsafe-allow-subinterpreters
Allow the subinterpreter safeguards to be disabled, so that applications
like Ceph's manager can continue to use pyo3 modules without soft
crashing.

Enabling this feature should be done with caution, as any storage of Py
objects in rust statics can lead to undefined behavior.

However, not all consumers of pyo3 use global state, and thus a subset
of them (such as python-bcrypt) are safe to use in subinterpreter
contexts.

References: https://github.com/bazaah/aur-ceph/issues/20
References: https://github.com/PyO3/pyo3/pull/2523
References: https://github.com/pyca/cryptography/issues/9016
References: https://github.com/PyO3/pyo3/discussions/2346#discussioncomment-3246505
References: https://github.com/PyO3/pyo3/discussions/2346#discussioncomment-2911159
References: https://github.com/PyO3/pyo3/issues/3451
Signed-off-by: Paul Stemmet <github@luxolus.com>
2024-07-12 10:32:10 +00:00
David Hewitt a646a820fd release: 0.21.2 2024-04-16 08:57:37 +01:00
David Hewitt bd15f92a56 Deprecate the `PySet::empty` gil-ref constructor (#4082)
* Deprecate the `PySet::empty` gil-ref constructor

* add newsfragment
2024-04-16 08:57:37 +01:00
Adam Reichold 4f7c7065c2 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-16 08:57:37 +01:00
Adam Reichold 3f6faf00ff Extend guide on interaction between method receivers and lifetime elision. (#4069) 2024-04-16 08:57:37 +01:00
messense 4e13c0eae8 Link libpython for AIX target (#4073) 2024-04-16 08:57:37 +01:00
Icxolu e501377587 fix declarative-modules compile error (#4054)
* fix declarative-modules compile error

* add newsfragment
2024-04-16 08:57:37 +01:00
Icxolu fd18955da8 add `#[doc(hidden)]` to the Rust module created by `#[pymodule]` (#4067)
* add `#[doc(hidden)]` to the Rust module created by `#[pymodule]`

* add newsfragment
2024-04-16 08:57:37 +01:00
Liam e174a04bb3 Minor: Fix a typo in Contributing.md (#4066) 2024-04-16 08:57:37 +01:00
dependabot[bot] a8abe508ba build(deps): bump peaceiris/actions-gh-pages from 3 to 4 (#4062)
Bumps [peaceiris/actions-gh-pages](https://github.com/peaceiris/actions-gh-pages) from 3 to 4.
- [Release notes](https://github.com/peaceiris/actions-gh-pages/releases)
- [Changelog](https://github.com/peaceiris/actions-gh-pages/blob/main/CHANGELOG.md)
- [Commits](https://github.com/peaceiris/actions-gh-pages/compare/v3...v4)

---
updated-dependencies:
- dependency-name: peaceiris/actions-gh-pages
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-04-16 08:57:37 +01:00
Jeong, Heon 68d19738e7 Fix typo (#4052)
Fix incorrect closing brackets
2024-04-16 08:57:37 +01:00
Joseph Perez b8ec43e469 fix: allow impl of Ungil for deprecated PyCell in nightly (#4053) 2024-04-16 08:57:37 +01:00
Icxolu 0b888cb934 add descriptive error msg for `__traverse__` receivers other than `&self` (#4045)
* add descriptive error msg for `__traverse__` receivers other than `self`

* add newsfragment

* improve error message
2024-04-16 08:57:37 +01:00
David Hewitt e4cc98607e fix compile error for multiple async method arguments (#4035) 2024-04-16 08:57:37 +01:00
David Hewitt c1f11fb4bd
release: 0.21.1 (#4032) 2024-04-01 18:51:58 +00:00
David Hewitt 8cabd2619c
docs: updates to guide for PyO3 0.21 feedback (#4031)
* docs: add notes on smart pointer conversions

* guide: add more notes on `.extract::<&str>()` to migration guide
2024-04-01 15:18:57 +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
Weijie Guo 3af9a1f4e0
docs: fix example in types.md (#4028) 2024-03-31 08:03:38 +00:00
David Hewitt cff4aa3cc8
ci: defer test-debug to the merge queue (#4023) 2024-03-30 23:26:34 +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 22e8dd10e1
add benchmark for class / method calls (#4016) 2024-03-30 20:29:39 +00:00
Weijie Guo 74d9d23ba0
async method should allow args not only receiver (#4015)
* async method should allow args not only receiver

* add changelog md
2024-03-30 08:48:19 +00:00
Rikus Honey 4d033c4497
Fix broken hyperlink to types.md (#4018) 2024-03-30 07:39:00 +00:00
geo7 0e093a5911
Update getting-started.md (#4004)
Missing word
2024-03-29 22:45:47 +00:00
Alex Gaynor de03ca270a
Remove dead code in macros backend (#4011) 2024-03-29 21:28:08 +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
Alex Gaynor 60e3f44dcf
Ensure all arguments to _run are strings (#4013)
Otherwise you get errors like https://github.com/PyO3/pyo3/actions/runs/8480723060/job/23236947935?pr=4012
2024-03-29 14:16:45 +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
Icxolu dd1710256d
use `extract_argument` for `#[setter]` extraction (#3998)
* use `extract_argument` for `#[setter]` extraction

* add newsfragment
2024-03-27 15:41:04 +00:00
David Hewitt bcfc848703
docs: fix link in CHANGELOG (#4001) 2024-03-27 11:48:56 +00:00
tison 7c03d65cda
chore: add Python scripting in database example (#3999) 2024-03-27 11:16:22 +00:00
Icxolu 35faeff6f1
handle `#[pyo3(from_py_with = "")]` in `#[setter]` methods (#3995)
* handle `#[pyo3(from_py_with = "")]` in `#[setter]` methods

* add newsfragment
2024-03-26 18:53:11 +00:00
David Hewitt 1be2fad9bf
release: 0.21.0 (#3983) 2024-03-25 23:36:08 +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
David Hewitt 7d319a906e
ci: tidy up benchmarks a little (#3986) 2024-03-23 20:17:33 +00:00
David Hewitt aeb74c7093
ci: use macos-14 runners (#3985)
* ci: use macos-14 runners

* use arm64 python architecture
2024-03-23 20:16:37 +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 9808f7111c
ci: add `update-ui-tests` nox session (#3979)
* ci: add `update-ui-tests` nox session

* defer error messages after the group closes

* fix syntax warnings
2024-03-22 22:43:08 +00:00
David Hewitt 20e477a7cd
avoid reference count cycle in tuple extraction (#3976) 2024-03-22 22:43:05 +00:00
David Hewitt 990886efda
docs: better document `FromPyObject` for `&str` changes in migration guide (#3974)
* docs: better document `FromPyObject` for `&str` changes in migration guide

* review: LilyFoote
2024-03-22 22:16:28 +00:00
David Hewitt d0f5b6af46
ci: updates for Rust 1.77 (#3978)
* ci: updates for Rust 1.77

* move `SendablePtr` inside of test which uses it
2024-03-22 20:43:23 +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
Icxolu 2736cf670c
deprecate gil-refs in `from_py_with` (Part 2) (#3972)
* deprecate `from_py_with` in `#[derive(FromPyObject)]` (NewType)

* deprecate `from_py_with` in `#[derive(FromPyObject)]` (Enum, Struct)
2024-03-20 09:27:38 +00:00