Skip to content

Commit 63b662e

Browse files
authored
Merge pull request #66 from alex/pyo3-bump
Upgrade to pyo3 0.26, fixing all warnings
2 parents 01c3667 + 1e286ad commit 63b662e

4 files changed

Lines changed: 14 additions & 14 deletions

File tree

.github/workflows/test.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ jobs:
6262
- name: Install Rust
6363
uses: dtolnay/rust-toolchain@master
6464
with:
65-
toolchain: "1.63"
65+
toolchain: "1.74"
6666

6767
- name: Install Python
6868
uses: actions/setup-python@v5
@@ -74,7 +74,7 @@ jobs:
7474

7575
- name: Install the minimal versions of dependencies
7676
env:
77-
# `-Z minimal-versions` is unstable, so we set
77+
# `-Z minimal-versions` is unstable, so we set
7878
# `RUSTC_BOOTSTRAP=1` to be able to use it on stable
7979
RUSTC_BOOTSTRAP: "1"
8080
run: cargo update -Z minimal-versions

Cargo.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,18 +10,18 @@ keywords = ["pyo3", "python", "logging"]
1010
categories = ["development-tools::debugging"]
1111
edition = "2018"
1212
license = "Apache-2.0 OR MIT"
13-
rust-version = "1.63"
13+
rust-version = "1.74"
1414

1515
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
1616

1717
[dependencies]
1818
arc-swap = "~1"
1919
# It's OK to ask for std on log, because pyo3 needs it too.
2020
log = { version = "~0.4.4", default-features = false, features = ["std"] }
21-
pyo3 = { version = ">=0.23, <0.26", default-features = false }
21+
pyo3 = { version = "0.26", default-features = false }
2222

2323
[dev-dependencies]
24-
pyo3 = { version = ">=0.23, <0.26", default-features = false, features = ["auto-initialize", "macros"] }
24+
pyo3 = { version = "0.26", default-features = false, features = ["auto-initialize", "macros"] }
2525

2626
# `pyo3-macros` is lying about the minimal version for its `syn` dependency.
2727
# Because we're testing with `-Zminimal-versions`, we need to explicitly set it here.

examples/hello_world/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,5 @@ crate-type = ["cdylib"]
1212

1313
[dependencies]
1414
log = "~0.4"
15-
pyo3 = { version = "~0.17", features = ["extension-module"] }
15+
pyo3 = { version = "~0.26", features = ["extension-module"] }
1616
pyo3-log = { path = "../.." }

src/lib.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -57,13 +57,13 @@
5757
//! #[pymodule]
5858
//! mod my_module{
5959
//! use super::*;
60-
//!
60+
//!
6161
//! #[pymodule_init]
6262
//! fn init(_m: &Bound<'_, PyModule>) -> PyResult<()> {
6363
//! pyo3_log::init();
6464
//! Ok(())
6565
//! }
66-
//!
66+
//!
6767
//! #[pyfunction]
6868
//! fn log_something() {
6969
//! info!("Something!");
@@ -108,7 +108,7 @@
108108
//! # use pyo3_log::{Caching, Logger};
109109
//! #
110110
//! # fn main() -> PyResult<()> {
111-
//! # Python::with_gil(|py| {
111+
//! # Python::attach(|py| {
112112
//! let handle = Logger::new(py, Caching::LoggersAndLevels)?
113113
//! .filter(LevelFilter::Trace)
114114
//! .filter_target("my_module::verbose_submodule".to_owned(), LevelFilter::Warn)
@@ -171,7 +171,7 @@
171171
//! fn dont_deadlock(py: Python<'_>) {
172172
//! info!("This logs fine");
173173
//!
174-
//! py.allow_threads(|| {
174+
//! py.detach(|| {
175175
//! let background_thread = thread::spawn(|| {
176176
//! info!("This'll not deadlock");
177177
//! });
@@ -242,7 +242,7 @@ pub enum Caching {
242242
#[derive(Debug)]
243243
struct CacheEntry {
244244
filter: LevelFilter,
245-
logger: PyObject,
245+
logger: Py<PyAny>,
246246
}
247247

248248
impl CacheEntry {
@@ -430,7 +430,7 @@ impl Logger {
430430
py: Python<'_>,
431431
record: &Record,
432432
cache: &Option<Arc<CacheNode>>,
433-
) -> PyResult<Option<PyObject>> {
433+
) -> PyResult<Option<Py<PyAny>>> {
434434
let msg = format!("{}", record.args());
435435
let log_level = map_level(record.level());
436436
let target = record.target().replace("::", ".");
@@ -520,7 +520,7 @@ impl Logger {
520520

521521
impl Default for Logger {
522522
fn default() -> Self {
523-
Python::with_gil(|py| {
523+
Python::attach(|py| {
524524
Self::new(py, Caching::LoggersAndLevels).expect("Failed to initialize python logging")
525525
})
526526
}
@@ -537,7 +537,7 @@ impl Log for Logger {
537537
let cache = self.lookup(record.target());
538538

539539
if self.enabled_inner(record.metadata(), &cache) {
540-
Python::with_gil(|py| {
540+
Python::attach(|py| {
541541
// If an exception were triggered before this attempt to log,
542542
// store it to the side for now and restore it afterwards.
543543
let maybe_existing_exception = PyErr::take(py);

0 commit comments

Comments
 (0)