Commit Graph

13021 Commits

Author SHA1 Message Date
Seth Michael Larson 2e161e2499
[3.11] gh-126623: Update libexpat to 2.6.4, make future updates easier (GH-126792) (GH-126798)
Update libexpat to 2.6.4, make future updates easier.
(cherry picked from commit 3c99969094)
2024-12-03 17:42:23 +01:00
Petr Viktorin e33b6fccd3
[3.11] gh-111942: Remove an extra incref in textiowrapper_change_encoding (#126542) 2024-11-08 13:26:57 +01:00
Seth Michael Larson b582d5234f
[3.11] gh-123678: Upgrade libexpat 2.6.3 (#123709)
(cherry picked from commit e6fe0ac014)
2024-09-05 14:27:22 +02:00
ChuBoning 522799a05e
[3.11]GH-112275: Fix HEAD_LOCK deadlock in child process after fork (#112336)
HEAD_LOCK is called from _PyEval_ReInitThreads->_PyThreadState_DeleteExcept before _PyRuntimeState_ReInitThreads reinit runtime->interpreters.mutex which might be locked before fork.

Co-authored-by: Łukasz Langa <lukasz@langa.pl>
2024-09-04 19:14:59 +02:00
Steve Dower 697beec04d
[3.11] gh-119690: Fixes buffer type confusion in _winapi.CreateNamedPipe audit event (#119734)
gh-119690: Fixes buffer type confusion in _winapi.CreateNamedPipe audit event
2024-09-04 18:02:48 +02:00
Inada Naoki 8a978a75c2
[3.11] gh-119506: fix _io.TextIOWrapper.write() write during flush (#119507) (#120314)
Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
fix _io.TextIOWrapper.write() write during flush (#119507)
2024-08-09 17:04:36 +00:00
Łukasz Langa d542a9be51
[3.11] gh-121957: Emit audit events for python -i and python -m asyncio (GH-122118) 2024-07-22 13:44:55 +02:00
Steve Dower 35c799d791
[3.11] gh-118486: Support mkdir(mode=0o700) on Windows (GH-118488) (GH-118739) 2024-05-24 02:13:18 +02:00
Seth Michael Larson 8133285c13
[3.11] gh-116741: Upgrade libexpat to 2.6.2 (GH-117296) (#118185)
Upgrade libexpat to 2.6.2
(cherry picked from commit c9829eec08)
2024-04-23 12:28:50 -07:00
Miss Islington (bot) 65a0923c70
[3.11] gh-117310: Remove extra DECREF on "no ciphers" error path in `_ssl._SSLContext` constructor (GH-117309) (GH-117318)
gh-117310: Remove extra DECREF on "no ciphers" error path in `_ssl._SSLContext` constructor (GH-117309)

Remove extra self DECREF on ssl "no ciphers" error path.

This doesn't come up in practice because nobody links against a broken
OpenSSL library that provides nothing.
(cherry picked from commit 8cb7d7ff86)

Co-authored-by: Gregory P. Smith <greg@krypto.org>
2024-03-28 10:05:19 -07:00
Serhiy Storchaka 6261322e26
[3.11] gh-91227: Ignore ERROR_PORT_UNREACHABLE in proactor recvfrom() (GH-32011) (GH-117210)
(cherry picked from commit f11d0d8be8)

Co-authored-by: Erik Soma <stillusingirc@gmail.com>
2024-03-25 10:34:25 +00:00
Serhiy Storchaka 7323c4dd07
[3.11] gh-117021: Fix integer overflow in PyLong_AsPid() on non-Windows 64-bit platforms (GH-117064) (GH-117070) (GH-117075)
(cherry picked from commit da2f9d1417)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
(cherry picked from commit 519b2ae22b)
2024-03-21 09:43:42 +00:00
jkriegshauser 23a1c9f422
[3.11] gh-116773: Fix overlapped memory corruption crash (GH-116774) (#117077)
Manual backport of gh-116774.
2024-03-20 13:10:32 -07:00
Victor Stinner f292b0724e
[3.11] gh-106687: _ssl: use uint64_t for SSL options (#106700) (#116665)
gh-106687: _ssl: use uint64_t for SSL options (#106700)

SSL_CTX_get_options() uses uint64_t for options:
https://www.openssl.org/docs/man3.1/man3/SSL_CTX_get_options.html

Fix this compiler warning on Windows with MSC:

    conversion from 'uint64_t' to 'long', possible loss of data

(cherry picked from commit ad95c7253a)
2024-03-13 17:49:30 +01:00
Miss Islington (bot) 52c41179f9
[3.11] gh-116541: Handle errors correctly in `_pystatvfs_fromstructstatvfs` (GH-116542) (#116644)
gh-116541: Handle errors correctly in `_pystatvfs_fromstructstatvfs` (GH-116542)
(cherry picked from commit f8147d01da)

Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
2024-03-12 10:34:48 +00:00
Miss Islington (bot) 6ae6d46e61
[3.11] gh-116545: Fix error handling in `mkpwent` in `pwdmodule` (GH-116548) (#116594)
gh-116545: Fix error handling in `mkpwent` in `pwdmodule` (GH-116548)
(cherry picked from commit ffd79bea0f)

Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
2024-03-11 12:16:22 +00:00
Miss Islington (bot) f2898f89bf
[3.11] gh-116520: Fix error handling in `os_get_terminal_size_impl` in `posixmodule` (GH-116521) (#116540)
gh-116520: Fix error handling in `os_get_terminal_size_impl` in `posixmodule` (GH-116521)
(cherry picked from commit b4b4e764a7)

Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
2024-03-09 11:41:46 +00:00
Miss Islington (bot) 3abf267787
[3.11] gh-116447: Fix possible UB in `arraymodule` and `getargs` (GH-116459) (#116497)
gh-116447: Fix possible UB in `arraymodule` and `getargs` (GH-116459)
(cherry picked from commit fdb2d90a27)

Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
2024-03-08 11:25:39 +00:00
Miss Islington (bot) fa7f278583
[3.11] gh-116448: Handle errors correctly in `os_waitid_impl` in `posixmodule` (GH-116449) (#116453)
gh-116448: Handle errors correctly in `os_waitid_impl` in `posixmodule` (GH-116449)
(cherry picked from commit 882fcede83)

Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
2024-03-07 09:10:08 +00:00
Sebastian Pipping fc9da96274
[3.11] gh-115398: Expose Expat >=2.6.0 reparse deferral API (CVE-2023-52425) (GH-115623) (#116268)
Allow controlling Expat >=2.6.0 reparse deferral (CVE-2023-52425) by adding five new methods:

- `xml.etree.ElementTree.XMLParser.flush`
- `xml.etree.ElementTree.XMLPullParser.flush`
- `xml.parsers.expat.xmlparser.GetReparseDeferralEnabled`
- `xml.parsers.expat.xmlparser.SetReparseDeferralEnabled`
- `xml.sax.expatreader.ExpatParser.flush`

Based on the "flush" idea from #115138 (comment) .

- Please treat as a security fix related to CVE-2023-52425.

(cherry picked from commit 6a95676)
(cherry picked from commit 73807eb)
(cherry picked from commit eda2963)

---------

Includes code suggested-by: Snild Dolkow <snild@sony.com>
and by core dev Serhiy Storchaka.
Co-authored-by: Gregory P. Smith <greg@krypto.org>
2024-03-06 14:17:02 -08:00
Miss Islington (bot) d69bef6080
[3.11] gh-116404: Handle errors correctly in `wait_helper` in `posixmodule` (GH-116405) (#116407)
gh-116404: Handle errors correctly in `wait_helper` in `posixmodule` (GH-116405)
(cherry picked from commit 22ccf13b33)

Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
2024-03-06 09:08:35 +00:00
Serhiy Storchaka f2b1f6b828
[3.11] gh-115886: Handle embedded null characters in shared memory name (GH-115887) (GH-115907)
shm_open() and shm_unlink() now check for embedded null characters in
the name and raise an error instead of silently truncating it.
(cherry picked from commit 79811ededd)
2024-02-25 11:12:07 +00:00
Miss Islington (bot) a4a28e50fe
[3.11] gh-67044: Always quote or escape \r and \n in csv.writer() (GH-115741) (GH-115867)
(cherry picked from commit c688c0f130)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2024-02-23 20:43:53 +00:00
Serhiy Storchaka 9068c8c614
[3.11] gh-115712: Support CSV dialects with delimiter=' ' and skipinitialspace=True (GH-115721) (GH-115729) (GH-115738)
(cherry picked from commit 5ea86f496a)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
csv.writer() now quotes empty fields if delimiter is a space and
skipinitialspace is true and raises exception if quoting is not possible.
(cherry picked from commit 937d282150)
2024-02-20 19:09:10 +00:00
Miss Islington (bot) 01c37f1d07
[3.11] gh-114572: Fix locking in cert_store_stats and get_ca_certs (GH-114573) (#115549)
gh-114572: Fix locking in cert_store_stats and get_ca_certs (GH-114573)

* gh-114572: Fix locking in cert_store_stats and get_ca_certs

cert_store_stats and get_ca_certs query the SSLContext's X509_STORE with
X509_STORE_get0_objects, but reading the result requires a lock. See
https://github.com/openssl/openssl/pull/23224 for details.

Instead, use X509_STORE_get1_objects, newly added in that PR.
X509_STORE_get1_objects does not exist in current OpenSSLs, but we can
polyfill it with X509_STORE_lock and X509_STORE_unlock.

* Work around const-correctness problem

* Add missing X509_STORE_get1_objects failure check

* Add blurb
(cherry picked from commit bce693111b)

Co-authored-by: David Benjamin <davidben@google.com>
2024-02-20 16:34:44 +00:00
Miss Islington (bot) a5eaa14584
[3.11] gh-95782: Fix io.BufferedReader.tell() etc. being able to return offsets < 0 (GH-99709) (GH-115600)
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:55:43 +02:00
Seth Michael Larson e071b0d558
[3.11] Upgrade bundled libexpat to 2.6.0 (GH-115399) (GH-115468)
Manual backport due to code differences.
2024-02-14 18:29:27 +01:00
Miss Islington (bot) 0e07ebdba4
[3.11] gh-115243: Fix crash in deque.index() when the deque is concurrently modified (GH-115247) (GH-115466)
(cherry picked from commit 671360161f)

Co-authored-by: kcatss <kcats9731@gmail.com>
2024-02-14 17:21:12 +00:00
John Belmonte b86fdf2222
[3.11] gh-114563: C decimal falls back to pydecimal for unsupported format strings (GH-114879) (GH-115384)
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 'GH-' format support

Suggested and prototyped by Stefan Krah.

Fixes gh-114563, gh-91060

(cherry picked from commit 72340d15cd)
(cherry picked from commit 09c98e4633)

Co-authored-by: Stefan Krah <skrah@bytereef.org>
2024-02-13 10:38:06 +02:00
Miss Islington (bot) f4146a220e
[3.11] gh-114670: Fix `_testbuffer` module initialization (GH-114672) (#115271)
(cherry picked from commit 3a5b38e3b4)

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

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2024-02-09 11:01:47 +00:00
Miss Islington (bot) 214ac16696
[3.11] gh-115136: Fix possible NULL deref in getpath_joinpath() (GH-115137) (ПР-115158)
(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:16 +02:00
Miss Islington (bot) 350d1d09c5
[3.11] gh-46968: Fix invalid reference to Sound eXchange (SoX) 12.17.7 license (GH-115094) (GH-115095)
(cherry picked from commit b39119916c)

Co-authored-by: Łukasz Langa <lukasz@langa.pl>
2024-02-06 19:22:48 +01:00
Peter Lazorchak a11312456d
[3.11] gh-89811: Check for valid tp_version_tag in specializer (GH-115045)
* gh-89811: Check for valid tp_version_tag in specializer (GH-113558)

* gh-113937 Fix failures in type cache tests due to re-running (GH-113953)

* Update backported code for 3.11 specifically
2024-02-06 21:58:30 +08:00
Erlend E. Aasland ead9e784fb
[3.11] gh-115015: Argument Clinic: fix generated code for METH_METHOD methods without params (#115016) (#115069)
(cherry picked from commit 09096a1647)
2024-02-06 11:21:00 +01:00
Miss Islington (bot) d326d52478
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:08:26 +00:00
Steve Dower d7cbb04acb
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:48:36 +00:00
Miss Islington (bot) 666d07f241
[3.11] gh-114492: Initialize struct termios before calling tcgetattr() (GH-114495) (GH-114503)
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 21:53:13 +00:00
Serhiy Storchaka 2c9872428e
[3.11] gh-104522: Fix OSError raised when run a subprocess (GH-114195) (GH-114243)
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: Robert O'Shea <PurityLake@users.noreply.github.com>
2024-01-18 11:32:57 +00:00
Miss Islington (bot) 67424458d2
[3.11] gh-111777: Fix assertion errors on incorrectly still-tracked GC object destruction (GH-111778) (GH-111990)
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>
2024-01-17 15:10:12 +01:00
Miss Islington (bot) 99a7bdc646
[3.11] gh-70835: Clarify error message for CSV file opened with wrong newline (GH-113786) (GH-113906)
Based on patch by SilentGhost.
(cherry picked from commit 568d220993)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2024-01-17 15:06:39 +01:00
Miss Islington (bot) 76d0c4b688
[3.11] gh-104282: Fix null pointer dereference in `lzma._decode_filter_properties` (GH-104283) (GH-114182)
(cherry picked from commit 0154405350)

Co-authored-by: Radislav Chugunov <52372310+chgnrdv@users.noreply.github.com>
2024-01-17 13:30:29 +00:00
Steve Dower fb5cec98e2
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.
2024-01-16 17:37:17 +00:00
Steve Dower 186c021688
gh-81489: Use Unicode APIs for mmap tagname on Windows (GH-14133)
Co-authored-by: Zackery Spytz <zspytz@gmail.com>
Co-authored-by: Erlend E. Aasland <erlend@python.org>
2024-01-11 23:04:36 +00:00
Miss Islington (bot) d15e1ac828
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-11 22:27:12 +00:00
Miss Islington (bot) 4db8d3be49
[3.11] gh-80109: Fix io.TextIOWrapper dropping the internal buffer during write() (GH-22535) (GH-113809)
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 10:47:50 +00:00
Diego Russo 5da53d3024
[3.11] gh-110190: Fix ctypes structs with array on PPCLE64 (GH-112959) (#113167)
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: I1ada30808c0d593a43eca3fa7a628c26bc276310
2024-01-05 16:38:20 +01:00
Serhiy Storchaka 36153494f1
[3.11] gh-62260: Fix ctypes.Structure subclassing with multiple layers (GH-13374) (GH-113624)
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-01 16:46:07 +00:00
Guido van Rossum 8938495120
[3.11] gh-113566: Fix asyncio segfault during interpreter finalization (#113578) 2023-12-29 21:06:32 -08:00
Miss Islington (bot) 656eb16707
[3.11] bpo-11102: Make configure enable major(), makedev(), and minor() on HP-UX (GH-19856) (GH-113541)
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:02:23 +00:00