Skip to content

Commit 8f310ca

Browse files
committed
Platform-specific signed/unsigned int libpython funcs
1 parent 7a1434f commit 8f310ca

1 file changed

Lines changed: 16 additions & 2 deletions

File tree

src/decode.rs

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,14 +102,28 @@ impl<'de, 'a> Visitor<'de> for JsonValue {
102102
where
103103
E: de::Error,
104104
{
105-
Ok(unsafe { pyo3::ffi::PyLong_FromLongLong(value) })
105+
#[cfg(target_os = "windows")]
106+
{
107+
Ok(unsafe { pyo3::ffi::PyLong_FromLongLong(value) })
108+
}
109+
#[cfg(not(target_os = "windows"))]
110+
{
111+
Ok(unsafe { pyo3::ffi::PyLong_FromLong(value) })
112+
}
106113
}
107114

108115
fn visit_u64<E>(self, value: u64) -> Result<Self::Value, E>
109116
where
110117
E: de::Error,
111118
{
112-
Ok(unsafe { pyo3::ffi::PyLong_FromLongLong(value as i64) })
119+
#[cfg(target_os = "windows")]
120+
{
121+
Ok(unsafe { pyo3::ffi::PyLong_FromUnsignedLongLong(value) })
122+
}
123+
#[cfg(not(target_os = "windows"))]
124+
{
125+
Ok(unsafe { pyo3::ffi::PyLong_FromUnsignedLong(value) })
126+
}
113127
}
114128

115129
fn visit_f64<E>(self, value: f64) -> Result<Self::Value, E>

0 commit comments

Comments
 (0)