Commit graph

14617 commits

Author SHA1 Message Date
Serhiy Storchaka
e514b4a279
[3.13] gh-151695: Fix use-after-free of the curses screen encoding (GH-151696) (GH-151706) (GH-151723)
The module-global screen_encoding stored a borrowed pointer to the
encoding owned by the window returned by the first initscr() call.  That
window can be deallocated while unctrl() and ungetch(), which have no window
of their own, still use the pointer to encode non-ASCII characters.

Keep a private copy of the encoding instead.
(cherry picked from commit 551f8e16f8)
(cherry picked from commit 7b55e9a93e)

Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-19 10:30:35 +00:00
Serhiy Storchaka
805830831f
[3.13] gh-151623: Improve curses documentation and docstrings (GH-151625) (GH-151629) (GH-151630)
(cherry picked from commit 015cc42bc2)

Fix errors and clarify the curses, curses.panel and curses.ascii docs
against X/Open Curses and ncurses, and sync the affected docstrings.
(cherry picked from commit 65afcdd8df)
2026-06-18 09:51:51 +00:00
Miss Islington (bot)
502534ed0b
[3.13] gh-148441: Avoid integer overflow in Expat's CharacterDataHandler (GH-148904) (#149637)
* gh-148441: Avoid integer overflow in Expat's CharacterDataHandler (GH-148904)
(cherry picked from commit bc1be4f617)

Co-authored-by: ByteFlow <fakeshadow1337@gmail.com>
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>

* Apply suggestion from @picnixz

Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>

---------

Co-authored-by: ByteFlow <fakeshadow1337@gmail.com>
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
Co-authored-by: Victor Stinner <vstinner@python.org>
2026-06-15 15:52:47 +02:00
Miss Islington (bot)
5810def6dd
[3.13] gh-151403: Fix use-after-free when an argv item's __fspath__ mutates args (GH-151404) (#151447)
gh-151403: Fix use-after-free when an argv item's __fspath__ mutates args (GH-151404)

---------
(cherry picked from commit 6679ac07d8)

