-
Notifications
You must be signed in to change notification settings - Fork 795
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
opt: improve handle_panic generated code
- Loading branch information
1 parent
947055d
commit 5be5d77
Showing
11 changed files
with
50 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,3 +8,4 @@ pub mod deprecations; | |
pub mod freelist; | ||
#[doc(hidden)] | ||
pub mod frompyobject; | ||
pub(crate) mod not_send; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
use std::marker::PhantomData; | ||
|
||
use crate::Python; | ||
|
||
/// A marker type that makes the type !Send. | ||
/// Workaround for lack of !Send on stable (https://github.com/rust-lang/rust/issues/68318). | ||
pub(crate) struct NotSend(PhantomData<*mut Python<'static>>); | ||
|
||
pub(crate) const NOT_SEND: NotSend = NotSend(PhantomData); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
use pyo3::prelude::*; | ||
|
||
fn test_not_send_allow_threads(py: Python) { | ||
py.allow_threads(|| { drop(py); }); | ||
} | ||
|
||
fn main() { | ||
Python::with_gil(|py| { | ||
test_not_send_allow_threads(py); | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
error[E0277]: `*mut pyo3::Python<'static>` cannot be shared between threads safely | ||
--> tests/ui/not_send.rs:4:8 | ||
| | ||
4 | py.allow_threads(|| { drop(py); }); | ||
| ^^^^^^^^^^^^^ `*mut pyo3::Python<'static>` cannot be shared between threads safely | ||
| | ||
= help: within `pyo3::Python<'_>`, the trait `Sync` is not implemented for `*mut pyo3::Python<'static>` | ||
= note: required because it appears within the type `PhantomData<*mut pyo3::Python<'static>>` | ||
= note: required because it appears within the type `pyo3::impl_::not_send::NotSend` | ||
= note: required because it appears within the type `(&GILGuard, pyo3::impl_::not_send::NotSend)` | ||
= note: required because it appears within the type `PhantomData<(&GILGuard, pyo3::impl_::not_send::NotSend)>` | ||
= note: required because it appears within the type `pyo3::Python<'_>` | ||
= note: required because of the requirements on the impl of `Send` for `&pyo3::Python<'_>` | ||
= note: required because it appears within the type `[closure@$DIR/tests/ui/not_send.rs:4:22: 4:38]` |