Commit graph

11935 commits

Author SHA1 Message Date
Łukasz Langa
798eaca665
[3.9] gh-98793: Fix typecheck in overlapped.c (GH-98835) (GH-98890) (GH-140825)
(cherry picked from commit d3d1738acd)

Co-authored-by: Charlie Zhao <zhaoyu_hit@qq.com>
Co-authored-by: Kumar Aditya <59607654+kumaraditya303@users.noreply.github.com>
Co-authored-by: Petr Viktorin <encukou@gmail.com>
2025-10-31 16:37:20 +01:00
Miss Islington (bot)
e26ba93181
[3.9] gh-139312: Update bundled libexpat to 2.7.3 (GH-139319) (GH-139697)
(cherry picked from commit 7252d2b73b)

Co-authored-by: Stan Ulbrych <89152624+StanFromIreland@users.noreply.github.com>
2025-10-07 21:15:33 +02:00
Stan Ulbrych
f3d8338cd5
[3.9] gh-138998: Upgrade vendored expat to 2.7.2 (GH-138999) (GH-139055)
Some checks are pending
Tests / Check for source changes (push) Waiting to run
Tests / Check if the ABI has changed (push) Blocked by required conditions
Tests / Check if generated files are up to date (push) Blocked by required conditions
Tests / Windows (x86) (push) Blocked by required conditions
Tests / Windows (x64) (push) Blocked by required conditions
Tests / macOS (push) Blocked by required conditions
Tests / Ubuntu (push) Blocked by required conditions
Tests / Ubuntu SSL tests with OpenSSL (push) Blocked by required conditions
(cherry picked from commit 64c876dd68)
2025-10-07 14:53:33 +02:00
Sebastian Pipping
598165e373
[3.9] gh-139400: Make sure that parent parsers outlive their subparsers in pyexpat (GH-139403) (GH-139614)
Within libexpat, a parser created via `XML_ExternalEntityParserCreate`
is relying on its parent parser throughout its entire lifetime.
Prior to this fix, is was possible for the parent parser to be
garbage-collected too early.

