File tree Expand file tree Collapse file tree 3 files changed +5
-18
lines changed
Expand file tree Collapse file tree 3 files changed +5
-18
lines changed Original file line number Diff line number Diff line change 11Removed use of the CPython-internal ` _PyUnicode_COMPACT_DATA ` symbol from PyO3's FFI test suite.
22Deprecated ` _PySet_NextEntry ` in ` pyo3-ffi ` ; it is a CPython-internal API with no stability guarantee.
3+ Deprecated ` _PyLong_NumBits ` in ` pyo3-ffi ` and replaced its internal use with ` int.bit_length() ` for Python < 3.13 builds.
Original file line number Diff line number Diff line change @@ -85,6 +85,7 @@ extern_libpython! {
8585#[ cfg( not( Py_LIMITED_API ) ) ]
8686extern_libpython ! {
8787 #[ cfg_attr( PyPy , link_name = "_PyPyLong_NumBits" ) ]
88+ #[ deprecated( note = "`_PyLong_NumBits` is a CPython-internal API; use `PyLong_AsNativeBytes` on Python 3.13+ or `int.bit_length()` instead" ) ]
8889 pub fn _PyLong_NumBits( obj: * mut PyObject ) -> size_t;
8990}
9091
Original file line number Diff line number Diff line change @@ -318,24 +318,9 @@ fn int_to_py_bytes<'py>(
318318#[ inline]
319319#[ cfg( any( not( Py_3_13 ) , Py_LIMITED_API ) ) ]
320320fn int_n_bits ( long : & Bound < ' _ , PyInt > ) -> PyResult < usize > {
321- let py = long. py ( ) ;
322- #[ cfg( not( Py_LIMITED_API ) ) ]
323- {
324- // fast path
325- let n_bits = unsafe { crate :: ffi:: _PyLong_NumBits ( long. as_ptr ( ) ) } ;
326- if n_bits == ( -1isize as usize ) {
327- return Err ( crate :: PyErr :: fetch ( py) ) ;
328- }
329- Ok ( n_bits)
330- }
331-
332- #[ cfg( Py_LIMITED_API ) ]
333- {
334- // slow path
335- use crate :: types:: PyAnyMethods ;
336- long. call_method0 ( crate :: intern!( py, "bit_length" ) )
337- . and_then ( |any| any. extract ( ) )
338- }
321+ use crate :: types:: PyAnyMethods ;
322+ long. call_method0 ( crate :: intern!( long. py( ) , "bit_length" ) )
323+ . and_then ( |any| any. extract ( ) )
339324}
340325
341326#[ cfg( test) ]
You can’t perform that action at this time.
0 commit comments