Commit Graph

2319 Commits

Author SHA1 Message Date
Paul Stemmet 338c71d0ad
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-03-16 16:12:25 +00:00
David Hewitt 5f65a97bdc ci: workaround more aggressive nightly rust lints 2024-02-23 11:59:20 +00:00
David Hewitt 2d5a54e4d2 ci: updates for Rust 1.76 2024-02-23 11:59:20 +00:00
David Hewitt 3447f0e77d 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-23 11:59:20 +00:00
Adam Reichold f7afb8157d Use portable-atomic for targets which lack 64-bit atomics used to check interpreter ID.
I chose to make the dependency mandatory instead of optional as portable-atomic
itself just forwards to the native atomics when they are available so making
that choice part of our build system is not really necessary. Personally, I was
unable to perceive any noticeable compile-time hit from adding it.
2024-02-23 11:59:20 +00:00
Adam Reichold 2564ca4e75
Fix missing feature flags in implementation of Either conversion. 2024-01-02 09:52:45 +01:00
Adam Reichold ecb0e9cb61 Copy note on using check_signals on non-main thread/interpreter from Python docs. 2023-12-29 22:59:45 +00:00
Nathan Kent 8f6976d9a5 Enable `GILProtected` access via `PyVisit`
Closes #3615

This simply adds a new method which uses the existence of a `PyVisit`
object as proof that the GIL is held instead of a `Python` object. This
allows `GILProtected` to be used in instances where contained Python
objects need to participate in garbage collection. Usage in this
situation should be valid since no Python calls are made and this does
not provide any additional mechanism for accessing a `Python` object.
2023-12-29 22:52:22 +00:00
Alex Gaynor 1166a995a4 Refactor create_type_object so that most of the code is monomorphic
In pyca/cryptography this function is the #1 source of lines of generated LLVM IR, because it is duplicated 42x (and growing!). By rewriting it so most of the logic is monomorphic, we reduce the generated LLVM IR for this function by 4x.
2023-12-29 22:50:23 +00:00
David Hewitt b1de927a31 docs: fixup docs for smallvec feature 2023-12-29 22:49:13 +00:00
Ivan Smirnov 2312270ec1 add conversion support for `either::Either` 2023-12-29 22:49:07 +00:00
David Hewitt bbc5404297 ci: move lints to new 1.74 cargo.toml tables 2023-12-29 22:46:39 +00:00
Joseph Perez a4aba0a09a refactor: remove useless `unsafe` in `get_mut` 2023-12-29 22:45:20 +00:00
Joseph Perez 04bb9f2110 feat: add `take` and `into_inner` methods to `GILOnceCell` 2023-12-29 22:45:12 +00:00
David Hewitt ba5a1da4a8 ci: fix nightly unused import warnings 2023-12-29 22:43:56 +00:00
David Hewitt 30463b6720 remove comparison to rust-cpython 2023-12-29 22:41:00 +00:00
Orhun Parmaksız 779eb2412c Add an entry to features table in lib 2023-12-29 22:39:43 +00:00
Orhun Parmaksız 427b2e9386 Add support for `SmallVec` in conversion traits (#3440) 2023-12-29 22:39:09 +00:00
David Hewitt e1d4173827 Fix bug in default implementation of `__ne__` 2023-10-11 09:48:06 +01:00
David Hewitt 76bf521ed0
Merge pull request #3505 from davidhewitt/deprecate_dunder_new
deprecate undocumented `#[__new__]` form of `#[new]`
2023-10-10 21:35:10 +00:00
David Hewitt 6c90325a1c deprecate undocumented `#[__new__]` form of `#[new]` 2023-10-10 08:47:03 +01:00
David Hewitt c0b5004cfa
Merge pull request #3455 from davidhewitt/normalized-exceptions
also use `PyErr::SetObject` on Python versions before 3.12
2023-10-10 07:44:39 +00:00
mejrs 6ca573b9d0 Update clippy 2023-10-06 23:31:06 +02: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 b9e9859082
Merge pull request #3478 from mejrs/auto
Don't let auto trait syntax bleed through on stable Rust
2023-09-29 16:35:05 +00:00
mejrs 0c8ab98760 move it into the inline module. 2023-09-29 17:22:27 +02:00
David Hewitt 1a349c2eb7 adjust cfgs for windows 3.9 2023-09-29 14:23:18 +01:00
David Hewitt 50cb41dd0b
Merge pull request #3458 from davidhewitt/truncate-leap-seconds
truncate leap seconds on `chrono` to `datetime` conversions
2023-09-29 11:47:27 +00:00
David Hewitt 4b5ff05721
Merge pull request #3471 from davidhewitt/normalized-exceptions-2
always normalize exceptions before raising
2023-09-28 20:27:18 +00:00
mejrs d0d4b9d3fb Dont let auto trait syntax bleed through on stable 2023-09-28 12:26:09 +02:00
David Hewitt 0459532f69 truncate leap seconds on `chrono` to `datetime` conversions 2023-09-24 20:28:43 +01:00
David Hewitt 673c45aac3
Merge pull request #3470 from davidhewitt/tests-capture-warnings
add `assert_warnings` test helper
2023-09-24 13:09:01 +00:00
David Hewitt 1e8833e15e always normalize exceptions before raising 2023-09-24 13:38:23 +01:00
David Hewitt 7d486bb72a tests/common.rs -> src/tests/common.rs 2023-09-24 13:34:53 +01:00
David Hewitt 42f9cd4476
Merge pull request #3469 from davidhewitt/chrono-tidy-up
refactor chrono implementation to be more DRY
2023-09-24 09:32:43 +00:00
David Hewitt f691a68b46
Merge pull request #3472 from davidhewitt/normalized-exceptions-3
unify 3.12 / non-3.12 error handling branches
2023-09-23 21:45:25 +00:00
David Hewitt d089c92680 unify 3.12 / non-3.12 error handling branches 2023-09-23 22:18:59 +01:00
David Hewitt 97ee5967e0 increase test coverage of `chrono` feature 2023-09-23 13:51:38 +01:00
David Hewitt 20378a607b
Merge pull request #3466 from davidhewitt/docs-only-prs
docs: skip changelog check for docs-only PRs
2023-09-23 12:26:37 +00:00
David Hewitt c8f82be32c add assert_warnings test helper 2023-09-23 13:14:18 +01:00
David Hewitt ccc22a905d allow invalid_from_utf8 lint in tests 2023-09-23 12:54:53 +01:00
David Hewitt 2d61a73b02 refactor chrono implementation to be more DRY 2023-09-23 12:46:45 +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
David Hewitt 5798caf1f8 better `Some`-wrapping for default arguments 2023-09-21 21:14:44 +01:00
David Hewitt 1ec3c5a4fd ci: adjust tests to avoid chrono panics 2023-09-21 08:34:45 +01:00
David Hewitt bcb01049cc
Merge pull request #3404 from davidhewitt/fix-dealloc
call PyObject_GC_Untrack before deallocating
2023-09-11 05:18:34 +00:00
David Hewitt 932c5c7061 workaround BaseException issue on Python versions before 3.11 2023-09-10 22:16:17 +02:00
David Hewitt e28403e772 call PyObject_GC_Untrack before deallocating 2023-09-09 22:29:58 +01:00