Commit graph

13516 commits

Author SHA1 Message Date
Miss Islington (bot)
de347c0207
[3.12] gh-95782: Fix io.BufferedReader.tell() etc. being able to return offsets < 0 (GH-99709) (GH-115599)
lseek() always returns 0 for character pseudo-devices like
`/dev/urandom` (for other non-regular files, e.g. `/dev/stdin`, it
always returns -1, to which CPython reacts by raising appropriate
exceptions). They are thus technically seekable despite not having seek
semantics.

When calling read() on e.g. an instance of `io.BufferedReader` that
wraps such a file, `BufferedReader` reads ahead, filling its buffer,
creating a discrepancy between the number of bytes read and the internal
`tell()` always returning 0, which previously resulted in e.g.
`BufferedReader.tell()` or `BufferedReader.seek()` being able to return
positions < 0 even though these are supposed to be always >= 0.

Invariably keep the return value non-negative by returning
max(former_return_value, 0) instead, and add some corresponding tests.
(cherry picked from commit 26800cf25a)

Co-authored-by: 6t8k <58048945+6t8k@users.noreply.github.com>
2024-02-17 14:56:00 +02:00
Miss Islington (bot)
14930acf5a
[3.12] gh-115399: Upgrade bundled libexpat to 2.6.0 (GH-115431) (#115469)
gh-115399: Upgrade bundled libexpat to 2.6.0 (GH-115431)
(cherry picked from commit 4b2d1786cc)

Co-authored-by: Seth Michael Larson <seth@python.org>
2024-02-14 14:14:34 -08:00
Miss Islington (bot)
d25894332a
[3.12] gh-115243: Fix crash in deque.index() when the deque is concurrently modified (GH-115247) (GH-115465)
(cherry picked from commit 671360161f)

Co-authored-by: kcatss <kcats9731@gmail.com>
2024-02-14 17:17:58 +00:00
John Belmonte
09c98e4633
[3.12] gh-114563: C decimal falls back to pydecimal for unsupported format strings (GH-114879) (GH-115353)
Immediate merits:
* eliminate complex workarounds for 'z' format support
  (NOTE: mpdecimal recently added 'z' support, so this becomes
  efficient in the long term.)
* fix 'z' format memory leak
* fix 'z' format applied to 'F'
* fix missing '#' format support

Suggested and prototyped by Stefan Krah.

Fixes gh-114563, gh-91060

(cherry picked from commit 72340d15cd)

Co-authored-by: John Belmonte <john@neggie.net>
Co-authored-by: Stefan Krah <skrah@bytereef.org>
2024-02-12 23:31:12 +02:00
Miss Islington (bot)
d19f0674ae
[3.12] gh-114670: Fix _testbuffer module initialization (GH-114672) (#115272)
(cherry picked from commit 3a5b38e3b4)

Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
2024-02-11 10:53:00 +03:00
Miss Islington (bot)
0211f919b1
[3.12] gh-115059: Flush the underlying write buffer in io.BufferedRandom.read1() (GH-115163) (GH-115205)
(cherry picked from commit 846fd721d5)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2024-02-09 11:00:35 +00:00
Miss Islington (bot)
dc01c84ed0
[3.12] gh-115136: Fix possible NULL deref in getpath_joinpath() (GH-115137) (GH-115157)
(cherry picked from commit 9e90313320)

Signed-off-by: Artem Chernyshev <artem.chernyshev@red-soft.ru>
Co-authored-by: Artem Chernyshev <62871052+dTenebrae@users.noreply.github.com>
2024-02-08 11:18:38 +02:00
Łukasz Langa
b39119916c
[3.12] gh-46968: Fix invalid reference to Sound eXchange (SoX) 12.17.7 license (#115094)
Fix invalid reference to Sound eXchange (SoX) 12.17.7 license
2024-02-06 18:59:23 +01:00
Erlend E. Aasland
6f5e360acd
[3.12] gh-115015: Argument Clinic: fix generated code for METH_METHOD methods without params (#115016) (#115067)
(cherry picked from commit 09096a1647)
2024-02-06 11:20:16 +01:00
Miss Islington (bot)
4defc50100
gh-110190: Fix ctypes structs with array on Windows ARM64 (GH-114753)
(cherry picked from commit a06b606462)

Co-authored-by: Diego Russo <diego.russo@arm.com>
2024-01-31 00:15:16 +00:00
Steve Dower
74bd566f70
Use Unicode unconditionally for _winapi.CreateFile (GH-114611)
Currently it switches based on build settings, but argument clinic does not handle it correctly.
2024-01-26 17:53:46 +00:00
Miss Islington (bot)
386c72d992
[3.12] gh-114492: Initialize struct termios before calling tcgetattr() (GH-114495) (GH-114502)
On Alpine Linux it could leave some field non-initialized.
(cherry picked from commit d22c066b80)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2024-01-23 22:02:02 +00:00
Peter Lazorchak
ae2a25bf60
[3.12] Check for valid tp_version_tag in specializer (gh-89811) (gh-114216) 2024-01-20 04:45:33 +08:00
Miss Islington (bot)
ffac6ac656
[3.12] gh-114286: Fix maybe-uninitialized warning in Modules/_io/fileio.c (GH-114287) (GH-114288)
(cherry picked from commit 05e47202a3)

Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
2024-01-19 10:58:09 +00:00
Miss Islington (bot)
f8fc8534c4
[3.12] gh-104522: Fix OSError raised when run a subprocess (GH-114195) (#114219)
gh-104522: Fix OSError raised when run a subprocess (GH-114195)

Only set filename to cwd if it was caused by failed chdir(cwd).

_fork_exec() now returns "noexec:chdir" for failed chdir(cwd).

(cherry picked from commit e2c097ebde)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
Co-authored-by: Robert O'Shea <PurityLake@users.noreply.github.com>
2024-01-18 01:19:11 +00:00
Miss Islington (bot)
00e7793519
[3.12] gh-104282: Fix null pointer dereference in lzma._decode_filter_properties (GH-104283) (GH-114181)
(cherry picked from commit 0154405350)

Co-authored-by: Radislav Chugunov <52372310+chgnrdv@users.noreply.github.com>
2024-01-17 13:31:33 +00:00
Miss Islington (bot)
10f00294a0
gh-114096: Restore privileges in _winapi.CreateJunction after creating the junction (GH-114089)
This avoids impact on later parts of the application which may be able to do things they otherwise shouldn't.
(cherry picked from commit de4ced54eb)

Co-authored-by: Steve Dower <steve.dower@python.org>
2024-01-16 17:39:59 +00:00
Miss Islington (bot)
7b7cf75c02
gh-111877: Fixes stat() handling for inaccessible files on Windows (GH-113716)
(cherry picked from commit ed066481c7)

Co-authored-by: Steve Dower <steve.dower@python.org>
2024-01-12 15:53:27 +00:00
Miss Islington (bot)
b902671d36
gh-81489: Use Unicode APIs for mmap tagname on Windows (GH-14133)
(cherry picked from commit b4d4aa9e8d)

Co-authored-by: Zackery Spytz <zspytz@gmail.com>
Co-authored-by: Erlend E. Aasland <erlend@python.org>
2024-01-11 23:13:02 +00:00
Miss Islington (bot)
4050a150e9
gh-87868: Sort and remove duplicates in getenvironment() (GH-102731)
(cherry picked from commit c31be58da8)

Co-authored-by: AN Long <aisk@users.noreply.github.com>
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
Co-authored-by: Pieter Eendebak <pieter.eendebak@gmail.com>
Co-authored-by: Erlend E. Aasland <erlend.aasland@protonmail.com>
2024-01-10 23:43:39 +00:00
Miss Islington (bot)
59a7b9495b
[3.12] gh-70835: Clarify error message for CSV file opened with wrong newline (GH-113786) (GH-113905)
Based on patch by SilentGhost.
(cherry picked from commit 568d220993)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2024-01-10 13:26:04 +00:00
Miss Islington (bot)
ad2d5ec97e
[3.12] gh-80109: Fix io.TextIOWrapper dropping the internal buffer during write() (GH-22535) (GH-113808)
io.TextIOWrapper was dropping the internal decoding buffer
during read() and write() calls.
(cherry picked from commit 73c9326563)

Co-authored-by: Zackery Spytz <zspytz@gmail.com>
2024-01-08 11:00:30 +00:00
Serhiy Storchaka
6d9af66616
[3.12] gh-62260: Fix ctypes.Structure subclassing with multiple layers (GH-13374) (GH-113623)
The length field of StgDictObject for Structure class contains now
the total number of items in ffi_type_pointer.elements (excluding
the trailing null).

The old behavior of using the number of elements in the parent class can
cause the array to be truncated when it is copied, especially when there
are multiple layers of subclassing.

(cherry picked from commit 5f3cc90a12)

Co-authored-by: Jeffrey Kintscher <49998481+websurfer5@users.noreply.github.com>
2024-01-05 22:52:41 +00:00
Diego Russo
b95cebf2b6
[3.12] gh-110190: Fix ctypes structs with array on PPCLE64 (GH-112959) (#113170)
Fix the same issue of PR #112604 on PPC64LE platform
Refactor tests to make easier to add more platfroms if needed.

(cherry picked from commit 6644ca45cd)
Change-Id: I31730a3ebe558570ce1d7a3b26db8392f18d1770
2024-01-05 16:45:26 +01:00
Miss Islington (bot)
0e3cf5bcac
[3.12] bpo-11102: Make configure enable major(), makedev(), and minor() on HP-UX (GH-19856) (GH-113540)
Always include <sys/types.h> before <sys/sysmacros.h>.

(cherry picked from commit f108468970)

Co-authored-by: Zackery Spytz <zspytz@gmail.com>
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2023-12-28 11:12:16 +00:00
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