Skip to content

Commit 2b29831

Browse files
konstinijl
authored andcommitted
Remove two unsafe (#29)
1 parent 1d4e706 commit 2b29831

1 file changed

Lines changed: 2 additions & 20 deletions

File tree

src/lib.rs

Lines changed: 2 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -48,27 +48,9 @@ fn orjson(py: Python, m: &PyModule) -> PyResult<()> {
4848

4949
m.add("JSONDecodeError", py.get_type::<exc::JSONDecodeError>())?;
5050
m.add("JSONEncodeError", py.get_type::<exc::JSONEncodeError>())?;
51+
m.add("OPT_STRICT_INTEGER", encode::STRICT_INTEGER)?;
52+
m.add("OPT_NAIVE_UTC", encode::NAIVE_UTC)?;
5153

52-
unsafe {
53-
pyo3::ffi::PyModule_AddObject(
54-
m.as_ptr(),
55-
"OPT_STRICT_INTEGER\0".as_ptr() as *const c_char,
56-
#[cfg(target_os = "windows")]
57-
pyo3::ffi::PyLong_FromUnsignedLongLong(encode::STRICT_INTEGER as u64),
58-
#[cfg(not(target_os = "windows"))]
59-
pyo3::ffi::PyLong_FromUnsignedLong(encode::STRICT_INTEGER as u64),
60-
)
61-
};
62-
unsafe {
63-
pyo3::ffi::PyModule_AddObject(
64-
m.as_ptr(),
65-
"OPT_NAIVE_UTC\0".as_ptr() as *const c_char,
66-
#[cfg(target_os = "windows")]
67-
pyo3::ffi::PyLong_FromUnsignedLongLong(encode::NAIVE_UTC as u64),
68-
#[cfg(not(target_os = "windows"))]
69-
pyo3::ffi::PyLong_FromUnsignedLong(encode::NAIVE_UTC as u64),
70-
)
71-
};
7254
Ok(())
7355
}
7456

0 commit comments

Comments
 (0)