Commit graph

13491 commits

Author SHA1 Message Date
Miss Islington (bot)
fc7e67f51a
[3.12] bpo-37013: Fix the error handling in socket.if_indextoname() (GH-13503) (GH-112597)
* Fix a crash when pass UINT_MAX.
* Fix an integer overflow on 64-bit non-Windows platforms.
(cherry picked from commit 0daf555c6f)

Co-authored-by: Zackery Spytz <zspytz@gmail.com>
2023-12-25 20:55:08 +02:00
Miss Islington (bot)
15ea4a4292
[3.12] gh-111784: Fix two segfaults in the elementtree module (GH-113405) (GH-113446)
First fix resolve situation when pyexpat module (which contains expat_CAPI
capsule) deallocates before _elementtree, so we need to hold a strong
reference to pyexpat module to.

Second fix resolve situation when module state is deallocated before
deallocation of XMLParser instances, which uses module state to clear
some stuff.
(cherry picked from commit 894f0e573d)

Co-authored-by: Kirill Podoprigora <kirill.bast9@mail.ru>
2023-12-24 09:25:05 +00:00
Miss Islington (bot)
bc23ad4b99
[3.12] bpo-36796: Clean the error handling in _testcapimodule.c (GH-13085) (GH-113132)
(cherry picked from commit a723a13bf1)

