Skip to content

Commit

Permalink
pyo3 0.20, Py_MOD_MULTIPLE_INTERPRETERS_NOT_SUPPORTED
Browse files Browse the repository at this point in the history
  • Loading branch information
ijl committed Oct 12, 2023
1 parent 58e2669 commit ca397ec
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 44 deletions.
8 changes: 4 additions & 4 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ encoding_rs = { version = "0.8", default_features = false }
itoa = { version = "1", default_features = false }
itoap = { version = "1", features = ["std", "simd"] }
once_cell = { version = "1", default_features = false, features = ["race"] }
pyo3-ffi = { version = "^0.19.2", default_features = false, features = ["extension-module"]}
pyo3-ffi = { version = "^0.20", default_features = false, features = ["extension-module"]}
ryu = { version = "1", default_features = false }
serde = { version = "1", default_features = false }
serde_json = { version = "1", default_features = false, features = ["std", "float_roundtrip"] }
Expand All @@ -68,7 +68,7 @@ smallvec = { version = "^1.11", default_features = false, features = ["union", "

[build-dependencies]
cc = { version = "1" }
pyo3-build-config = { version = "^0.19.2" }
pyo3-build-config = { version = "^0.20" }
version_check = { version = "0.9" }

[profile.dev]
Expand Down
7 changes: 2 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ file-like objects
orjson supports CPython 3.8, 3.9, 3.10, 3.11, and 3.12. It distributes
amd64/x86_64, aarch64/armv8, arm7, POWER/ppc64le, and s390x wheels for Linux,
amd64 and aarch64 wheels for macOS, and amd64 and i686/x86 wheels for Windows.
orjson does not support PyPy. Releases follow semantic versioning and
orjson does not and will not support PyPy. orjson does not and will not
support PEP 554 subinterpreters. Releases follow semantic versioning and
serializing a new object type without an opt-in flag is considered a
breaking change.

Expand Down Expand Up @@ -1177,10 +1178,6 @@ level above this.

No. `bytes` is the correct type for a serialized blob.

### Will it support PyPy?

Probably not.

## Packaging

To package orjson requires at least [Rust](https://www.rust-lang.org/) 1.65
Expand Down
27 changes: 0 additions & 27 deletions src/ffi/immortal.rs

This file was deleted.

4 changes: 0 additions & 4 deletions src/ffi/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
mod buffer;
mod bytes;
mod fragment;
#[cfg(Py_3_12)]
mod immortal;
mod list;
mod long;
#[cfg(feature = "yyjson")]
Expand All @@ -13,7 +11,5 @@ pub mod yyjson;
pub use buffer::*;
pub use bytes::*;
pub use fragment::{orjson_fragmenttype_new, Fragment};
#[cfg(Py_3_12)]
pub use immortal::_Py_IsImmortal;
pub use list::PyListIter;
pub use long::{pylong_is_unsigned, pylong_is_zero};
12 changes: 11 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -143,16 +143,26 @@ pub unsafe extern "C" fn orjson_init_exec(mptr: *mut PyObject) -> c_int {
0
}

#[cfg(not(Py_3_12))]
const PYMODULEDEF_LEN: usize = 2;
#[cfg(Py_3_12)]
const PYMODULEDEF_LEN: usize = 3;

#[allow(non_snake_case)]
#[no_mangle]
#[cold]
#[cfg_attr(feature = "optimize", optimize(size))]
pub unsafe extern "C" fn PyInit_orjson() -> *mut PyModuleDef {
let mod_slots: Box<[PyModuleDef_Slot; 2]> = Box::new([
let mod_slots: Box<[PyModuleDef_Slot; PYMODULEDEF_LEN]> = Box::new([
PyModuleDef_Slot {
slot: Py_mod_exec,
value: orjson_init_exec as *mut c_void,
},
#[cfg(Py_3_12)]
PyModuleDef_Slot {
slot: Py_mod_multiple_interpreters,
value: Py_MOD_MULTIPLE_INTERPRETERS_NOT_SUPPORTED,
},
PyModuleDef_Slot {
slot: 0,
value: null_mut(),
Expand Down
2 changes: 1 addition & 1 deletion src/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ macro_rules! str_from_slice {
macro_rules! reverse_pydict_incref {
($op:expr) => {
unsafe {
if crate::ffi::_Py_IsImmortal($op) == 0 {
if pyo3_ffi::_Py_IsImmortal($op) == 0 {
debug_assert!(ffi!(Py_REFCNT($op)) >= 2);
(*$op).ob_refcnt.ob_refcnt -= 1;
}
Expand Down

0 comments on commit ca397ec

Please sign in to comment.