rust-python3: compatibility fix for incoming PyLong
authorGeorges Racinet <georges.racinet@octobus.net>
Thu, 16 May 2019 21:22:29 +0200
changeset 42356 48df8a06c8bb
parent 42355 9166935da31f
child 42357 5b795108dd17
rust-python3: compatibility fix for incoming PyLong On Python3, PyInt is PyLong and it doesn't have the `value()` method. Re upcasting to PythonObj as done here works, but we might prefer taking a PythonObj from the onset (would require more testing) Differential Revision: https://phab.mercurial-scm.org/D6397
rust/hg-cpython/src/dirstate.rs
--- a/rust/hg-cpython/src/dirstate.rs	Tue May 21 04:30:56 2019 +0530
+++ b/rust/hg-cpython/src/dirstate.rs	Thu May 16 21:22:29 2019 +0200
@@ -12,7 +12,7 @@
 
 use cpython::{
     exc, PyBytes, PyDict, PyErr, PyInt, PyModule, PyObject, PyResult,
-    PySequence, PyTuple, Python, ToPyObject,
+    PySequence, PythonObject, PyTuple, Python, ToPyObject,
 };
 use hg::{
     pack_dirstate, parse_dirstate, CopyVecEntry, DirstateEntry,
@@ -153,7 +153,7 @@
         &dirstate_vec?,
         &copies?,
         DirstateParents { p1, p2 },
-        now.value(py) as i32,
+        now.as_object().extract::<i32>(py)?,
     ) {
         Ok((packed, new_dirstate_vec)) => {
             for (