Co-authored-by: Zackery Spytz <zspytz@gmail.com>
2023-12-14 19:39:57 +00:00
Miss Islington (bot)
9f5209f3c2
[3.12] gh-111049: Fix crash during garbage collection of the BytesIO buffer object (GH-111221) (GH-113096)
(cherry picked from commit bb36f72efc)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2023-12-14 10:28:57 +00:00
Diego Russo
f941ecfffa
[3.12] gh-110190: Fix ctypes structs with array on Arm (#112604) (#112767)
Set MAX_STRUCT_SIZE to 32 in stgdict.c when on Arm platforms.
This because on Arm platforms structs with at most 4 elements of any
floating point type values can be passed through registers. If the type
is double the maximum size of the struct is 32 bytes.
On x86-64 Linux, it's maximum 16 bytes hence we need to differentiate.

(cherry picked from commit bc68f4a4ab)
2023-12-06 16:57:34 +01:00
Miss Islington (bot)
85bbfa8a4b
[3.12] gh-112334: Restore subprocess's use of vfork() & fix extra_groups=[] behavior (GH-112617) (#112731)
Restore `subprocess`'s intended use of `vfork()` by default for performance on Linux;
also fixes the behavior of `extra_groups=[]` which was unintentionally broken in 3.12.0:

Fixed a performance regression in 3.12's :mod:`subprocess` on Linux where it
would no longer use the fast-path ``vfork()`` system call when it could have
due to a logic bug, instead falling back to the safe but slower ``fork()``.

Also fixed a security bug introduced in 3.12.0.  If a value of ``extra_groups=[]``
was passed to :mod:`subprocess.Popen` or related APIs, the underlying
``setgroups(0, NULL)`` system call to clear the groups list would not be made
in the child process prior to ``exec()``.

The security issue was identified via code inspection in the process of
fixing the first bug.  Thanks to @vain for the detailed report and
analysis in the initial bug on Github.

(cherry picked from commit 9fe7655c6c)

+ Reword NEWS for the bugfix/security release. (mentions the assigned CVE number)

Co-authored-by: Gregory P. Smith [Google LLC] <greg@krypto.org>
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2023-12-04 23:33:59 +00:00
Miss Islington (bot)
88ec2a4fef
[3.12] gh-105967: Work around a macOS bug, limit zlib C library crc32 API calls to 1gig (GH-112615) (#112724)
gh-105967: Work around a macOS bug, limit zlib C library crc32 API calls to 1gig (GH-112615)

Work around a macOS bug, limit zlib crc32 calls to 1GiB.

Without this, `zlib.crc32` and `binascii.crc32` could produce incorrect
results on multi-gigabyte inputs depending on the macOS version's Apple
supplied zlib implementation.
(cherry picked from commit 4eddb4c9d9)

Co-authored-by: Gregory P. Smith <greg@krypto.org>
2023-12-04 20:29:23 +00:00
Miss Islington (bot)
55896f470b
[3.12] gh-109786: Fix leaks and crash when re-enter itertools.pairwise.__next__() (GH-109788) (GH-112699)
(cherry picked from commit 6ca9d3e017)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2023-12-04 12:15:41 +00:00
Miss Islington (bot)
bfad9578d1
[3.12] gh-112678: Declare Tkapp_CallDeallocArgs() as static (GH-112679) (GH-112690)
(cherry picked from commit 23e001fa9f)

Co-authored-by: Christopher Chavez <chrischavez@gmx.us>
2023-12-04 08:21:28 +00:00
Miss Islington (bot)
8f43250c91
[3.12] Add more C API tests (GH-112522) (GH-112525)
Add tests for PyObject_Str(), PyObject_Repr(), PyObject_ASCII() and
PyObject_Bytes().
(cherry picked from commit e0449b9a7f)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2023-11-29 22:02:57 +02:00
Miss Islington (bot)
e28722e772
[3.12] gh-109802: Increase test coverage for complexobject.c (GH-112452) (GH-112489)
(cherry picked from commit f14d741daa)

Co-authored-by: Sergey B Kirpichev <skirpichev@gmail.com>
2023-11-28 08:33:44 +00:00
Miss Islington (bot)
7225a014de
[3.12] gh-112105: Make completer delims work on libedit (gh-112106) (gh-112487)
gh-112105: Make completer delims work on libedit (gh-112106)
(cherry picked from commit 2df26d8348)

Co-authored-by: Tian Gao <gaogaotiantian@hotmail.com>
2023-11-28 06:42:54 +00:00
Eric Snow
0122b4d7c9
[3.12] gh-105716: Support Background Threads in Subinterpreters Consistently (gh-109921) (gh-110707)
The existence of background threads running on a subinterpreter was preventing interpreters from getting properly destroyed, as well as impacting the ability to run the interpreter again. It also affected how we wait for non-daemon threads to finish.

We add PyInterpreterState.threads.main, with some internal C-API functions.

(cherry-picked from commit 1dd9dee45d)
2023-11-27 19:01:05 -07:00
Eric Snow
313554457e
[3.12] gh-109853: Fix sys.path[0] For Subinterpreters (gh-109994) (gh-110701)
This change makes sure sys.path[0] is set properly for subinterpreters.  Before, it wasn't getting set at all.

This change does not address the broader concerns from gh-109853.

(cherry-picked from commit a040a32ea2)
2023-11-27 22:21:12 +00:00
Eric Snow
592a849fdf
[3.12] gh-76785: Use Pending Calls When Releasing Cross-Interpreter Data (gh-109556) (gh-112288)
This fixes some crashes in the _xxinterpchannels module, due to a race between interpreters.
(cherry picked from commit fd7e08a6f3)
2023-11-27 14:49:48 -07:00
Miss Islington (bot)
4463d2e018
[3.12] bpo-41422: Visit the Pickler's and Unpickler's memo in tp_traverse (GH-21664) (GH-112464)
(cherry picked from commit 967f2a3052)

Co-authored-by: kale-smoothie <34165060+kale-smoothie@users.noreply.github.com>
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2023-11-27 18:42:48 +00:00
Miss Islington (bot)
46047bb12b
[3.12] gh-112438: Fix support of format units with the "e" prefix in nested tuples in PyArg_Parse (gh-112439) (GH-112460)
(cherry picked from commit 4eea1e8236)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2023-11-27 17:57:30 +00:00
Mark Dickinson
42df73652d
[3.12] gh-112358: Fix Python 3.12 regression with subclassing struct.Struct (GH-112424) (#112426)
* [3.12] gh-112358: Fix Python 3.12 regression with subclassing struct.Struct. (GH-112424)

Revert commit c8c0afc713 (PR GH-94532),
which moved `struct.Struct` initialisation from `Struct.__init__` to `Struct.__new__`.
This caused issues with code in the wild that subclasses `struct.Struct`..
(cherry picked from commit 9fe60340d7)

Co-authored-by: Mark Dickinson <dickinsm@gmail.com>

* Remove unrelated test
2023-11-27 08:25:06 +00:00
Victor Stinner
1445d77282
[3.12] gh-111942: Fix SystemError in the TextIOWrapper constructor (GH-112061) (GH-112089)
In non-debug more the check for the "errors" argument is skipped,
and then PyUnicode_AsUTF8() can fail, but its result was not checked.

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

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2023-11-15 15:55:46 +02:00
Miss Islington (bot)
24216d0530
[3.12] gh-111942: Fix crashes in TextIOWrapper.reconfigure() (GH-111976) (GH-112058)
* Fix crash when encoding is not string or None.
* Fix crash when both line_buffering and write_through raise exception
  when converted ti int.
* Add a number of tests for constructor and reconfigure() method
  with invalid arguments.

(cherry picked from commit ee06fffd38)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2023-11-14 16:15:10 +00:00
Miss Islington (bot)
13ca1f02a4
[3.12] gh-111777: Fix assertion errors on incorrectly still-tracked GC object destruction (GH-111778) (#111989)
gh-111777: Fix assertion errors on incorrectly still-tracked GC object destruction (GH-111778)

In PyObject_GC_Del, in Py_DEBUG mode, when warning about GC objects that
were not properly untracked before starting destruction, take care to
untrack the object _before_ warning, to avoid triggering a GC run and
causing the problem the code tries to warn about. Also make sure to save and
restore any pending exceptions, which the warning would otherwise clobber or
trigger an assertion error on.
(cherry picked from commit ce6a533c4b)

Co-authored-by: T. Wouters <thomas@python.org>
2023-11-12 00:44:24 +00:00
Miss Islington (bot)
1afc4dc3e6
[3.12] Fix undefined behaviour in datetime.time.fromisoformat() (GH-111982) (#111992)
Fix undefined behaviour in datetime.time.fromisoformat() (GH-111982)

Fix undefined behaviour in datetime.time.fromisoformat() when parsing a string without a timezone. 'tzoffset' is not assigned to by parse_isoformat_time if it returns 0, but time_fromisoformat then passes tzoffset to another function, which is undefined behaviour (even if the function in question does not use the value).
(cherry picked from commit 21615f77b5)

Co-authored-by: T. Wouters <thomas@python.org>
2023-11-12 00:39:03 +00:00
Gregory P. Smith
0f7671cc69
[3.12] gh-110395: invalidate open kqueues after fork (GH-110517) (#111745)
* [3.12] gh-110395: invalidate open kqueues after fork (GH-110517)

Invalidate open select.kqueue instances after fork as the fd will be invalid in the child.
(cherry picked from commit a6c1c04d4d)

Co-authored-by: Davide Rizzo <sorcio@gmail.com>

* move assert to after the child dying

this is in `main` via https://github.com/python/cpython/pull/111816/files
2023-11-11 09:21:52 -08:00
Miss Islington (bot)
3bd8b74330
[3.12] gh-111841: Fix os.putenv() and os.unsetenv() with embedded NUL on Windows (GH-111842) (GH-111966)
(cherry picked from commit 0b06d2482d)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2023-11-11 08:02:08 +00:00
Miss Islington (bot)
2c6000cba4
[3.12] gh-111251: Fix error checking in _blake2 module init (GH-111252) (#111297)
Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
2023-11-10 14:58:00 +00:00
Brett Cannon
5a8e6f8bcc
[3.12] GH-111804: Drop posix.fallocate() under WASI (GH-111869) (GH-111919)
GH-111804: Drop posix.fallocate() under WASI (GH-111869)

Drop posix.fallocate() under WASI.

The underlying POSIX function, posix_fallocate(), was found to vary too
much between implementations to remain in WASI. As such, while it was
available in WASI preview1, it's been dropped in preview2.
2023-11-09 15:35:51 -08:00
Miss Islington (bot)
759168a2a9
[3.12] gh-111495: Add tests for PyList C API (GH-111562) (GH-111861)
(cherry picked from commit a3903c8ec8)

Signed-off-by: kalyanr <kalyan.ben10@live.com>
Co-authored-by: Kalyan <kalyan.ben10@live.com>
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
Co-authored-by: Victor Stinner <vstinner@python.org>
2023-11-08 18:10:13 +00:00
Miss Islington (bot)
c4e524c3f2
[3.12] gh-101180: Fix a bug where iso2022_jp_3 and iso2022_jp_2004 codecs read out of bounds (gh-111695) (gh-111769)
gh-101180: Fix a bug where iso2022_jp_3 and iso2022_jp_2004 codecs read out of bounds (gh-111695)
(cherry picked from commit c8faa3568a)

Co-authored-by: Masayuki Moriyama <masayuki.moriyama@miraclelinux.com>
2023-11-06 11:31:58 +00:00
Miss Islington (bot)
e0c2bf4672
[3.12] gh-111495: Add tests for PyComplex C API (GH-111591) (GH-111753)
(cherry picked from commit 24b5cbd3dc)

Co-authored-by: Sergey B Kirpichev <skirpichev@gmail.com>
2023-11-05 08:12:57 +00:00
Miss Islington (bot)
fef32a1d08
[3.12] gh-111495: Add tests for PyFloat C API (GH-111624) (GH-111752)
(cherry picked from commit b452202a11)

Co-authored-by: Sergey B Kirpichev <skirpichev@gmail.com>
2023-11-05 10:01:31 +02:00
Miss Islington (bot)
99f0dd88b1
[3.12] gh-111253: Fix error checking in _socket module init (GH-111254) (#111299)
gh-111253: Fix error checking in _socket module init (GH-111254)
(cherry picked from commit 3052c098ca)

Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
2023-11-01 21:01:28 +01:00
Miss Islington (bot)
a94bdc2459
[3.12] gh-111295: Fix error checking in time extension module init (GH-111296) (#111300)
gh-111295: Fix error checking in time extension module init (GH-111296)

Introduce ADD_INT macro wrapper for PyModule_AddIntConstant()
(cherry picked from commit 81b03e7810)

Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
2023-11-01 20:58:02 +01:00
Miss Islington (bot)
f1087855e2
[3.12] gh-111495: Add tests for PyBytes and PyByteArray C API (GH-111496) (GH-111607)
(cherry picked from commit 97b3cd38d1)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2023-11-01 18:23:39 +00:00
Victor Stinner
d3d2cfead7
[3.12] gh-110968: Py_MOD_PER_INTERPRETER_GIL_SUPPORTED was added to 3.12 (#111588)
Constants like Py_MOD_PER_INTERPRETER_GIL_SUPPORTED were only added
to the limited C API version 3.12 and newer.
2023-11-01 18:13:31 +01:00
Sergey B Kirpichev
9619e517d4
[3.12] gh-111495: add stub files for C API test modules (GH-111586) (GH-111592)
This is to reduce merge conflicts (Modules/Setup.stdlib.in) for
subsequent pull requests for the issue.
(cherry picked from commit 33ed5fa69d)
2023-11-01 09:43:56 +02:00
Miss Islington (bot)
748bc48648
[3.12] gh-108082: C API: Add tests for PyErr_WriteUnraisable() (GH-111455) (GH-111507)
Also document the behavior when called with NULL.
(cherry picked from commit bca3305429)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2023-10-30 17:36:00 +00:00
Miss Islington (bot)
c3f75b757f
[3.12] gh-111342: fix typo in math.sumprod (GH-111416) (gh-111419) 2023-10-28 05:27:33 +00:00
Miss Islington (bot)
e25d8b40cd
GH-111293: Fix DirEntry.inode dropping higher bits on Windows (GH-111294)
(cherry picked from commit b468538d35)

Co-authored-by: zcxsythenew <30565051+zcxsythenew@users.noreply.github.com>
2023-10-26 17:08:41 +00:00
Miss Islington (bot)
45c0b38880
[3.12] gh-111174: Fix crash in getbuffer() called repeatedly for empty BytesIO (GH-111210) (GH-111314)
(cherry picked from commit 9da98c0d9a)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2023-10-25 11:25:31 +00:00
Serhiy Storchaka
54e93d36d0
[3.12] gh-111065: Add more tests for the C API with the PySys_ prefix (GH-111067) (GH-111305)
* Move existing tests for PySys_GetObject() and PySys_SetObject() into
  specialized files.
* Add test for PySys_GetXOptions() using _testcapi.
* Add tests for PySys_FormatStdout(), PySys_FormatStderr(),
  PySys_WriteStdout() and PySys_WriteStderr() using ctypes.

(cherry picked from commit b2ba298527)
2023-10-25 09:10:03 +00:00
Miss Islington (bot)
552ceb2d0f
[3.12] gh-110572: Fix potential leaks in test_*_code in _testcapi/getargs.c (GH-110573) (GH-111161)
(cherry picked from commit f71cd5394e)

Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
2023-10-21 12:57:22 +00:00
Miss Islington (bot)
dfc8d7ac93
gh-110913: Fix WindowsConsoleIO chunking of UTF-8 text (GH-111007)
(cherry picked from commit 11312eae6e)

Co-authored-by: Tamás Hegedűs <sorgloomer@users.noreply.github.com>
2023-10-20 12:37:31 +00:00
Serhiy Storchaka
72b0f0eaf5
[3.12] bpo-42663: Fix parsing TZ strings in zoneinfo module (GH-23825) (GH-110882)
zipinfo now supports the full range of values in the TZ string
determined by RFC 8536 and detects all invalid formats.
Both Python and C implementations now raise exceptions of the same
type on invalid data.
(cherry picked from commit ab08ff7882)
2023-10-15 10:59:19 +03:00
Serhiy Storchaka
7c3e8e5af0
[3.12] gh-110628: Add tests for PyLong C API (GH-110629) (GH-110854)
(cherry picked from commit 9d40ebf190)
2023-10-14 10:20:24 +03:00
Miss Islington (bot)
a2cc9a4c3a
[3.12] gh-109747: Improve errors for unsupported look-behind patterns (GH-109859) (GH-110859)
Now re.error is raised instead of OverflowError or RuntimeError for
too large width of look-behind pattern.

The limit is increased to 2**32-1 (was 2**31-1).
(cherry picked from commit e2b3d831fd)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2023-10-14 06:42:19 +00:00
Miss Islington (bot)
1c44f881c7
[3.12] gh-110815: Improve tests for PyArg_ParseTupleAndKeywords() (GH-110817) (GH-110825)
(cherry picked from commit 548ce0923b)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2023-10-13 13:41:43 +00:00
Miss Islington (bot)
ca971d12ed
[3.12] gh-84489: C API: Add tests for Py_BuildValue() (GH-110596) (GH-110680)
(cherry picked from commit 5c6e85480a)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2023-10-11 11:12:39 +03:00
Miss Islington (bot)
c1e8e90915
[3.12] gh-110590: Fix a bug where _sre.compile would overwrite exceptions (GH-110591) (#110613)
TypeError would be overwritten by OverflowError
if 'code' param contained non-ints.
(cherry picked from commit 344d3a222a)

Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
2023-10-10 10:55:21 +00:00
Miss Islington (bot)
190660abe9
[3.12] gh-78469: Declare missing sethostname for Solaris 10 (GH-109447) (#110580)
Add OS version specific macro for Solaris: Py_SUNOS_VERSION.
(cherry picked from commit 3b1580af07)

Co-authored-by: Jakub Kulík <Kulikjak@gmail.com>
2023-10-10 09:26:36 +00:00
Miss Islington (bot)
53122bcf82
[3.12] gh-109191: Fix build with newer editline (gh-110239) (gh-110562)
gh-109191: Fix build with newer editline (gh-110239)
(cherry picked from commit f4cb0d27cc)

Co-authored-by: Bo Anderson <mail@boanderson.me>
2023-10-09 23:01:00 +09:00