1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92
|
Description: Support pyo3 0.26-0.28
Update Cargo.toml version constraints and adapt to pyo3 0.28 API changes:
PyObject replaced with Py<PyAny>, Python::allow_threads renamed to
py.detach(), BoundObject trait removed, bool into_pyobject now returns
Borrowed requiring to_owned() before into_any().
Author: Adrian Bunk <bunk@debian.org>
Author: Colin Watson <cjwatson@debian.org>
Author: Jelmer Vernooij <jelmer@debian.org>
Bug-Debian: https://bugs.debian.org/1114321
---
Index: python-pycddl/Cargo.toml
===================================================================
--- python-pycddl.orig/Cargo.toml
+++ python-pycddl/Cargo.toml
@@ -18,10 +18,10 @@ crate-type = ["cdylib"]
cddl = "0.9.5"
ciborium = "0.2"
self_cell = "1.0"
-pyo3 = "0.22"
+pyo3 = ">=0.26,<0.29"
[build-dependencies]
-pyo3-build-config = { version = "0.22", features = ["resolve-config"] }
+pyo3-build-config = { version = ">=0.26,<0.29", features = ["resolve-config"] }
[profile.release]
lto = "thin"
\ No newline at end of file
Index: python-pycddl/src/deserialize.rs
===================================================================
--- python-pycddl.orig/src/deserialize.rs
+++ python-pycddl/src/deserialize.rs
@@ -1,16 +1,16 @@
//! Deserialize CBOR to Python objects.
use ciborium::value::Value;
-use pyo3::{prelude::*, types::{PyList, PyDict, PyBytes, PySet}, exceptions::PyValueError, BoundObject};
+use pyo3::{prelude::*, types::{PyList, PyDict, PyBytes, PySet}, exceptions::PyValueError};
/// Convert a CBOR value into an equivalent tree of Python objects.
-pub fn deserialize(py: Python<'_>, value: &Value) -> PyResult<PyObject> {
+pub fn deserialize(py: Python<'_>, value: &Value) -> PyResult<Py<PyAny>> {
match value {
Value::Integer(int) => Ok(i128::from(*int).into_pyobject(py)?.into_any().unbind()),
Value::Bytes(vec) => Ok(PyBytes::new(py, vec).into_any().unbind()),
Value::Float(float) => Ok(float.into_pyobject(py)?.into_any().unbind()),
Value::Text(string) => Ok(string.into_pyobject(py)?.into_any().unbind()),
- Value::Bool(boolean) => Ok(boolean.into_pyobject(py)?.into_any().unbind()),
+ Value::Bool(boolean) => Ok(boolean.into_pyobject(py)?.to_owned().into_any().unbind()),
Value::Null => Ok(py.None()),
Value::Array(array_values) => {
let result = PyList::empty(py);
@@ -34,7 +34,7 @@ pub fn deserialize(py: Python<'_>, value
}
/// Decoded a tagged value that isn't built-in to ciborium.
-fn deserialize_tagged(py: Python<'_>, tag: u64, value: &Value) -> PyResult<PyObject> {
+fn deserialize_tagged(py: Python<'_>, tag: u64, value: &Value) -> PyResult<Py<PyAny>> {
match (tag, value) {
(258, Value::Array(array_values)) => {
let result = PySet::empty(py)?;
Index: python-pycddl/src/lib.rs
===================================================================
--- python-pycddl.orig/src/lib.rs
+++ python-pycddl/src/lib.rs
@@ -50,7 +50,7 @@ impl Schema {
/// if validation failed. If the ``deserialize`` argument is true, the CBOR
/// will be deserialized to Python objects and returned.
#[pyo3(signature = (cbor, deserialize=false))]
- fn validate_cbor(&self, py: Python<'_>, cbor: &Bound<'_, PyAny>, deserialize: bool) -> PyResult<PyObject> {
+ fn validate_cbor(&self, py: Python<'_>, cbor: &Bound<'_, PyAny>, deserialize: bool) -> PyResult<Py<PyAny>> {
let buffer = PyBuffer::<u8>::get(cbor)?;
// PyPy has weird issues with this flag.
if !cfg!(PyPy) && !buffer.readonly() {
@@ -91,7 +91,7 @@ impl Schema {
if document_size > 10 * 1024 {
// For larger documents, parsing can get expensive, so release
// the GIL to enable parallelism.
- Python::allow_threads(py, parse_and_validate)?;
+ py.detach(parse_and_validate)?;
} else {
parse_and_validate()?;
}
@@ -101,7 +101,7 @@ impl Schema {
// need to parse twice (https://github.com/anweiss/cddl/issues/216).
// Cloning would use lots more memory, so better to use CPU.
let parsed_cbor = if document_size > 10 * 1024 {
- Python::allow_threads(py, parse)
+ py.detach(parse)
} else {
parse()
}
|