Skip to content

Commit 398ed30

Browse files
awestlake87chris-patterngi0baro
authored
Bump PyO3 to 0.20 (#110)
* tokio_test: add panic message into exception string * test adding module to export panic type * get compiling * fix macros build * Fix some stuff * fix build for async_std and tokio * Bump PyO3 to 0.20 * Fixed compilation errors in panic message change * Bumped MSRV * Updated docs --------- Co-authored-by: Chris Gregory <[email protected]> Co-authored-by: Giovanni Barillari <[email protected]>
1 parent 0ce6d6d commit 398ed30

File tree

9 files changed

+123
-45
lines changed

9 files changed

+123
-45
lines changed

.github/workflows/ci.yml

+1-4
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ jobs:
9191
platform: { os: "windows-latest", python-architecture: "x86" }
9292
include:
9393
# Test minimal supported Rust version
94-
- rust: 1.62.0
94+
- rust: 1.63.0
9595
python-version: "3.10"
9696
platform:
9797
{
@@ -155,9 +155,6 @@ jobs:
155155
env:
156156
RUST_BACKTRACE: 1
157157
RUSTFLAGS: "-D warnings"
158-
# TODO: this is a hack to workaround compile_error! warnings about auto-initialize on PyPy
159-
# Once cargo's `resolver = "2"` is stable (~ MSRV Rust 1.52), remove this.
160-
PYO3_CI: 1
161158

162159
coverage:
163160
needs: [fmt]

Cargo.toml

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[package]
22
name = "pyo3-asyncio"
33
description = "PyO3 utilities for Python's Asyncio library"
4-
version = "0.19.0"
4+
version = "0.20.0"
55
authors = ["Andrew J Westlake <[email protected]>"]
66
readme = "README.md"
77
keywords = ["pyo3", "python", "ffi", "async", "asyncio"]
@@ -116,11 +116,11 @@ futures = "0.3"
116116
inventory = { version = "0.3", optional = true }
117117
once_cell = "1.14"
118118
pin-project-lite = "0.2"
119-
pyo3 = "0.19"
120-
pyo3-asyncio-macros = { path = "pyo3-asyncio-macros", version = "=0.19.0", optional = true }
119+
pyo3 = "0.20"
120+
pyo3-asyncio-macros = { path = "pyo3-asyncio-macros", version = "=0.20.0", optional = true }
121121

122122
[dev-dependencies]
123-
pyo3 = { version = "0.19", features = ["macros"] }
123+
pyo3 = { version = "0.20", features = ["macros"] }
124124

125125
[dependencies.async-std]
126126
version = "1.12"

README.md

+13-13
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
[![Actions Status](https://github.com/awestlake87/pyo3-asyncio/workflows/CI/badge.svg)](https://github.com/awestlake87/pyo3-asyncio/actions)
44
[![codecov](https://codecov.io/gh/awestlake87/pyo3-asyncio/branch/master/graph/badge.svg)](https://codecov.io/gh/awestlake87/pyo3-asyncio)
55
[![crates.io](https://img.shields.io/crates/v/pyo3-asyncio)](https://crates.io/crates/pyo3-asyncio)
6-
[![minimum rustc 1.62](https://img.shields.io/badge/rustc-1.62+-blue.svg)](https://rust-lang.github.io/rfcs/2495-min-rust-version.html)
6+
[![minimum rustc 1.63](https://img.shields.io/badge/rustc-1.63+-blue.svg)](https://rust-lang.github.io/rfcs/2495-min-rust-version.html)
77

88
[Rust](http://www.rust-lang.org/) bindings for [Python](https://www.python.org/)'s [Asyncio Library](https://docs.python.org/3/library/asyncio.html). This crate facilitates interactions between Rust Futures and Python Coroutines and manages the lifecycle of their corresponding event loops.
99

@@ -52,8 +52,8 @@ Here we initialize the runtime, import Python's `asyncio` library and run the gi
5252
```toml
5353
# Cargo.toml dependencies
5454
[dependencies]
55-
pyo3 = { version = "0.19" }
56-
pyo3-asyncio = { version = "0.19", features = ["attributes", "async-std-runtime"] }
55+
pyo3 = { version = "0.20" }
56+
pyo3-asyncio = { version = "0.20", features = ["attributes", "async-std-runtime"] }
5757
async-std = "1.9"
5858
```
5959

@@ -82,8 +82,8 @@ attribute.
8282
```toml
8383
# Cargo.toml dependencies
8484
[dependencies]
85-
pyo3 = { version = "0.19" }
86-
pyo3-asyncio = { version = "0.19", features = ["attributes", "tokio-runtime"] }
85+
pyo3 = { version = "0.20" }
86+
pyo3-asyncio = { version = "0.20", features = ["attributes", "tokio-runtime"] }
8787
tokio = "1.9"
8888
```
8989

@@ -127,17 +127,17 @@ For `async-std`:
127127

128128
```toml
129129
[dependencies]
130-
pyo3 = { version = "0.19", features = ["extension-module"] }
131-
pyo3-asyncio = { version = "0.19", features = ["async-std-runtime"] }
130+
pyo3 = { version = "0.20", features = ["extension-module"] }
131+
pyo3-asyncio = { version = "0.20", features = ["async-std-runtime"] }
132132
async-std = "1.9"
133133
```
134134

135135
For `tokio`:
136136

137137
```toml
138138
[dependencies]
139-
pyo3 = { version = "0.19", features = ["extension-module"] }
140-
pyo3-asyncio = { version = "0.19", features = ["tokio-runtime"] }
139+
pyo3 = { version = "0.20", features = ["extension-module"] }
140+
pyo3-asyncio = { version = "0.20", features = ["tokio-runtime"] }
141141
tokio = "1.9"
142142
```
143143

@@ -431,8 +431,8 @@ name = "my_async_module"
431431
crate-type = ["cdylib"]
432432

433433
[dependencies]
434-
pyo3 = { version = "0.19", features = ["extension-module"] }
435-
pyo3-asyncio = { version = "0.19", features = ["tokio-runtime"] }
434+
pyo3 = { version = "0.20", features = ["extension-module"] }
435+
pyo3-asyncio = { version = "0.20", features = ["tokio-runtime"] }
436436
async-std = "1.9"
437437
tokio = "1.9"
438438
```
@@ -491,8 +491,8 @@ event loop before we can install the `uvloop` policy.
491491
```toml
492492
[dependencies]
493493
async-std = "1.9"
494-
pyo3 = "0.19"
495-
pyo3-asyncio = { version = "0.19", features = ["async-std-runtime"] }
494+
pyo3 = "0.20"
495+
pyo3-asyncio = { version = "0.20", features = ["async-std-runtime"] }
496496
```
497497

498498
```rust no_run

pyo3-asyncio-macros/Cargo.toml

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[package]
22
name = "pyo3-asyncio-macros"
33
description = "Proc Macro Attributes for PyO3 Asyncio"
4-
version = "0.19.0"
4+
version = "0.20.0"
55
authors = ["Andrew J Westlake <[email protected]>"]
66
readme = "../README.md"
77
keywords = ["pyo3", "python", "ffi", "async", "asyncio"]
@@ -18,4 +18,4 @@ proc-macro = true
1818
[dependencies]
1919
proc-macro2 = "1.0"
2020
quote = "1"
21-
syn = { version = "1", features = ["full"] }
21+
syn = { version = "1", features = ["full"] }

pyo3-asyncio-macros/src/lib.rs

+18-2
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,15 @@ pub fn tokio_test(_attr: TokenStream, item: TokenStream) -> TokenStream {
250250
Ok(result) => result,
251251
Err(e) => {
252252
assert!(e.is_panic());
253-
Err(pyo3::exceptions::PyException::new_err("rust future panicked"))
253+
let panic = e.into_panic();
254+
let panic_message = if let Some(s) = panic.downcast_ref::<&str>() {
255+
s.to_string()
256+
} else if let Some(s) = panic.downcast_ref::<String>() {
257+
s.clone()
258+
} else {
259+
"unknown error".into()
260+
};
261+
Err(pyo3_asyncio::err::RustPanic::new_err(format!("rust future panicked: {}", panic_message)))
254262
}
255263
}
256264
})
@@ -265,7 +273,15 @@ pub fn tokio_test(_attr: TokenStream, item: TokenStream) -> TokenStream {
265273
Ok(result) => result,
266274
Err(e) => {
267275
assert!(e.is_panic());
268-
Err(pyo3::exceptions::PyException::new_err("rust future panicked"))
276+
let panic = e.into_panic();
277+
let panic_message = if let Some(s) = panic.downcast_ref::<&str>() {
278+
s.to_string()
279+
} else if let Some(s) = panic.downcast_ref::<String>() {
280+
s.clone()
281+
} else {
282+
"unknown error".into()
283+
};
284+
Err(pyo3_asyncio::err::RustPanic::new_err(format!("rust future panicked: {}", panic_message)))
269285
}
270286
}
271287
})

src/async_std.rs

+4-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
//!
1010
//! ```toml
1111
//! [dependencies.pyo3-asyncio]
12-
//! version = "0.19"
12+
//! version = "0.20"
1313
//! features = ["unstable-streams"]
1414
//! ```
1515
@@ -48,6 +48,9 @@ impl JoinError for AsyncStdJoinErr {
4848
fn is_panic(&self) -> bool {
4949
true
5050
}
51+
fn into_panic(self) -> Box<dyn Any + Send + 'static> {
52+
self.0
53+
}
5154
}
5255

5356
async_std::task_local! {

0 commit comments

Comments
 (0)