Co-authored-by: tonghuaroot (童话) <tonghuaroot@gmail.com>
Co-authored-by: tonghuaroot <23011166+tonghuaroot@users.noreply.github.com>
2026-06-13 14:33:13 -07:00
Miss Islington (bot)
7c3f0bd9b0
[3.13] gh-151126: Fix crash on unset memory error in ctypes.get_errno (GH-151382) (#151400)
gh-151126: Fix crash on unset memory error in `ctypes.get_errno` (GH-151382)
(cherry picked from commit 6b217ea90b)

Co-authored-by: sobolevn <mail@sobolevn.me>
2026-06-12 11:27:19 +00:00
Miss Islington (bot)
e812fe9bc4
[3.13] gh-151337: Avoid possible memory leak in _tkinter.c on Windows. (GH-151340) (GH-151381)
(cherry picked from commit 71805db429)

Co-authored-by: Ivy Xu <fakeshadow1337@gmail.com>
2026-06-11 20:13:33 +00:00
Miss Islington (bot)
5a92c742e6
[3.13] gh-151126: Fix missing memory error in os._path_splitroot (GH-151339) (#151362)
gh-151126: Fix missing memory error in `os._path_splitroot` (GH-151339)
(cherry picked from commit 10595b1cb7)

Co-authored-by: sobolevn <mail@sobolevn.me>
2026-06-11 16:43:15 +00:00
sobolevn
1d74300f9f
[3.13] gh-151126: Fix missing memory errors in _interpchannelsmodule.c (GH-151239) (#151338)
(cherry picked from commit 9fd1a125bc)
2026-06-11 13:31:10 +00:00
Victor Stinner
87b9729522
[3.13][3.14] gh-143988: Fix re-entrant mutation crashes in socket sendmsg/recvmsg_into (#143987) (#151251) (#151256)
[3.14] gh-143988: Fix re-entrant mutation crashes in socket sendmsg/recvmsg_into (#143987) (#151251)

gh-143988: Fix re-entrant mutation crashes in socket sendmsg/recvmsg_into (#143987)

Fix crashes in socket.sendmsg() and socket.recvmsg_into() that could
occur if buffer sequences are mutated re-entrantly during argument
parsing via __buffer__ protocol callbacks.

The bug occurs because:

1. PySequence_Fast() returns the original list object when the input
   is already a list (not a copy).
2. During iteration, PyObject_GetBuffer() triggers __buffer__
   callbacks which may clear the list.
3. Subsequent iterations access invalid memory (heap OOB read).

The fix replaces PySequence_Fast() with PySequence_Tuple() which
always creates a new tuple, ensuring the sequence cannot be mutated
during iteration.

(cherry picked from commit 896f7fdc7d)



(cherry picked from commit 632daaf5e9)

Co-authored-by: tonghuaroot (童话) <tonghuaroot@gmail.com>
Co-authored-by: tonghuaroot <23011166+tonghuaroot@users.noreply.github.com>
2026-06-10 19:04:04 +02:00
Victor Stinner
c40e6d6ebb
[3.13][3.15] gh-143008: Fix race re-initializing TextIOWrapper (#151203) (#151227)
[3.15] gh-143008: Fix race re-initializing TextIOWrapper (#151203)

__init__() changes multiple variables and may be called more than once
from multiple threads.

(cherry picked from commit 0318867acf)

Co-authored-by: Cody Maloney <cmaloney@users.noreply.github.com>
2026-06-10 09:40:14 +00:00
Serhiy Storchaka
52ffdeda1d
[3.13] gh-151130: Add more tests for PyWeakref_* C API (GH-151131) (GH-151141) (#151148)
(cherry picked from commit cb96d5ea4a)


(cherry picked from commit c3cd75afdf)
2026-06-09 22:24:39 +02:00
Miss Islington (bot)
04884519ce
[3.13] gh-151126: Add missing PyErr_NoMemory in _winapi module (GH-151154) (#151182)
gh-151126: Add missing `PyErr_NoMemory` in `_winapi` module (GH-151154)
(cherry picked from commit 8d94fa7b86)

Co-authored-by: sobolevn <mail@sobolevn.me>
2026-06-09 17:07:51 +00:00
Stan Ulbrych
fc9b11ff49
[3.13] gh-149018: Use XML_SetHashSalt16Bytes in pyexpat/_elementtree when possible (GH-149023)
(cherry picked from commit 24b8f12544)
2026-06-09 14:45:59 +00:00
Stan Ulbrych
19bc39127e
[3.13] gh-90949: expose Expat API to tune exponential expansion protections (GH-139368)
Expose the XML Expat 2.7.2 APIs to tune protections against
"billion laughs" [1] attacks.

The exposed APIs are available on Expat parsers, that is,
parsers created by `xml.parsers.expat.ParserCreate()`, as:

- `parser.SetBillionLaughsAttackProtectionActivationThreshold(threshold)`, and
- `parser.SetBillionLaughsAttackProtectionMaximumAmplification(max_factor)`.

This completes the work in f04bea44c3,
and improves the existing related documentation.

[1]: https://en.wikipedia.org/wiki/Billion_laughs_attack
(cherry picked from commit 666112376d)

Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
2026-06-09 15:23:22 +01:00
Stan Ulbrych
8e73feee5c
[3.13] gh-148801: Fix unbound C recursion in Element.__deepcopy__() (GH-148802) (#148843) 2026-06-08 20:14:48 +01:00
Miss Islington (bot)
619a12b2e5
[3.13] gh-150599: Prevent bz2 decompressor reuse after errors (GH-150600)
(cherry picked from commit 157a5df8cb)

Co-authored-by: Stan Ulbrych <stan@python.org>
2026-06-08 10:55:32 +01:00
Miss Islington (bot)
68250323fc
[3.13] gh-150913: Fix sqlite3.Blob validation for empty slice assignment (GH-150915) (GH-150925)
ass_subscript_slice() returned early when the computed slice length
was zero, bypassing validation performed for non-empty slices.
(cherry picked from commit fc9c4db130)

Co-authored-by: Jiseok CHOI <jiseok.dev@gmail.com>
2026-06-04 13:59:11 +00:00
Alex Waygood
7c5734c791
[3.13] gh-150319: Replace all documentation which says "See PEP 585" (#150325) (#150814)
gh-150319: Replace all documentation which says "See PEP 585" (#150325)

* Replace all documentation which says "See PEP 585"

The following classes in the stdlib get simple updates:

- array.array
- asyncio.Future
- asyncio.Task
- collections.defaultdict
- collections.deque
- contextvars.ContextVar
- contextvars.Token
- ctypes.Array
- os.DirEntry
- re.Match
- re.Pattern
- string.templatelib.Interpolation
- string.templatelib.Template
- types.MappingProxyType
- queue.SimpleQueue
- weakref.ref

The following classes are documented publicly as functions, and are
therefore updated internally (`__class_getitem__.__doc__`) but not in the
public docs:

- functools.partial
- itertools.chain

The following builtin types have updates to `__class_getitem__.__doc__`
but not to any documentation pages:

- BaseExceptionGroup
- coroutines (from generators)
- dict
- enumerate
- frozendict
- frozenset
- generators (and async generators)
- list
- memoryview
- set
- slice
- tuple

Special cases:

- union objects are now documented as "supporting class-level []",
  rather than anything to do with generics.

- Templates might be generic over a single type (union, in theory) or
  over a TypeVarTuple. As this is not currently fully settled, it is
  marked with a comment and a mild hint that it is a single type is used
  (namely, "type" is singular rather than "types", plural)

* Apply suggestions from code review



* Correct several class getitem docs

And expand the text for tuples.



* Add notes on generic typing of builtins

* Fix typo in tuple.__class_getitem__ docstring

* Typo fix: malformed refs

Fix `generic` links which weren't marked as `:ref:`.

* Strike unnecessary docs on generic-ness



* Apply suggestions from code review

These are applied at both the originally indicated locations and in the
corresponding docstring definitions.



* Update Doc/library/re.rst



* Update Objects/enumobject.c



* Remove tuple generic doc in 'stdtypes' page

This is covered in more detail in the cross-linked typing documentation.
The other copy of this documentation -- in the docstring for
`tuple.__class_getitem__` -- is left in place.

* Fix whitespace around new doc of generics

Per review, do not introduce or remove whitespace such that section
breaks are altered by the introduction of doc on various generic types.

In most cases, this is a removal of an extra line.

In one case (Arrays), it is the reintroduction of a line.

Additionally, two other minor fixes are included:
- incorrect indent on 'defaultdicts'
- make `mappingproxy.__class_getitem__.__doc__` consistent with other
  mapping type generic docs



* Move placement of memoryview generic note

Previous placement was at the end of the main docstring, which is
consistent with other types but places it after a section on various
methods (which makes it read somewhat inconsistently). Moving it up
helps resolve.



* Ensure sphinxdoc does not start sentences lowercase

Lowercase class names at the start of sentences are marked out with the
`class` role. In the case of `deque`, documentation already refers to
these as `Deques`, so this form is preferred.

* Apply suggestions from code review



* Fix line endings and wrap more tightly

Line endings fixed by pre-commit ; also re-wrapped the MappingProxyType
text which was too long.

* Use 'ContextVars' style in sphinx doc

---------

Co-authored-by: Stephen Rosen <sirosen@globus.org>
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
Co-authored-by: Jelle Zijlstra <906600+JelleZijlstra@users.noreply.github.com>
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
2026-06-02 22:26:33 +00:00
Petr Viktorin
ba785b88ad
[3.13] gh-149079: Fix O(n^2) canonical ordering in unicodedata.normalize() (GH-149080) (#150780)
Replace the insertion sort used for canonical ordering of combining
characters with a hybrid approach: insertion sort for short runs (< 20)
and counting sort for longer runs, reducing worst-case complexity from
O(n^2) to O(n). This prevents denial of service via crafted Unicode
strings with many combining characters in alternating CCC order.
(cherry picked from commit 991224b1e8)

Co-authored-by: Seth Larson <seth@python.org>
Co-authored-by: ch4n3-yoon <ch4n3.yoon@gmail.com>
Co-authored-by: Seokchan Yoon <13852925+ch4n3-yoon@users.noreply.github.com>
Co-authored-by: Stan Ulbrych <stan@python.org>
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
Co-authored-by: Maurycy Pawłowski-Wieroński <maurycy@maurycy.com>
2026-06-02 16:12:42 +00:00
Victor Stinner
b8ce8a38d1
[3.13] gh-149738: Fix segmentation fault bug in sqllite3 (#149754) (#150770)
gh-149738: Fix segmentation fault bug in sqllite3 (#149754)

Deleting the `row_factory` or `text_factory` attribute is no longer allowed.

(cherry picked from commit 60fdb3192b)

Co-authored-by: Sepehr Rasouli <sepehrrasouli06@gmail.com>
2026-06-02 14:52:30 +02:00
Miss Islington (bot)
ac0fe8a757
[3.13] gh-150372: Add missing null check on completer_word_break_characters in readline.c (GH-150251) (GH-150630)
(cherry picked from commit 56bd9ea676)

Co-authored-by: Thomas Kowalski <thom.kowa@gmail.com>
2026-05-31 14:59:05 +03:00
Sergey B Kirpichev
70a4e191e6
[3.13] Correct frexp() docs for zero and non-finite numbers (GH-149753) (GH-150654)
0.5 <= abs(m) < 1 is only true for finite nonzero numbers
(cherry picked from commit 5b5ffce05c)
2026-05-31 07:58:24 +00:00
Miss Islington (bot)
4d91835af5
[3.13] gh-150406: Check result of PyThread_allocate_lock() for netdb_lock (GH-150407) (GH-150618)
(cherry picked from commit 1e18c45495)

Co-authored-by: Thomas Kowalski <thom.kowa@gmail.com>
2026-05-30 19:56:46 +03:00
Serhiy Storchaka
68840510e3
[3.13] gh-150285: Fix too long docstrings in Argument Clinic code (GH-150338) (GH-150350) (GH-150473) (GH-150526)
(cherry picked from commit 49975a511f)
(cherry picked from commit cf73b17adf)
(cherry picked from commit 287c98f4cb)
2026-05-27 18:06:50 +00:00
Miss Islington (bot)
98a9ccbe39
[3.13] gh-149571: Fix the C implementation of Element.itertext() (GH-149929) (GH-150511)
It no longer emits text for comments and processing instructions.
(cherry picked from commit 7de4fcd445)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2026-05-27 10:49:54 +00:00
Serhiy Storchaka
96d66ac33b
[3.13] gh-150285: Fix too long docstrings in the io module (GH-150287) (GH-150458) (GH-150470)
(cherry picked from commit 36137e46a8)
(cherry picked from commit 160dc74122)
2026-05-26 10:29:28 +00:00
Serhiy Storchaka
b030936f33
[3.13] gh-150285: Fix too long docstrings in the sqlite3 module (GH-150290) (GH-150461) (GH-150471)
(cherry picked from commit 7168b02795)
(cherry picked from commit 0466560b31)
2026-05-26 10:11:11 +00:00
Serhiy Storchaka
56be4fb3d2
[3.13] gh-150285: Fix too long docstrings in the pyexpat module (GH-150294) (GH-150463) (GH-150468)
(cherry picked from commit ad1bb6c14c)
(cherry picked from commit 9da7923835)
2026-05-26 10:01:15 +00:00
Serhiy Storchaka
59cafbbeaf
[3.13] gh-150285: Fix too long docstrings in the curses module (GH-150286) (GH-150457) (GH-150469)
(cherry picked from commit e7f1216204)
(cherry picked from commit 4c0fe2d134)
2026-05-26 09:58:11 +00:00
Miss Islington (bot)
60d843777c
[3.13] gh-149449: Fix use-after-free in _PyUnicode_GetNameCAPI (GH-150323) (#150354)
gh-149449: Fix use-after-free in `_PyUnicode_GetNameCAPI` (GH-150323)
(cherry picked from commit 43c60ec2fd)

Co-authored-by: Pieter Eendebak <pieter.eendebak@gmail.com>
Co-authored-by: Kumar Aditya <kumaraditya@python.org>
2026-05-25 16:10:48 +05:30
Bénédikt Tran
e102378eca
[3.13] gh-142516: fix reference leaks in ssl.SSLContext objects (GH-143685) (GH-145075) (#148371)
Cherry picked from commits 3a2a686cc4
and 1decc7ee20 with minor amendments.
2026-05-24 11:43:03 +02:00
Shamil
e87baa8d24
[3.13] gh-142831: Fix use-after-free in json encoder during re-entrant mutation (gh-142851) (#150079)
gh-142831: Fix use-after-free in json encoder during re-entrant mutation (gh-142851)

User callbacks invoked during JSON encoding (e.g. the `default` callback or
a custom string encoder) can mutate or clear the dict or sequence being
encoded, invalidating borrowed references to items, keys, and values. Hold
strong references unconditionally while iterating.



(cherry picked from commit 235fa7244a)

Co-authored-by: Kumar Aditya <kumaraditya@python.org>
Co-authored-by: Gregory P. Smith <greg@krypto.org>
2026-05-19 20:33:22 -07:00
Miss Islington (bot)
23fcb4824f
[3.13] gh-149983: Fix PyErr_NoMemory call without GIL in winconsoleio.c (GH-149984) (GH-150112)
(cherry picked from commit 3d2aa899ba)

Co-authored-by: AN Long <aisk@users.noreply.github.com>
2026-05-19 23:11:28 +02:00
Armaan Vakharia
44f314933c
[3.13] gh-149590: Remove faulthandler_traverse (GH-150023) (#150087)
`faulthandler_traverse` visits Python objects owned by `_PyRuntime`, not
by the module instance. With multi-phase init allowing multiple module
instances, each instance's GC traversal decrements `gc_refs` on the same
runtime-owned objects, driving it negative when two instances are
collected simultaneously.
(cherry picked from commit 56737483c2)
2026-05-19 15:04:13 +00:00
AN Long
5531c77d33
[3.13] gh-149921: Fix reference leaks in _interpchannels and _interpqueues modules (GH-149922) (#149954)
(cherry picked from commit acefff95ea)
2026-05-17 13:36:32 +00:00
Victor Stinner
782880ba23
[3.13] gh-149707: Fix compiler warning in _ctypes_test on strchr() (#149791) (#149867)
gh-149707: Fix compiler warning in _ctypes_test on strchr() (#149791)

Change my_strchr() return type to "const char*" (add "const").

Fix the compiler warning:

Modules/_ctypes/_ctypes_test.c: In function 'my_strchr':
Modules/_ctypes/_ctypes_test.c:451:12: warning: return discards
'const' qualifier from pointer target type [-Wdiscarded-qualifiers]
  451 |     return strchr(s, c);
      |            ^~~~~~

When using C23, strchr(text, ch) return type is "const char*" if text
type is "const char*".

(cherry picked from commit 5465b69255)
2026-05-15 11:32:58 +00:00
Miss Islington (bot)
6fff3e4bc6
[3.13] gh-149698: Update bundled expat to 2.8.1 (GH-149699) (#149827)
(cherry picked from commit f1a47e79fb)

Co-authored-by: Stan Ulbrych <stan@python.org>
2026-05-14 15:24:39 +00:00
Miss Islington (bot)
ae31e50d3f
[3.13] gh-149017: Upgrade bundled Expat to 2.8.0 (GH-149020) (#149099)
(cherry picked from commit 005555a3f0)

Co-authored-by: Stan Ulbrych <stan@python.org>
2026-05-14 16:00:07 +01:00
Stan Ulbrych
ea8c3e028b
[3.13] gh-145376: Fix various reference leaks (GH-145377) (#148661)
(cherry picked from commit bd13cc09fa)

Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
2026-05-12 18:35:27 +00:00
Miss Islington (bot)
023ecbd01f
[3.13] gh-148093: Raise binascii.Error from binascii.a2b_uu() on empty input (GH-149077) (GH-149349)
Instead of reading past the end of the empty buffer.
(cherry picked from commit 0c6d2f64c0)

Co-authored-by: Maurycy Pawłowski-Wieroński <maurycy@maurycy.com>
2026-05-04 10:06:25 +00:00
Serhiy Storchaka
0fd4fd4496
[3.13] gh-148529: Minor improvements of the struct module documentation (GH-148565) (GH-149072)
* Document that 's' and 'p' accept bytes and bytearray.
* Fix some footnotes.
* Clarify that "string" is a byte string.
* Fix the module docstring.
(cherry picked from commit 3e5a3cb2bd)
2026-04-27 20:22:47 +00:00
Stan Ulbrych
feafd5f69c
[3.13] gh-148735: Fix a UAF in Element.findtext() (GH-148738) (#148923)
(cherry picked from commit 0469e6d38d)
2026-04-25 10:38:14 +01:00
Miss Islington (bot)
813498411a
[3.13] gh-148484: Fix memory leak of iterator in array.array constructor (GH-148523) (GH-148679)
(cherry picked from commit afde75664e)

Co-authored-by: Gleb Popov <gvpopov.dev@gmail.com>
2026-04-23 16:00:47 +02:00
Miss Islington (bot)
95633d2aad
[3.13] gh-148808: Add boundary check to asyncio.AbstractEventLoop.sock_recvf… (GH-148809) (#148836)
gh-148808: Add boundary check to asyncio.AbstractEventLoop.sock_recvf… (GH-148809)
(cherry picked from commit 1274766d3c)

Co-authored-by: Seth Larson <seth@python.org>
2026-04-21 21:56:37 +05:30
Miss Islington (bot)
c3cf71c336
[3.13] gh-148395: Fix a possible UAF in {LZMA,BZ2,_Zlib}Decompressor (GH-148396) (#148479)
gh-148395: Fix a possible UAF in `{LZMA,BZ2,_Zlib}Decompressor` (GH-148396)

Fix dangling input pointer after `MemoryError` in _lzma/_bz2/_ZlibDecompressor.decompress
(cherry picked from commit 8fc66aef6d)

Co-authored-by: Stan Ulbrych <stan@python.org>
2026-04-13 01:35:24 +00:00
Miss Islington (bot)
8e369d3645
[3.13] gh-145105: Fix crash in csv.reader with re-entrant iterator (GH-145106) (#148405)
gh-145105: Fix crash in csv.reader with re-entrant iterator (GH-145106)

When a custom iterator calls next() on the same csv.reader from
within __next__, the inner iteration sets self->fields to NULL.
The outer iteration then crashes in parse_save_field() by passing
NULL to PyList_Append.

Add a guard after PyIter_Next() to detect that fields was set to
NULL by a re-entrant call, and raise csv.Error instead of crashing.
(cherry picked from commit 20994b1809)

Co-authored-by: Ramin Farajpour Cami <ramin.blackhat@gmail.com>
2026-04-11 22:44:45 +00:00
Miss Islington (bot)
7fc8507f3d
[3.13] gh-146613: Fix re-entrant use-after-free in itertools._grouper (GH-147962) (#148011)
gh-146613: Fix re-entrant use-after-free in `itertools._grouper` (GH-147962)
(cherry picked from commit fc7a188fe7)

Co-authored-by: Ma Yukun <68433685+TheSkyC@users.noreply.github.com>
2026-04-07 12:24:54 +02:00
Ramin Farajpour Cami
4c8d6f4f68
[3.13] gh-144984: Fix crash in Expat's ExternalEntityParserCreate error paths (GH-144992) (#146142)
* gh-144984: Fix crash in Expat's `ExternalEntityParserCreate` error paths (#144992)

Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>

* gh-144984: Skip test under tracerefs (GH-146218)

---------

Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
Co-authored-by: Petr Viktorin <encukou@gmail.com>
2026-04-07 12:22:22 +02:00
Miss Islington (bot)
df89a705d0
[3.13] gh-145883: Fix two heap-buffer-overflows in _zoneinfo (GH-145885) (#148086)
(cherry picked from commit fe9befc1ca)

Co-authored-by: Stan Ulbrych <stan@python.org>
2026-04-04 17:14:19 +01:00
Victor Stinner
01af34a364
[3.13] gh-143050: Correct PyLong_FromString() to use _PyLong_Negate() (#145901) (#147437)
The long_from_string_base() might return a small integer, when the
_pylong.py is used to do conversion.  Hence, we must be careful here to
not smash it "small int" bit by using the _PyLong_FlipSign().

Co-authored-by: Victor Stinner <vstinner@python.org>
(cherry picked from commit db5936c5b8)

Co-authored-by: Sergey B Kirpichev <skirpichev@gmail.com>
2026-03-31 17:06:38 +02:00