Browse Source

Bump pyo3 version to 0.22.

Jelmer Vernooij 8 months ago
parent
commit
d76f668c47
5 changed files with 65 additions and 178 deletions
  1. 23 140
      Cargo.lock
  2. 1 0
      Cargo.toml
  3. 28 26
      crates/diff-tree/src/lib.rs
  4. 8 7
      crates/objects/src/lib.rs
  5. 5 5
      crates/pack/src/lib.rs

+ 23 - 140
Cargo.lock

@@ -4,15 +4,9 @@ version = 3
 
 [[package]]
 name = "autocfg"
-version = "1.2.0"
+version = "1.3.0"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "f1fdabc7756949593fe60f30ec81974b613357de856987752631dea1e3394c80"
-
-[[package]]
-name = "bitflags"
-version = "1.3.2"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a"
+checksum = "0c4b4d0bd25bd0b74681c0ad21497610ce1b7c91b1022cd21c80c6fbdd9476b0"
 
 [[package]]
 name = "cfg-if"
@@ -29,9 +23,9 @@ dependencies = [
 
 [[package]]
 name = "heck"
-version = "0.4.1"
+version = "0.5.0"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8"
+checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea"
 
 [[package]]
 name = "indoc"
@@ -41,19 +35,9 @@ checksum = "b248f5224d1d606005e02c97f5aa4e88eeb230488bcc03bc9ca4d7991399f2b5"
 
 [[package]]
 name = "libc"
-version = "0.2.153"
+version = "0.2.155"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "9c198f91728a82281a64e1f4f9eeb25d82cb32a5de251c6bd1b5154d63a8e7bd"
-
-[[package]]
-name = "lock_api"
-version = "0.4.11"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "3c168f8615b12bc01f9c17e2eb0cc07dcae1940121185446edc3744920e8ef45"
-dependencies = [
- "autocfg",
- "scopeguard",
-]
+checksum = "97b3888a4aecf77e811145cadf6eef5901f4782c53886191b2f693f24761847c"
 
 [[package]]
 name = "memchr"
@@ -92,29 +76,6 @@ dependencies = [
  "pyo3",
 ]
 
-[[package]]
-name = "parking_lot"
-version = "0.12.1"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "3742b2c103b9f06bc9fff0a37ff4912935851bee6d36f3c02bcc755bcfec228f"
-dependencies = [
- "lock_api",
- "parking_lot_core",
-]
-
-[[package]]
-name = "parking_lot_core"
-version = "0.9.9"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "4c42a9226546d68acdd9c0a280d17ce19bfe27a46bf68784e4066115788d008e"
-dependencies = [
- "cfg-if",
- "libc",
- "redox_syscall",
- "smallvec",
- "windows-targets",
-]
-
 [[package]]
 name = "portable-atomic"
 version = "1.6.0"
@@ -123,24 +84,24 @@ checksum = "7170ef9988bc169ba16dd36a7fa041e5c4cbeb6a35b76d4c03daded371eae7c0"
 
 [[package]]
 name = "proc-macro2"
-version = "1.0.79"
+version = "1.0.86"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "e835ff2298f5721608eb1a980ecaee1aef2c132bf95ecc026a11b7bf3c01c02e"
+checksum = "5e719e8df665df0d1c8fbfd238015744736151d4445ec0836b8e628aae103b77"
 dependencies = [
  "unicode-ident",
 ]
 
 [[package]]
 name = "pyo3"
-version = "0.21.2"
+version = "0.22.0"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "a5e00b96a521718e08e03b1a622f01c8a8deb50719335de3f60b3b3950f069d8"
+checksum = "1962a33ed2a201c637fc14a4e0fd4e06e6edfdeee6a5fede0dab55507ad74cf7"
 dependencies = [
  "cfg-if",
  "indoc",
  "libc",
  "memoffset",
- "parking_lot",
+ "once_cell",
  "portable-atomic",
  "pyo3-build-config",
  "pyo3-ffi",
@@ -150,9 +111,9 @@ dependencies = [
 
 [[package]]
 name = "pyo3-build-config"
-version = "0.21.2"
+version = "0.22.0"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "7883df5835fafdad87c0d888b266c8ec0f4c9ca48a5bed6bbb592e8dedee1b50"
+checksum = "ab7164b2202753bd33afc7f90a10355a719aa973d1f94502c50d06f3488bc420"
 dependencies = [
  "once_cell",
  "target-lexicon",
@@ -160,9 +121,9 @@ dependencies = [
 
 [[package]]
 name = "pyo3-ffi"
-version = "0.21.2"
+version = "0.22.0"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "01be5843dc60b916ab4dad1dca6d20b9b4e6ddc8e15f50c47fe6d85f1fb97403"
+checksum = "c6424906ca49013c0829c5c1ed405e20e2da2dc78b82d198564880a704e6a7b7"
 dependencies = [
  "libc",
  "pyo3-build-config",
@@ -170,9 +131,9 @@ dependencies = [
 
 [[package]]
 name = "pyo3-macros"
-version = "0.21.2"
+version = "0.22.0"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "77b34069fc0682e11b31dbd10321cbf94808394c56fd996796ce45217dfac53c"
+checksum = "82b2f19e153122d64afd8ce7aaa72f06a00f52e34e1d1e74b6d71baea396460a"
 dependencies = [
  "proc-macro2",
  "pyo3-macros-backend",
@@ -182,9 +143,9 @@ dependencies = [
 
 [[package]]
 name = "pyo3-macros-backend"
-version = "0.21.2"
+version = "0.22.0"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "08260721f32db5e1a5beae69a55553f56b99bd0e1c3e6e0a5e8851a9d0f5a85c"
+checksum = "dd698c04cac17cf0fe63d47790ab311b8b25542f5cb976b65c374035c50f1eef"
 dependencies = [
  "heck",
  "proc-macro2",
@@ -195,39 +156,18 @@ dependencies = [
 
 [[package]]
 name = "quote"
-version = "1.0.35"
+version = "1.0.36"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "291ec9ab5efd934aaf503a6466c5d5251535d108ee747472c3977cc5acc868ef"
+checksum = "0fa76aaf39101c457836aec0ce2316dbdc3ab723cdda1c6bd4e6ad4208acaca7"
 dependencies = [
  "proc-macro2",
 ]
 
-[[package]]
-name = "redox_syscall"
-version = "0.4.1"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "4722d768eff46b75989dd134e5c353f0d6296e5aaa3132e776cbdb56be7731aa"
-dependencies = [
- "bitflags",
-]
-
-[[package]]
-name = "scopeguard"
-version = "1.2.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49"
-
-[[package]]
-name = "smallvec"
-version = "1.13.2"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "3c5e1a9a646d36c3599cd173a41282daf47c44583ad367b8e6837255952e5c67"
-
 [[package]]
 name = "syn"
-version = "2.0.57"
+version = "2.0.68"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "11a6ae1e52eb25aab8f3fb9fca13be982a373b8f1157ca14b897a825ba4a2d35"
+checksum = "901fa70d88b9d6c98022e23b4136f9f3e54e4662c3bc1bd1d84a42a9a0f0c1e9"
 dependencies = [
  "proc-macro2",
  "quote",
@@ -251,60 +191,3 @@ name = "unindent"
 version = "0.2.3"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "c7de7d73e1754487cb58364ee906a499937a0dfabd86bcb980fa99ec8c8fa2ce"
-
-[[package]]
-name = "windows-targets"
-version = "0.48.5"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "9a2fa6e2155d7247be68c096456083145c183cbbbc2764150dda45a87197940c"
-dependencies = [
- "windows_aarch64_gnullvm",
- "windows_aarch64_msvc",
- "windows_i686_gnu",
- "windows_i686_msvc",
- "windows_x86_64_gnu",
- "windows_x86_64_gnullvm",
- "windows_x86_64_msvc",
-]
-
-[[package]]
-name = "windows_aarch64_gnullvm"
-version = "0.48.5"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "2b38e32f0abccf9987a4e3079dfb67dcd799fb61361e53e2882c3cbaf0d905d8"
-
-[[package]]
-name = "windows_aarch64_msvc"
-version = "0.48.5"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc"
-
-[[package]]
-name = "windows_i686_gnu"
-version = "0.48.5"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "a75915e7def60c94dcef72200b9a8e58e5091744960da64ec734a6c6e9b3743e"
-
-[[package]]
-name = "windows_i686_msvc"
-version = "0.48.5"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "8f55c233f70c4b27f66c523580f78f1004e8b5a8b659e05a4eb49d4166cca406"
-
-[[package]]
-name = "windows_x86_64_gnu"
-version = "0.48.5"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "53d40abd2583d23e4718fddf1ebec84dbff8381c07cae67ff7768bbf19c6718e"
-
-[[package]]
-name = "windows_x86_64_gnullvm"
-version = "0.48.5"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "0b7b52767868a23d5bab768e390dc5f5c55825b6d30b86c844ff2dc7414044cc"
-
-[[package]]
-name = "windows_x86_64_msvc"
-version = "0.48.5"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538"

+ 1 - 0
Cargo.toml

@@ -1,5 +1,6 @@
 [workspace]
 members = ["crates/*"]
+resolver = "2"
 
 [workspace.dependencies]
 pyo3 = ">=0.19"

+ 28 - 26
crates/diff-tree/src/lib.rs

@@ -30,8 +30,8 @@ use std::cmp::Ordering;
 const S_IFMT: u32 = 0o170000;
 const S_IFDIR: u32 = 0o040000;
 
-fn add_hash(get: &PyAny, set: &PyAny, string: &[u8], py: Python) -> PyResult<()> {
-    let str_obj = PyBytes::new(py, string);
+fn add_hash(get: &Bound<PyAny>, set: &Bound<PyAny>, string: &[u8], py: Python) -> PyResult<()> {
+    let str_obj = PyBytes::new_bound(py, string);
     let hash_obj = str_obj.hash()?;
     let value = get.call1((hash_obj,))?;
     let n = string.len();
@@ -40,9 +40,9 @@ fn add_hash(get: &PyAny, set: &PyAny, string: &[u8], py: Python) -> PyResult<()>
 }
 
 #[pyfunction]
-fn _count_blocks(py: Python, obj: &PyAny) -> PyResult<PyObject> {
-    let default_dict_cls = PyModule::import(py, "collections")?.getattr("defaultdict")?;
-    let int_cls = PyModule::import(py, "builtins")?.getattr("int")?;
+fn _count_blocks(py: Python, obj: &Bound<PyAny>) -> PyResult<PyObject> {
+    let default_dict_cls = PyModule::import_bound(py, "collections")?.getattr("defaultdict")?;
+    let int_cls = PyModule::import_bound(py, "builtins")?.getattr("int")?;
 
     let counts = default_dict_cls.call1((int_cls,))?;
     let get = counts.getattr("__getitem__")?;
@@ -56,7 +56,7 @@ fn _count_blocks(py: Python, obj: &PyAny) -> PyResult<PyObject> {
     }
 
     let num_chunks = chunks.extract::<Vec<PyObject>>()?.len();
-    let pym = py.import("dulwich.diff_tree")?;
+    let pym = py.import_bound("dulwich.diff_tree")?;
     let block_size = pym.getattr("_BLOCK_SIZE")?.extract::<usize>()?;
     let mut block: Vec<u8> = Vec::with_capacity(block_size);
 
@@ -70,20 +70,20 @@ fn _count_blocks(py: Python, obj: &PyAny) -> PyResult<PyObject> {
         for c in chunk_str {
             block.push(*c);
             if *c == b'\n' || block.len() == block_size {
-                add_hash(get, set, &block, py)?;
+                add_hash(&get, &set, &block, py)?;
                 block.clear();
             }
         }
     }
     if !block.is_empty() {
-        add_hash(get, set, &block, py)?;
+        add_hash(&get, &set, &block, py)?;
     }
 
     Ok(counts.to_object(py))
 }
 
 #[pyfunction]
-fn _is_tree(_py: Python, entry: &PyAny) -> PyResult<bool> {
+fn _is_tree(_py: Python, entry: &Bound<PyAny>) -> PyResult<bool> {
     let mode = entry.getattr("mode")?;
 
     if mode.is_none() {
@@ -94,12 +94,12 @@ fn _is_tree(_py: Python, entry: &PyAny) -> PyResult<bool> {
     }
 }
 
-fn tree_entries(path: &[u8], tree: &PyAny, py: Python) -> PyResult<Vec<PyObject>> {
+fn tree_entries(path: &[u8], tree: &Bound<PyAny>, py: Python) -> PyResult<Vec<PyObject>> {
     if tree.is_none() {
         return Ok(Vec::new());
     }
 
-    let dom = py.import("dulwich.objects")?;
+    let dom = py.import_bound("dulwich.objects")?;
     let tree_entry_cls = dom.getattr("TreeEntry")?;
 
     let items = tree
@@ -117,25 +117,27 @@ fn tree_entries(path: &[u8], tree: &PyAny, py: Python) -> PyResult<Vec<PyObject>
         }
         new_path.extend_from_slice(name.as_slice());
 
-        let tree_entry = tree_entry_cls.call1((PyBytes::new(py, &new_path), mode, sha))?;
+        let tree_entry = tree_entry_cls.call1((PyBytes::new_bound(py, &new_path), mode, sha))?;
         result.push(tree_entry.to_object(py));
     }
 
     Ok(result)
 }
 
-fn entry_path_cmp(entry1: &PyAny, entry2: &PyAny) -> PyResult<Ordering> {
-    let path1 = entry1.getattr("path")?.extract::<&[u8]>()?;
-    let path2 = entry2.getattr("path")?.extract::<&[u8]>()?;
+fn entry_path_cmp(entry1: &Bound<PyAny>, entry2: &Bound<PyAny>) -> PyResult<Ordering> {
+    let path1_o = entry1.getattr("path")?;
+    let path1 = path1_o.extract::<&[u8]>()?;
+    let path2_o = entry2.getattr("path")?;
+    let path2 = path2_o.extract::<&[u8]>()?;
     Ok(path1.cmp(path2))
 }
 
 #[pyfunction]
-fn _merge_entries(py: Python, path: &[u8], tree1: &PyAny, tree2: &PyAny) -> PyResult<PyObject> {
+fn _merge_entries(py: Python, path: &[u8], tree1: &Bound<PyAny>, tree2: &Bound<PyAny>) -> PyResult<PyObject> {
     let entries1 = tree_entries(path, tree1, py)?;
     let entries2 = tree_entries(path, tree2, py)?;
 
-    let pym = py.import("dulwich.diff_tree")?;
+    let pym = py.import_bound("dulwich.diff_tree")?;
     let null_entry = pym.getattr("_NULL_ENTRY")?.to_object(py);
 
     let mut result = Vec::new();
@@ -143,13 +145,13 @@ fn _merge_entries(py: Python, path: &[u8], tree1: &PyAny, tree2: &PyAny) -> PyRe
     let mut i1 = 0;
     let mut i2 = 0;
     while i1 < entries1.len() && i2 < entries2.len() {
-        let cmp = entry_path_cmp(entries1[i1].as_ref(py), entries2[i2].as_ref(py))?;
+        let cmp = entry_path_cmp(entries1[i1].bind(py), entries2[i2].bind(py))?;
         let (e1, e2) = match cmp {
-            Ordering::Equal => (entries1[i1].clone(), entries2[i2].clone()),
-            Ordering::Less => (entries1[i1].clone(), null_entry.clone()),
-            Ordering::Greater => (null_entry.clone(), entries2[i2].clone()),
+            Ordering::Equal => (entries1[i1].clone_ref(py), entries2[i2].clone_ref(py)),
+            Ordering::Less => (entries1[i1].clone_ref(py), null_entry.clone_ref(py)),
+            Ordering::Greater => (null_entry.clone_ref(py), entries2[i2].clone_ref(py)),
         };
-        let pair = PyTuple::new(py, &[e1, e2]);
+        let pair = PyTuple::new_bound(py, &[e1, e2]);
         result.push(pair);
         match cmp {
             Ordering::Equal => {
@@ -166,22 +168,22 @@ fn _merge_entries(py: Python, path: &[u8], tree1: &PyAny, tree2: &PyAny) -> PyRe
     }
 
     while i1 < entries1.len() {
-        let pair = PyTuple::new(py, &[entries1[i1].clone(), null_entry.clone()]);
+        let pair = PyTuple::new_bound(py, &[entries1[i1].clone_ref(py), null_entry.clone_ref(py)]);
         result.push(pair);
         i1 += 1;
     }
 
     while i2 < entries2.len() {
-        let pair = PyTuple::new(py, &[null_entry.clone(), entries2[i2].clone()]);
+        let pair = PyTuple::new_bound(py, &[null_entry.clone_ref(py), entries2[i2].clone_ref(py)]);
         result.push(pair);
         i2 += 1;
     }
 
-    Ok(PyList::new(py, &result).to_object(py))
+    Ok(PyList::new_bound(py, &result).to_object(py))
 }
 
 #[pymodule]
-fn _diff_tree(_py: Python, m: &PyModule) -> PyResult<()> {
+fn _diff_tree(_py: Python, m: &Bound<PyModule>) -> PyResult<()> {
     m.add_function(wrap_pyfunction!(_count_blocks, m)?)?;
     m.add_function(wrap_pyfunction!(_is_tree, m)?)?;
     m.add_function(wrap_pyfunction!(_merge_entries, m)?)?;

+ 8 - 7
crates/objects/src/lib.rs

@@ -45,10 +45,11 @@ fn sha_to_pyhex(py: Python, sha: &[u8]) -> PyResult<PyObject> {
         hexsha.push(bytehex(c & 0x0F));
     }
 
-    Ok(PyBytes::new(py, hexsha.as_slice()).into())
+    Ok(PyBytes::new_bound(py, hexsha.as_slice()).into())
 }
 
 #[pyfunction]
+#[pyo3(signature = (text, strict=None))]
 fn parse_tree(
     py: Python,
     mut text: &[u8],
@@ -94,7 +95,7 @@ fn parse_tree(
         text = &text[namelen + 1..];
         let sha = &text[..20];
         entries.push((
-            PyBytes::new(py, name).to_object(py),
+            PyBytes::new_bound(py, name).to_object(py),
             mode,
             sha_to_pyhex(py, sha)?,
         ));
@@ -124,7 +125,7 @@ fn name_with_suffix(mode: u32, name: &[u8]) -> Cow<[u8]> {
 ///
 /// # Returns: Iterator over (name, mode, hexsha)
 #[pyfunction]
-fn sorted_tree_items(py: Python, entries: &PyDict, name_order: bool) -> PyResult<Vec<PyObject>> {
+fn sorted_tree_items(py: Python, entries: &Bound<PyDict>, name_order: bool) -> PyResult<Vec<PyObject>> {
     let mut qsort_entries = Vec::new();
     for (name, e) in entries.iter() {
         let (mode, sha): (u32, Vec<u8>) = match e.extract() {
@@ -142,16 +143,16 @@ fn sorted_tree_items(py: Python, entries: &PyDict, name_order: bool) -> PyResult
             name_with_suffix(a.1, a.0.as_slice()).cmp(&name_with_suffix(b.1, b.0.as_slice()))
         });
     }
-    let objectsm = py.import("dulwich.objects")?;
+    let objectsm = py.import_bound("dulwich.objects")?;
     let tree_entry_cls = objectsm.getattr("TreeEntry")?;
     qsort_entries
         .into_iter()
         .map(|(name, mode, hexsha)| -> PyResult<PyObject> {
             Ok(tree_entry_cls
                 .call1((
-                    PyBytes::new(py, name.as_slice()).to_object(py),
+                    PyBytes::new_bound(py, name.as_slice()).to_object(py),
                     mode,
-                    PyBytes::new(py, hexsha.as_slice()).to_object(py),
+                    PyBytes::new_bound(py, hexsha.as_slice()).to_object(py),
                 ))?
                 .to_object(py))
         })
@@ -159,7 +160,7 @@ fn sorted_tree_items(py: Python, entries: &PyDict, name_order: bool) -> PyResult
 }
 
 #[pymodule]
-fn _objects(_py: Python, m: &PyModule) -> PyResult<()> {
+fn _objects(_py: Python, m: &Bound<PyModule>) -> PyResult<()> {
     m.add_function(wrap_pyfunction!(sorted_tree_items, m)?)?;
     m.add_function(wrap_pyfunction!(parse_tree, m)?)?;
     Ok(())

+ 5 - 5
crates/pack/src/lib.rs

@@ -26,7 +26,7 @@ pyo3::import_exception!(dulwich.errors, ApplyDeltaError);
 
 fn py_is_sha(sha: &PyObject, py: Python) -> PyResult<bool> {
     // Check if the object is a bytes object
-    if sha.as_ref(py).is_instance_of::<PyBytes>() {
+    if sha.bind(py).is_instance_of::<PyBytes>() {
         // Check if the bytes object has a size of 20
         if sha.extract::<&[u8]>(py)?.len() == 20 {
             Ok(true)
@@ -100,7 +100,7 @@ fn get_delta_header_size(delta: &[u8], index: &mut usize, length: usize) -> usiz
 }
 
 fn py_chunked_as_string<'a>(py: Python<'a>, py_buf: &'a PyObject) -> PyResult<std::borrow::Cow<'a, [u8]>> {
-    if let Ok(py_list) = py_buf.extract::<&PyList>(py) {
+    if let Ok(py_list) = py_buf.extract::<Bound<PyList>>(py) {
         let mut buf = Vec::new();
         for chunk in py_list.iter() {
             if let Ok(chunk) = chunk.extract::<&[u8]>() {
@@ -112,7 +112,7 @@ fn py_chunked_as_string<'a>(py: Python<'a>, py_buf: &'a PyObject) -> PyResult<st
             }
         }
         Ok(buf.into())
-    } else if py_buf.extract::<&PyBytes>(py).is_ok() {
+    } else if py_buf.extract::<Bound<PyBytes>>(py).is_ok() {
         Ok(std::borrow::Cow::Borrowed(py_buf.extract::<&[u8]>(py)?))
     } else {
         Err(PyTypeError::new_err("buf is not a string or a list of chunks"))
@@ -203,11 +203,11 @@ fn apply_delta(py: Python, py_src_buf: PyObject, py_delta: PyObject) -> PyResult
         return Err(ApplyDeltaError::new_err("dest size incorrect"));
     }
 
-    Ok(vec![PyBytes::new(py, &out).into()])
+    Ok(vec![PyBytes::new_bound(py, &out).into()])
 }
 
 #[pymodule]
-fn _pack(_py: Python, m: &PyModule) -> PyResult<()> {
+fn _pack(_py: Python, m: &Bound<PyModule>) -> PyResult<()> {
     m.add_function(wrap_pyfunction!(bisect_find_sha, m)?)?;
     m.add_function(wrap_pyfunction!(apply_delta, m)?)?;
     Ok(())