Skip to content
Prev Previous commit
Next Next commit
Merge branch 'main' into stdint
  • Loading branch information
vstinner committed Aug 27, 2024
commit 050f41512f4a37e3d05dbf412b3801205e29e2b3
112 changes: 56 additions & 56 deletions Doc/data/stable_abi.dat

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 14 additions & 0 deletions Doc/whatsnew/3.14.rst
Original file line number Diff line number Diff line change
Expand Up @@ -457,6 +457,20 @@ New Features

(Contributed by Victor Stinner in :gh:`119182`.)

* Add :c:func:`PyIter_NextItem` to replace :c:func:`PyIter_Next`,
which has an ambiguous return value.
(Contributed by Irit Katriel and Erlend Aasland in :gh:`105201`.)

* :c:func:`Py_Finalize` now deletes all interned strings. This
is backwards incompatible to any C-Extension that holds onto an interned
string after a call to :c:func:`Py_Finalize` and is then reused after a
call to :c:func:`Py_Initialize`. Any issues arising from this behavior will
normally result in crashes during the exectuion of the subsequent call to
:c:func:`Py_Initialize` from accessing uninitialized memory. To fix, use
an address sanitizer to identify any use-after-free coming from
an interned string and deallocate it during module shutdown.
(Contribued by Eddie Elizondo in :gh:`113601`.)

* Add new functions to convert C ``<stdint.h>`` numbers from/to Python
:class:`int`:

Expand Down
26 changes: 4 additions & 22 deletions Lib/test/test_capi/test_long.py
Original file line number Diff line number Diff line change
Expand Up @@ -220,23 +220,6 @@ def test_long_asint(self):
from _testcapi import INT_MIN, INT_MAX
self.check_long_asint(PyLong_AsInt, INT_MIN, INT_MAX)

def check_long_asint(self, long_asint, min_val, max_val):
# round trip (object -> C integer -> object)
for value in (min_val, max_val, -1, 0, 1, 1234):
with self.subTest(value=value):
self.assertEqual(long_asint(value), value)
self.assertEqual(long_asint(IntSubclass(value)), value)
self.assertEqual(long_asint(Index(value)), value)

self.assertEqual(long_asint(MyIndexAndInt()), 10)

self.assertRaises(OverflowError, long_asint, min_val - 1)
self.assertRaises(OverflowError, long_asint, max_val + 1)
self.assertRaises(TypeError, long_asint, 1.0)
self.assertRaises(TypeError, long_asint, b'2')
self.assertRaises(TypeError, long_asint, '3')
self.assertRaises(SystemError, long_asint, NULL)

def test_long_aslong(self):
# Test PyLong_AsLong() and PyLong_FromLong()
aslong = _testlimitedcapi.pylong_aslong
Expand Down Expand Up @@ -277,7 +260,8 @@ def test_long_asunsignedlong(self):
# Test PyLong_AsUnsignedLong() and PyLong_FromUnsignedLong()
asunsignedlong = _testlimitedcapi.pylong_asunsignedlong
from _testcapi import ULONG_MAX
self.check_long_asunsignedint(asunsignedlong, ULONG_MAX)
self.check_long_asint(asunsignedlong, 0, ULONG_MAX,
use_index=False)

def test_long_asunsignedlongmask(self):
# Test PyLong_AsUnsignedLongMask()
Expand Down Expand Up @@ -675,28 +659,26 @@ def test_long_asint32(self):
# Test PyLong_AsInt32() and PyLong_FromInt32()
to_int32 = _testlimitedcapi.pylong_asint32
from _testcapi import INT32_MIN, INT32_MAX
self.check_long_asint(to_int32, INT32_MIN, INT32_MAX)
self.check_long_asint(to_int32, INT32_MIN, INT32_MAX, use_index=False)

def test_long_asint64(self):
# Test PyLong_AsInt64() and PyLong_FromInt64()
as_int64 = _testlimitedcapi.pylong_asint64
from _testcapi import INT64_MIN, INT64_MAX
self.check_long_asint(as_int64, INT64_MIN, INT64_MAX)
self.check_long_asint(as_int64, INT64_MIN, INT64_MAX, use_index=False)

def test_long_asuint32(self):
# Test PyLong_AsUInt32() and PyLong_FromUInt32()
as_uint32 = _testlimitedcapi.pylong_asuint32
from _testcapi import UINT32_MAX
self.check_long_asunsignedint(as_uint32, UINT32_MAX,
use_index=True,
negative_value_error=True)

def test_long_asuint64(self):
# Test PyLong_AsUInt64() and PyLong_FromUInt64()
as_uint64 = _testlimitedcapi.pylong_asuint64
from _testcapi import UINT64_MAX
self.check_long_asunsignedint(as_uint64, UINT64_MAX,
use_index=True,
negative_value_error=True)

if __name__ == "__main__":
Expand Down
2 changes: 2 additions & 0 deletions Misc/stable_abi.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2508,6 +2508,8 @@

[function.Py_TYPE]
added = '3.14'
[function.PyIter_NextItem]
added = '3.14'
[function.PyLong_FromInt32]
added = '3.14'
[function.PyLong_FromUInt32]
Expand Down
You are viewing a condensed version of this merge commit. You can view the full changes here.