@@ -3,7 +3,7 @@ use std::borrow::Cow;
3
3
use pyo3:: exceptions:: PyKeyError ;
4
4
use pyo3:: prelude:: * ;
5
5
use pyo3:: types:: { PyDict , PyString } ;
6
- use pyo3:: { ffi , intern, FromPyObject } ;
6
+ use pyo3:: { intern, FromPyObject } ;
7
7
8
8
use jiter:: { cached_py_string, pystring_fast_new, StringCacheMode } ;
9
9
@@ -124,26 +124,17 @@ pub fn safe_repr<'py>(v: &Bound<'py, PyAny>) -> ReprOutput<'py> {
124
124
}
125
125
}
126
126
127
- /// Extract an i64 from a python object more quickly, see
128
- /// https://github.com/PyO3/pyo3/pull/3742#discussion_r1451763928
129
- #[ cfg( not( any( target_pointer_width = "32" , windows, PyPy ) ) ) ]
130
- pub fn extract_i64 ( obj : & Bound < ' _ , PyAny > ) -> Option < i64 > {
131
- let val = unsafe { ffi:: PyLong_AsLong ( obj. as_ptr ( ) ) } ;
132
- if val == -1 && PyErr :: occurred ( obj. py ( ) ) {
133
- unsafe { ffi:: PyErr_Clear ( ) } ;
134
- None
135
- } else {
136
- Some ( val)
137
- }
138
- }
139
-
140
- #[ cfg( any( target_pointer_width = "32" , windows, PyPy ) ) ]
141
127
pub fn extract_i64 ( v : & Bound < ' _ , PyAny > ) -> Option < i64 > {
142
- if v. is_instance_of :: < pyo3:: types:: PyInt > ( ) {
143
- v. extract ( ) . ok ( )
144
- } else {
145
- None
128
+ #[ cfg( PyPy ) ]
129
+ if !v. is_instance_of :: < pyo3:: types:: PyInt > ( ) {
130
+ // PyPy used __int__ to cast floats to ints after CPython removed it,
131
+ // see https://github.com/pypy/pypy/issues/4949
132
+ //
133
+ // Can remove this after PyPy 7.3.17 is released
134
+ return None ;
146
135
}
136
+
137
+ v. extract ( ) . ok ( )
147
138
}
148
139
149
140
pub ( crate ) fn new_py_string < ' py > ( py : Python < ' py > , s : & str , cache_str : StringCacheMode ) -> Bound < ' py , PyString > {
0 commit comments