Skip to content

Commit 80cd8e3

Browse files
committed
Fix immutable_type for Python 3.9
!test
1 parent db4aef5 commit 80cd8e3

File tree

8 files changed

+20
-10
lines changed

8 files changed

+20
-10
lines changed

src/bridge/cache.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@ use crate::common::Entry;
22
use crate::common::ObservedIterator;
33
use crate::common::PreHashObject;
44

5-
#[pyo3::pyclass(module = "cachebox._core", frozen, immutable_type)]
5+
#[cfg_attr(Py_3_9, pyo3::pyclass(module = "cachebox._core", frozen))]
6+
#[cfg_attr(not(Py_3_9), pyo3::pyclass(module = "cachebox._core", frozen, immutable_type))]
67
pub struct Cache {
78
raw: crate::common::Mutex<crate::policies::nopolicy::NoPolicy>,
89
}

src/bridge/fifocache.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@ use crate::common::Entry;
22
use crate::common::ObservedIterator;
33
use crate::common::PreHashObject;
44

5-
#[pyo3::pyclass(module = "cachebox._core", frozen, immutable_type)]
5+
#[cfg_attr(Py_3_9, pyo3::pyclass(module = "cachebox._core", frozen))]
6+
#[cfg_attr(not(Py_3_9), pyo3::pyclass(module = "cachebox._core", frozen, immutable_type))]
67
pub struct FIFOCache {
78
raw: crate::common::Mutex<crate::policies::fifo::FIFOPolicy>,
89
}

src/bridge/lfucache.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@ use crate::common::Entry;
22
use crate::common::ObservedIterator;
33
use crate::common::PreHashObject;
44

5-
#[pyo3::pyclass(module = "cachebox._core", frozen, immutable_type)]
5+
#[cfg_attr(Py_3_9, pyo3::pyclass(module = "cachebox._core", frozen))]
6+
#[cfg_attr(not(Py_3_9), pyo3::pyclass(module = "cachebox._core", frozen, immutable_type))]
67
pub struct LFUCache {
78
raw: crate::common::Mutex<crate::policies::lfu::LFUPolicy>,
89
}

src/bridge/lrucache.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@ use crate::common::Entry;
22
use crate::common::ObservedIterator;
33
use crate::common::PreHashObject;
44

5-
#[pyo3::pyclass(module = "cachebox._core", frozen, immutable_type)]
5+
#[cfg_attr(Py_3_9, pyo3::pyclass(module = "cachebox._core", frozen))]
6+
#[cfg_attr(not(Py_3_9), pyo3::pyclass(module = "cachebox._core", frozen, immutable_type))]
67
pub struct LRUCache {
78
raw: crate::common::Mutex<crate::policies::lru::LRUPolicy>,
89
}

src/bridge/mod.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@ use pyo3::types::PyTypeMethods;
33

44
create_exception!(cachebox._core, CoreKeyError, pyo3::exceptions::PyException);
55

6-
#[pyo3::pyclass(module = "cachebox._cachebox", subclass, frozen, immutable_type)]
6+
#[cfg_attr(Py_3_9, pyo3::pyclass(module = "cachebox._core", frozen, subclass))]
7+
#[cfg_attr(not(Py_3_9), pyo3::pyclass(module = "cachebox._core", frozen, immutable_type, subclass))]
78
pub struct BaseCacheImpl {}
89

910
#[pyo3::pymethods]
@@ -38,7 +39,8 @@ impl BaseCacheImpl {
3839
}
3940
}
4041

41-
#[pyo3::pyclass(module = "cachebox._core", frozen, immutable_type)]
42+
#[cfg_attr(Py_3_9, pyo3::pyclass(module = "cachebox._core", frozen))]
43+
#[cfg_attr(not(Py_3_9), pyo3::pyclass(module = "cachebox._core", frozen, immutable_type))]
4244
pub struct TTLPair {
4345
key: pyo3::Py<pyo3::PyAny>,
4446
value: pyo3::Py<pyo3::PyAny>,

src/bridge/rrcache.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@ use crate::common::Entry;
33
use crate::common::ObservedIterator;
44
use crate::common::PreHashObject;
55

6-
#[pyo3::pyclass(module = "cachebox._core", frozen, immutable_type)]
6+
#[cfg_attr(Py_3_9, pyo3::pyclass(module = "cachebox._core", frozen))]
7+
#[cfg_attr(not(Py_3_9), pyo3::pyclass(module = "cachebox._core", frozen, immutable_type))]
78
pub struct RRCache {
89
raw: crate::common::Mutex<crate::policies::random::RandomPolicy>,
910
}

src/bridge/ttlcache.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,15 @@ use crate::common::ObservedIterator;
33
use crate::common::PreHashObject;
44
use crate::common::TimeToLivePair;
55

6-
#[pyo3::pyclass(module = "cachebox._core", frozen, immutable_type)]
6+
#[cfg_attr(Py_3_9, pyo3::pyclass(module = "cachebox._core", frozen))]
7+
#[cfg_attr(not(Py_3_9), pyo3::pyclass(module = "cachebox._core", frozen, immutable_type))]
78
pub struct TTLCache {
89
raw: crate::common::Mutex<crate::policies::ttl::TTLPolicy>,
910
}
1011

1112
#[allow(non_camel_case_types)]
12-
#[pyo3::pyclass(module = "cachebox._core", immutable_type)]
13+
#[cfg_attr(Py_3_9, pyo3::pyclass(module = "cachebox._core"))]
14+
#[cfg_attr(not(Py_3_9), pyo3::pyclass(module = "cachebox._core", immutable_type))]
1315
pub struct ttlcache_items {
1416
pub ptr: ObservedIterator,
1517
pub iter: crate::common::Mutex<crate::policies::ttl::TTLIterator>,

src/bridge/vttlcache.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@ use crate::common::ObservedIterator;
33
use crate::common::PreHashObject;
44
use crate::common::TimeToLivePair;
55

6-
#[pyo3::pyclass(module = "cachebox._core", frozen, immutable_type)]
6+
#[cfg_attr(Py_3_9, pyo3::pyclass(module = "cachebox._core", frozen))]
7+
#[cfg_attr(not(Py_3_9), pyo3::pyclass(module = "cachebox._core", frozen, immutable_type))]
78
pub struct VTTLCache {
89
raw: crate::common::Mutex<crate::policies::vttl::VTTLPolicy>,
910
}

0 commit comments

Comments
 (0)