(cherry picked from commit 6edb2ddb5f)
2025-10-07 13:52:10 +02:00
Seth Michael Larson
12deea5acf
[3.9] gh-131809: Upgrade vendored expat to 2.7.1 (GH-132192) (#132242)
(cherry picked from commit c0de650024)

Co-authored-by: Gregory P. Smith <greg@krypto.org>
2025-04-08 11:36:44 +02:00
Seth Michael Larson
8ad2d88ebd
[3.9] gh-131261: Update libexpat to 2.7.0 (CVE-2024-8176) (GH-131272) (GH-131364)
(cherry picked from commit bb0268f60d)
(cherry picked from commit 6af54d298d)

Co-authored-by: Petr Viktorin <encukou@gmail.com>
Co-authored-by: Gregory P. Smith <greg@krypto.org>
2025-04-03 18:40:35 +02:00
Seth Michael Larson
6b8f44236a
[3.9] gh-126623: Update libexpat to 2.6.4, make future updates easier (GH-126792) (GH-126800)
(cherry picked from commit 3c99969094)
2024-12-02 16:07:24 +01:00
Seth Michael Larson
c57c4a9667
[3.9] gh-123678: Upgrade libexpat 2.6.3 (#123711)
(cherry picked from commit fdc04ad75a)
2024-09-05 14:27:48 +02:00
Łukasz Langa
0152431f17
[3.9] gh-112275: Fix HEAD_LOCK deadlock in child process after fork (GH-112336) (#123688)
HEAD_LOCK is called from _PyEval_ReInitThreads->_PyThreadState_DeleteExcept before _PyRuntimeState_ReInitThreads reinit runtime->interpreters.mutex which might be locked before fork.

(cherry picked from commit 522799a05e)

Co-authored-by: ChuBoning <102216855+ChuBoning@users.noreply.github.com>
2024-09-04 22:41:03 +02:00
Miss Islington (bot)
9290419492
[3.9] gh-119690: Fixes buffer type confusion in _winapi.CreateFile and _winapi.CreateNamedPipe audit events (GH-119735) (#123679)
(cherry picked from commit 2e861ac1cd)

Co-authored-by: Steve Dower <steve.dower@python.org>
2024-09-04 18:22:50 +02:00
Łukasz Langa
9e9c71d09e
[3.9] gh-121957: Emit audit events for python -i and python -m asyncio (GH-122120) 2024-07-22 13:49:47 +02:00
Steve Dower
5130731c9e
[3.9] gh-118486: Support mkdir(mode=0o700) on Windows (GH-118488) (GH-118741)
Co-authored-by: Łukasz Langa <lukasz@langa.pl>
2024-05-24 19:27:01 +02:00
Seth Michael Larson
b228655c22
[3.9] gh-114572: Fix locking in cert_store_stats and get_ca_certs (#118109) 2024-05-10 13:46:12 +02:00
Seth Michael Larson
7db40cd3a9
[3.9] gh-116741: Upgrade libexpat to 2.6.2 (GH-117296) (GH-118187)
(cherry picked from commit c9829eec08)
2024-05-07 10:50:48 +02:00
jkriegshauser
40d77b9367
[3.9] gh-116773: Fix overlapped memory corruption crash (GH-116774) (GH-117080)
Co-authored-by: Łukasz Langa <lukasz@langa.pl>
2024-03-27 16:24:46 +01:00
Sebastian Pipping
200762426b
[3.9] gh-115398: Expose Expat >=2.6.0 reparse deferral API (CVE-2023-52425) (GH-115623) (GH-116272)
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 https://github.com/python/cpython/pull/115138#issuecomment-1932444270 .

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-07 00:03:30 +01:00
Miss Islington (bot)
468ba95c79
[3.9] gh-107077: Raise SSLCertVerificationError even if the error is set via SSL_ERROR_SYSCALL (GH-107586) (#107590)
(cherry picked from commit 77e09192b5)

Co-authored-by: Pablo Galindo Salgado <Pablogsal@gmail.com>
Co-authored-by: T. Wouters <thomas@python.org>
Co-authored-by: Łukasz Langa <lukasz@langa.pl>
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2024-02-21 17:02:34 +01:00
Seth Michael Larson
4b68e5d7ab
[3.9] Upgrade bundled libexpat to 2.6.0 (GH-115399) (GH-115474)
Manual backport due to code differences.
(cherry picked from commit e071b0d558)

Co-authored-by: Łukasz Langa <lukasz@langa.pl>
2024-02-21 13:48:13 +01:00
Miss Islington (bot)
a6f73f6114
[3.9] bpo-37013: Fix the error handling in socket.if_indextoname() (GH-13503) (GH-112600)
* 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>
2024-01-17 14:47:26 +01:00
Łukasz Langa
08b640e157
[3.9] gh-101180: Fix a bug where iso2022_jp_3 and iso2022_jp_2004 codecs read out of bounds (gh-111695) (gh-111780)
(cherry picked from commit c8faa3568a)

Co-authored-by: Masayuki Moriyama <masayuki.moriyama@miraclelinux.com>
2023-11-06 18:44:50 +01:00
Serhiy Storchaka
4a79328195
[3.9] gh-99612: Fix PyUnicode_DecodeUTF8Stateful() for ASCII-only data (GH-99613) (GH-107224) (#107231)
Previously *consumed was not set in this case.
(cherry picked from commit f08e52ccb0).
(cherry picked from commit b8b3e6afc0)
2023-08-22 20:25:15 +02:00
Gregory P. Smith
e15de14c16
[3.9] gh-103142: Upgrade binary builds and CI to OpenSSL 1.1.1u (GH-105174) (GH-105200) (#105205)
Upgrade builds to OpenSSL 1.1.1u.

Also updates _ssl_data_111.h from OpenSSL 1.1.1u, _ssl_data_300.h from 3.0.9.

Manual edits to the _ssl_data_300.h file prevent it from removing any
existing definitions in case those exist in some peoples builds and were
important (avoiding regressions during backporting).

(cherry picked from commit ede89af)

Co-authored-by: Ned Deily <nad@python.org>
2023-06-05 17:41:51 +02:00
Kumar Aditya
6954203c9f
[3.9] GH-100892: Fix race in clearing threading.local (GH-100922) (#100939)
[3.9] [3.10] GH-100892: Fix race in clearing `threading.local` (GH-100922).
(cherry picked from commit 762745a124)

Co-authored-by: Kumar Aditya <59607654+kumaraditya303@users.noreply.github.com>.
(cherry picked from commit 683e9fe30e)

Co-authored-by: Kumar Aditya <59607654+kumaraditya303@users.noreply.github.com>
2023-01-20 23:21:40 +01:00
Miss Islington (bot)
857efee6d2
[3.9] gh-98517: Fix buffer overflows in _sha3 module (GH-98519) (#98526)
This is a port of the applicable part of XKCP's fix [1] for
CVE-2022-37454 and avoids the segmentation fault and the infinite
loop in the test cases published in [2].

[1]: fdc6fef075
[2]: https://mouha.be/sha-3-buffer-overflow/

Regression test added by: Gregory P. Smith [Google LLC] <greg@krypto.org>
(cherry picked from commit 0e4e058602)

Co-authored-by: Theo Buehler <botovq@users.noreply.github.com>
2022-10-28 12:08:06 +02:00
Miss Islington (bot)
71a075aaee
[3.9] gh-98739: Update libexpat from 2.4.9 to 2.5.0 (GH-98742) (#98786)
Update libexpat from 2.4.9 to 2.5.0 to address CVE-2022-43680.

Co-authored-by: Shaun Walbridge <shaun.walbridge@gmail.com>
(cherry picked from commit 3e07f827b3)
2022-10-28 12:07:32 +02:00
Miss Islington (bot)
77796d058e
[3.9] gh-97897: Prevent os.mkfifo and os.mknod segfaults with macOS 13 SDK (GH-97944) (#97968)
The macOS 13 SDK includes support for the `mkfifoat` and `mknodat` system calls.
 Using the `dir_fd` option with either `os.mkfifo` or `os.mknod` could result in a
 segfault if cpython is built with the macOS 13 SDK but run on an earlier
 version of macOS. Prevent this by adding runtime support for detection of
 these system calls ("weaklinking") as is done for other newer syscalls on
 macOS.
(cherry picked from commit 6d0a0191a4)

Co-authored-by: Ned Deily <nad@python.org>
2022-10-06 12:14:32 -07:00
Miss Islington (bot)
9b409e418a
[3.9] gh-97005: Update libexpat from 2.4.7 to 2.4.9 (gh-97006) (gh-97012)
gh-97005: Update libexpat from 2.4.7 to 2.4.9 (gh-97006)

Co-authored-by: Gregory P. Smith [Google] <greg@krypto.org>
(cherry picked from commit 10e3d398c3)

Co-authored-by: Dong-hee Na <donghee.na@python.org>
Co-authored-by: Ned Deily <nad@python.org>
2022-10-04 10:04:33 -07:00
Miss Islington (bot)
cd0a59f1fa
gh-94821: Fix autobind of empty unix domain address (GH-94826) (GH-94875)
When binding a unix socket to an empty address on Linux, the socket is
automatically bound to an available address in the abstract namespace.

    >>> s = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
    >>> s.bind("")
    >>> s.getsockname()
    b'\x0075499'

Since python 3.9, the socket is bound to the one address:

    >>> s.getsockname()
    b'\x00'

And trying to bind multiple sockets will fail with:

    Traceback (most recent call last):
      File "/home/nsoffer/src/cpython/Lib/test/test_socket.py", line 5553, in testAutobind
        s2.bind("")
    OSError: [Errno 98] Address already in use

Added 2 tests:
- Auto binding empty address on Linux
- Failing to bind an empty address on other platforms

Fixes f6b3a07b7d (bpo-44493: Add missing terminated NUL in sockaddr_un's length (GH-26866)
(cherry picked from commit c22f134211)

Co-authored-by: Nir Soffer <nsoffer@redhat.com>
2022-07-26 12:07:41 +02:00
Miss Islington (bot)
1699a5ee13
Check result of utc_to_seconds and skip fold probe in pure Python (GH-91582) (GH-92748)
The `utc_to_seconds` call can fail, here's a minimal reproducer on
Linux:

TZ=UTC python -c "from datetime import *; datetime.fromtimestamp(253402300799 + 1)"

The old behavior still raised an error in a similar way, but only
because subsequent calculations happened to fail as well. Better to fail
fast.

This also refactors the tests to split out the `fromtimestamp` and
`utcfromtimestamp` tests, and to get us closer to the actual desired
limits of the functions. As part of this, we also changed the way we
detect platforms where the same limits don't necessarily apply (e.g.
Windows).

As part of refactoring the tests to hit this condition explicitly (even
though the user-facing behvior doesn't change in any way we plan to
guarantee), I noticed that there was a difference in the places that
`datetime.utcfromtimestamp` fails in the C and pure Python versions, which
was fixed by skipping the "probe for fold" logic for UTC specifically —
since UTC doesn't have any folds or gaps, we were never going to find a
fold value anyway. This should prevent some failures in the pure python
`utcfromtimestamp` method on timestamps close to 0001-01-01.

There are two separate news entries for this because one is a
potentially user-facing change, the other is an internal code
correctness change that, if anything, changes some error messages. The
two happen to be coupled because of the test refactoring, but they are
probably best thought of as independent changes.

Fixes GH-91581
(cherry picked from commit 83c0247d47)

Co-authored-by: Paul Ganssle <1377457+pganssle@users.noreply.github.com>
2022-05-16 17:33:01 +02:00
Itai Steinherz
1fb25a96ae
bpo-46785: Fix race condition between os.stat() and unlink on Windows (GH-31858)
* [3.9] bpo-46785: Fix race condition between os.stat() and unlink on Windows (GH-31858).
(cherry picked from commit 39e6b8ae6a)

Co-authored-by: Itai Steinherz <itaisteinherz@gmail.com>
2022-05-09 23:42:59 +01:00
Erlend Egeberg Aasland
7d17a7b352
[3.9] gh-80254: Disallow recursive usage of cursors in sqlite3 converters (#92278)
* [3.9] gh-80254: Disallow recursive usage of cursors in `sqlite3` converters

(cherry picked from commit c908dc5b47)

Co-authored-by: Sergey Fedoseev <fedoseev.sergey@gmail.com>
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>

* Fix ref leak in pysqlite_cursor_iternext

* Explicitly free resources at test tearDown()
2022-05-05 12:47:58 -07:00
Miss Islington (bot)
f84c51eb7a
gh-92036: Fix gc_fini_untrack() (GH-92037)
Fix a crash in subinterpreters related to the garbage collector. When
a subinterpreter is deleted, untrack all objects tracked by its GC.
To prevent a crash in deallocator functions expecting objects to be
tracked by the GC, leak a strong reference to these objects on
purpose, so they are never deleted and their deallocator functions
are not called.
(cherry picked from commit 14243369b5)

Co-authored-by: Victor Stinner <vstinner@python.org>
2022-05-04 03:25:33 -07:00
Serhiy Storchaka
1b1c79c566
[3.9] gh-91583: AC: Fix regression for functions with defining_class (GH-91739) (GH-92080)
Argument Clinic now generates the same efficient code as before
adding the defining_class parameter.
(cherry picked from commit a055dac0b4)
2022-05-03 11:54:06 +03:00
Miss Islington (bot)
56c2d08097
gh-91734: Fix ossaudio support on Solaris (GH-91735)
(cherry picked from commit 4420faf273)

Co-authored-by: Jakub Kulík <Kulikjak@gmail.com>
2022-04-20 04:09:01 -07:00
Oleg Iarygin
312e16fb7b
[3.9] gh-91118: Fix docstrings that do not honor --without-doc-strings (GH-31769) (#91664)
Co-authored-by: Éric <merwok@netwok.org>
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
(cherry picked from commit a573cb2fec)
2022-04-19 12:58:34 -07:00
Miss Islington (bot)
dae09c2b81
[3.9] bpo-44493: Add missing terminated NUL in sockaddr_un's length (GH-26866) (GH-32140) (GH-32156)
Add missing terminated NUL in sockaddr_un's length

- Linux: https://man7.org/linux/man-pages/man7/unix.7.html
- *BSD: SUN_LEN
(cherry picked from commit f6b3a07b7d)

Co-authored-by: ty <zonyitoo@users.noreply.github.com>

Automerge-Triggered-By: GH:gpshead
(cherry picked from commit 5944807b09)

Co-authored-by: Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
2022-03-28 13:03:18 -07:00
Miss Islington (bot)
ec3589f59d
bpo-47101: list only activated algorithms in hashlib.algorithms_available (GH-32076)
(cherry picked from commit 48e2010d92)

Co-authored-by: Christian Heimes <christian@python.org>
2022-03-23 13:58:02 -07:00
Miss Islington (bot)
f89949ec67
bpo-23691: Protect the re.finditer() iterator from re-entering (GH-32012)
(cherry picked from commit 08eb754d84)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2022-03-21 04:28:31 -07:00
Gregory P. Smith
58a7e13037
bpo-38256: Fix binascii.crc32 large input. (GH-32000) (GH-32013) (GH-32015)
Inputs >= 4GiB to `binascii.crc32(...)` when compiled to use the zlib
crc32 implementation (the norm on POSIX) no longer return the wrong
result.

(cherry picked from commit 4c989e19c8)
2022-03-20 23:34:45 -07:00
Pablo Galindo Salgado
a12ef81231
[3.9] bpo-46968: Check for 'sys/auxv.h' in the configure script (GH-31961). (GH-31975)
(cherry picked from commit 8e3fde728f)

Co-authored-by: Pablo Galindo Salgado <Pablogsal@gmail.com>
2022-03-18 13:33:03 +00:00
Jelle Zijlstra
49ff5eddfe
[3.9] sqlite3: normalise pre-acronym determiners (GH-31772) (GH-31807)
For consistency, replace "a SQL" with "an SQL"..
(cherry picked from commit 2d5835a019)

Co-authored-by: Erlend Egeberg Aasland <erlend.aasland@innova.no>
2022-03-11 17:10:39 -08:00
Victor Stinner
ba2b7956fa
bpo-46968: Fix faulthandler for Sapphire Rapids Xeon (GH-31789) (GH-31831)
In Linux kernel 5.14 one can dynamically request size of altstacksize
based on hardware capabilities with getauxval(AT_MINSIGSTKSZ).

This changes allows for Python extension's request to Linux kernel
to use AMX_TILE instruction set on Sapphire Rapids Xeon processor
to succeed, unblocking use of the ISA in frameworks.

Introduced HAVE_LINUX_AUXVEC_H in configure.ac and pyconfig.h.in
Used cpython_autoconf:269 docker container to generate configure.

(cherry picked from commit 3b128c0548)

Co-authored-by: Oleksandr Pavlyk <oleksandr.pavlyk@intel.com>
2022-03-12 00:37:16 +01:00
Jelle Zijlstra
0c47008f8b
[3.9] Docstring: replace pysqlite with sqlite3 (GH-31758) (GH-31778)
Replace two instances of "pysqlite" with "sqlite3" in sqlite3
docstrings. Also reword "is a no-op" to "does nothing" for clarity..
(cherry picked from commit b33a1ae703)

Co-authored-by: Erlend Egeberg Aasland <erlend.aasland@innova.no>
2022-03-09 10:19:53 -08:00
Erlend Egeberg Aasland
653ca6c62b
[3.9] bpo-46878: Purge 'non-standard' from sqlite3 docstrings (GH-31612) (GH-31754)
(cherry picked from commit 4d95fa1ac5)
2022-03-08 07:31:06 -08:00
Miss Islington (bot)
f46a044691
bpo-46932: Update bundled libexpat to 2.4.7 (GH-31736)
(cherry picked from commit 176835c3d5)

Co-authored-by: Steve Dower <steve.dower@python.org>
2022-03-07 14:18:24 -08:00
Miss Islington (bot)
01df048831
bpo-25415: Remove confusing sentence from IOBase docstrings (PR-31631)
(cherry picked from commit cedd2473a9)

Co-authored-by: slateny <46876382+slateny@users.noreply.github.com>
2022-03-04 10:34:14 -08:00
Victor Stinner
6a14330318
bpo-46913: Fix test_ctypes, test_hashlib, test_faulthandler on UBSan (GH-31675) (GH-31676)
* bpo-46913: Fix test_faulthandler.test_sigfpe() on UBSAN (GH-31662)

Disable undefined behavior sanitizer (UBSAN) on
faulthandler_sigfpe().

(cherry picked from commit 4173d677a1)

* bpo-46913: Fix test_faulthandler.test_read_null() on UBSan (GH31672)

Disable undefined behavior sanitizer (UBSan) on
faulthandler._read_null().

(cherry picked from commit 65b92ccdec)

* bpo-46913: test_hashlib skips _sha3 tests on UBSan (GH-31673)

If Python is built with UBSan, test_hashlib skips tests on the _sha3
extension which currently has undefined behaviors.

This change allows to run test_hashlib to check for new UBSan regression,
but the known _sha3 undefined behavior must be fixed.

(cherry picked from commit 6d0d7d2b8c)

* bpo-46913: Skip test_ctypes.test_shorts() on UBSan (GH-31674)

If Python is built with UBSan, test_ctypes now skips test_shorts().
This change allows to run test_ctypes to check for new UBSan regression,
but the known test_shorts() undefined behavior must be fixed.

(cherry picked from commit ad1b04451d)
(cherry picked from commit 7b5b429ada)
2022-03-04 01:31:54 +01:00
Erlend Egeberg Aasland
3ea2a8f425
[3.9] bpo-43853: Expand test suite for SQLite UDF's (GH-27642) (GH-31030) (GH-31586)
(cherry picked from commit 3eb3b4f270)
2022-03-01 20:46:16 -08:00
Miss Islington (bot)
87cebb1e69
bpo-46794: Bump up the libexpat version into 2.4.6 (GH-31487)
(cherry picked from commit 1935e1cc28)

Co-authored-by: Dong-hee Na <donghee.na@python.org>
2022-02-22 18:50:57 -08:00
Miss Islington (bot)
9aca412db8
bpo-46784: Add newly exported expat symbols to the namespace. (GH-31397)
The libexpat 2.4.1 upgrade from  introduced the following new exported symbols:

* `testingAccountingGetCountBytesDirect`
* `testingAccountingGetCountBytesIndirect`
* `unsignedCharToPrintable`
* `XML_SetBillionLaughsAttackProtectionActivationThreshold`
* `XML_SetBillionLaughsAttackProtectionMaximumAmplification`

We need to adjust [Modules/expat/pyexpatns.h](https://github.com/python/cpython/blob/master/Modules/expat/pyexpatns.h)

(The newer libexpat upgrade  has no new symbols).

Automerge-Triggered-By: GH:gpshead
(cherry picked from commit 6312c1052c)

Co-authored-by: Yilei "Dolee" Yang <yileiyang@google.com>
2022-02-18 15:13:16 -08:00