]> git.ipfire.org Git - thirdparty/Python/cpython.git/commit
gh-147988: Initialize digits in long_alloc() in debug mode (#147989)
authorVictor Stinner <vstinner@python.org>
Thu, 2 Apr 2026 11:55:34 +0000 (13:55 +0200)
committerGitHub <noreply@github.com>
Thu, 2 Apr 2026 11:55:34 +0000 (11:55 +0000)
commitc1a4112c225e22d2707ff0a711353227e64f6fb5
treefef5543240dc7522f1457fd1cd267ba60f36f890
parenta86963b3e2afa854132968f0d4bffe2ed2c87fe0
gh-147988: Initialize digits in long_alloc() in debug mode (#147989)

When Python is built in debug mode:

* long_alloc() now initializes digits with a pattern to detect usage of
  uninitialized digits.
* _PyLong_CompactValue() now makes sure that the digit is zero when the
  sign is zero.
* PyLongWriter_Finish() now raises SystemError if it detects uninitialized
  digits

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
Include/cpython/longintrepr.h
Lib/test/test_capi/test_long.py
Modules/_testcapi/long.c
Objects/longobject.c