Commit graph

14378 commits

Author SHA1 Message Date
Miss Islington (bot)
bafad85181
[3.13] gh-130617 : fix time_clockid_converter on DragonFlyBSD (GH-130634) (#130666)
gh-130617 : fix time_clockid_converter on DragonFlyBSD (GH-130634)
(cherry picked from commit e41981704f)

Signed-off-by: leleliu008 <leleliu008@gmail.com>
Co-authored-by: leleliu008 <leleliu008@gmail.com>
2025-02-28 08:19:45 +00:00
Serhiy Storchaka
2ab7e1135a
[3.13] gh-130163: Fix a leak in _pickle.c after backporting (GH-130568) 2025-02-26 12:47:41 +02:00
Serhiy Storchaka
7c1b76fce8
[3.13] gh-130163: Fix crashes related to PySys_GetObject() (GH-130503) (GH-130556)
The use of PySys_GetObject() and _PySys_GetAttr(), which return a borrowed
reference, has been replaced by using one of the following functions, which
return a strong reference and distinguish a missing attribute from an error:
_PySys_GetOptionalAttr(), _PySys_GetOptionalAttrString(),
_PySys_GetRequiredAttr(), and _PySys_GetRequiredAttrString().
(cherry picked from commit 0ef4ffeefd)
2025-02-25 22:50:26 +00:00
Miss Islington (bot)
d71b167c5c
[3.13] gh-129405: Fix doc for Py_mod_multiple_interpreters default, and add test (GH-129406) (GH-130507)
(cherry picked from commit fc8d2cba54)

Co-authored-by: Petr Viktorin <encukou@gmail.com>
2025-02-24 16:49:35 +01:00
Miss Islington (bot)
86dab0e67e
[3.13] gh-130151: Fix reference leaks in _hashlib.hmac_{new,digest} (GH-130152) (#130491)
gh-130151: Fix reference leaks in `_hashlib.hmac_{new,digest}` (GH-130152)

* fix leak in `_hashlib.hmac_new`
* fix leak in `hmac_digest`
* fix exception type in `_hashlib.HMAC.copy`
(cherry picked from commit 071820113f)

Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
2025-02-24 00:19:49 -08:00
Miss Islington (bot)
6cd2f356c3
[3.13] gh-129838: Don't redefine _Py_NO_SANITIZE_UNDEFINED (GH-129839) (#130366)
gh-129838: Don't redefine _Py_NO_SANITIZE_UNDEFINED (GH-129839)

Newer GCC versions accept both __attribute__((no_sanitize("undefined")))
and __attribute__((no_sanitize_undefined)) so check that the macro is
not already defined.
(cherry picked from commit 568db400ff)

Co-authored-by: Collin Funk <collin.funk1@gmail.com>
2025-02-20 16:30:46 +00:00
Miss Islington (bot)
5d83b6c160
[3.13] gh-130230: Fix crash in pow() with only Decimal third argument (GH-130237) (GH-130246)
(cherry picked from commit b93b7e566e)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2025-02-18 13:18:37 +02:00
Miss Islington (bot)
2fcad2a47b
[3.13] gh-130179: Fix persistent_{id,load}_attr reference leaks in _pickle (GH-130180) (#130190)
gh-130179: Fix `persistent_{id,load}_attr` reference leaks in `_pickle` (GH-130180)
(cherry picked from commit e7f00cd14f)

Co-authored-by: Sergey Miryanov <sergey.miryanov@gmail.com>
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
2025-02-16 14:22:23 +00:00
Kumar Aditya
4cb251d06f
[3.13] gh-129983: fix data race in compile_template in sre.c (#130038)
gh-129983: fix data race in compile_template in sre.c (#130015)

(cherry picked from commit 3cf68cdd3e)

Co-authored-by: Tomasz Pytel <tompytel@gmail.com>
2025-02-12 13:33:56 +00:00
Erlend E. Aasland
d6daeeeb2f
[3.13] gh-129603: Don't segfault if sqlite3.Row description is None (#129604) (#129923)
(cherry picked from commit 7e6ee50b6b)
2025-02-10 00:21:33 +00:00
Tomasz Pytel
4a1389ced4
[3.13] gh-128657: fix _hashopenssl ref/data race (GH-128886) (GH-129853)
(cherry picked from commit 6c67904e79)
2025-02-08 10:59:30 -05:00
Miss Islington (bot)
506c76f1bd
[3.13] gh-129502: Fix handling errors in ctypes callbacks (GH-129504) (#129517)
gh-129502: Fix handling errors in ctypes callbacks (GH-129504)

Unlikely errors in preparing arguments for ctypes callback are now
handled in the same way as errors raised in the callback of in converting
the result of the callback -- using sys.unraisablehook() instead of
sys.excepthook() and not setting sys.last_exc and other variables.
(cherry picked from commit 9d63ae5fe5)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2025-02-04 00:05:51 +00:00
Miss Islington (bot)
de27372234
[3.13] gh-129345: null check for indent syslogmodule (GH-129348) (#129442)
gh-129345: null check for indent syslogmodule (GH-129348)
(cherry picked from commit 25cf79a082)

Co-authored-by: Burkov Egor <xwooffie@gmail.com>
2025-02-04 00:37:24 +01:00
Collin Funk
65f3432ac3
[3.13] gh-129539: Include sysexits.h before checking EX_OK (#129590)
Previously, the macro would be redefined when the header was included.
2025-02-02 19:37:32 +01:00
Victor Stinner
9a59a51733
[3.13] gh-111495: Add PyFile tests (#129449) (#129477)
gh-111495: Add PyFile tests (#129449)

Add tests for the following functions in test_capi.test_file:

* PyFile_FromFd()
* PyFile_GetLine()
* PyFile_NewStdPrinter()
* PyFile_WriteObject()
* PyFile_WriteString()
* PyObject_AsFileDescriptor()

Add Modules/_testlimitedcapi/file.c file.

Remove test_embed.StdPrinterTests which became redundant.

(cherry picked from commit 4ca9fc08f8)
2025-01-30 20:29:27 +01:00
Miss Islington (bot)
48b87d14e8
[3.13] gh-129409: Fix Integer overflow - SEGV while writing data more than 2GB in CSV file (GH-129413) (#129436)
gh-129409: Fix Integer overflow -  SEGV while writing data more than 2GB in CSV file (GH-129413)
(cherry picked from commit 97b0ef05d9)

Co-authored-by: Srinivas Reddy Thatiparthy (తాటిపర్తి శ్రీనివాస్  రెడ్డి) <thatiparthysreenivas@gmail.com>
2025-01-29 11:39:16 +00:00
Miss Islington (bot)
247c3b2644
[3.13] gh-129346: Handle allocation errors for SQLite aggregate context (GH-129347) (#129372)
(cherry picked from commit 379ab856f5)

Co-authored-by: Erlend E. Aasland <erlend@python.org>
2025-01-27 17:41:59 +00:00
Victor Stinner
e3b3e01d6a
[3.13] gh-129185: Fix PyTraceMalloc_Untrack() at Python exit (#129191) (#129217)
gh-129185: Fix PyTraceMalloc_Untrack() at Python exit (#129191)

Support calling PyTraceMalloc_Track() and PyTraceMalloc_Untrack()
during late Python finalization.

* Call _PyTraceMalloc_Fini() later in Python finalization.
* Test also PyTraceMalloc_Untrack() without the GIL
* PyTraceMalloc_Untrack() now gets the GIL.
* Test also PyTraceMalloc_Untrack() in test_tracemalloc_track_race().

(cherry picked from commit 46c7e13c05)
2025-01-23 13:59:19 +01:00
Miss Islington (bot)
c5e1131cfb
[3.13] gh-111178: fix UBSan failures in Modules/_multiprocessing/semaphore.c (GH-129084) (#129100)
gh-111178: fix UBSan failures in `Modules/_multiprocessing/semaphore.c` (GH-129084)

fix UBSan failures for `SemLockObject`
(cherry picked from commit 5ed5572cac)

Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
2025-01-20 21:05:52 +00:00
Miss Islington (bot)
0351ed5049
[3.13] Fix a typo in syslog's error message (GH-129029) (#129049)
Fix a typo in `syslog`'s error message (GH-129029)
(cherry picked from commit 9b1c1817af)

Co-authored-by: Tomas R <tomas.roun8@gmail.com>
2025-01-20 10:37:21 +00:00
Victor Stinner
6b47499510
[3.13] gh-128679: Fix tracemalloc.stop() race conditions (#128897)
tracemalloc_alloc(), tracemalloc_realloc(), PyTraceMalloc_Track(),
PyTraceMalloc_Untrack() and _PyTraceMalloc_TraceRef() now check
tracemalloc_config.tracing after calling TABLES_LOCK().

_PyTraceMalloc_Stop() now protects more code with TABLES_LOCK(),
especially setting tracemalloc_config.tracing to 1.

Add a test using PyTraceMalloc_Track() to test tracemalloc.stop()
race condition.

Call _PyTraceMalloc_Init() at Python startup.
2025-01-18 23:39:07 +00:00
Victor Stinner
430ccbc009
[3.13] gh-111495: Add more tests on PyEval C APIs (#122789) (#128987)
* gh-111495: Add more tests on PyEval C APIs (#122789)

* Add Lib/test/test_capi/test_eval.py
* Add Modules/_testlimitedcapi/eval.c

(cherry picked from commit bf8b374639)

* gh-111495: Fix refleaks in test_capi.test_eval tests (#122851)

(cherry picked from commit b4a316087c)
2025-01-18 14:49:55 +00:00
Miss Islington (bot)
c75894a36b
[3.13] gh-128961: Fix exhausted array iterator crash in __setstate__() (GH-128962) (#128976)
(cherry picked from commit 4dade055f4)

Co-authored-by: Tomasz Pytel <tompytel@gmail.com>
2025-01-18 10:17:42 +00:00
Victor Stinner
34ded1a1a1
[3.13] gh-128911: Add tests on the PyImport C API (#128915) (#128960)
gh-128911: Add tests on the PyImport C API (#128915)

* Add Modules/_testlimitedcapi/import.c
* Add Lib/test/test_capi/test_import.py
* Remove _testcapi.check_pyimport_addmodule(): tests already covered
  by newly added tests.

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
(cherry picked from commit d95ba9fa11)
2025-01-17 22:44:51 +01:00
Miss Islington (bot)
d997ba45ed
[3.13] gh-58689: Fix os.kill() error handling on Windows (GH-128932) (#128937)
gh-58689: Fix os.kill() error handling on Windows (GH-128932)
(cherry picked from commit 939df0f9f6)

Co-authored-by: Victor Stinner <vstinner@python.org>
2025-01-17 12:55:07 +00:00
Erlend E. Aasland
436064afd8
[3.13] gh-127614: Correctly check for ttyname_r() in configure (#128503) (#128598)
(cherry picked from commit e08b28235a)

PR #14868 replaced the ttyname() call with ttyname_r(), but the old
check remained.
2025-01-11 11:47:49 +00:00
Miss Islington (bot)
0d2b9abd18
[3.13] gh-127196: Fix crash in _interpreters, when shared had invalid encodings (GH-127220) (#128689)
gh-127196: Fix crash in `_interpreters`, when `shared` had invalid encodings (GH-127220)
(cherry picked from commit 087bb48aca)

Co-authored-by: sobolevn <mail@sobolevn.me>
2025-01-09 20:10:08 +00:00
Miss Islington (bot)
ebadfd1039
[3.13] gh-128400: Stop-the-world when manually calling faulthandler (GH-128422) (GH-128423)
(cherry picked from commit c9356feef2)

Co-authored-by: Peter Bierma <zintensitydev@gmail.com>
2025-01-02 19:21:16 +00:00
Miss Islington (bot)
261a604a88
[3.13] gh-123925: Fix building curses on platforms without libncursesw (GH-128405) (GH-128407)
(cherry picked from commit 8d16919a06)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2025-01-02 12:01:40 +00:00
Miss Islington (bot)
40c46f08e2
gh-128217: Validate the normalized_environment variable instead of the similarly named function (GH-128220)
(cherry picked from commit 3ddd70ceaa)

Co-authored-by: Sergey Muraviov <smurav@mail.ru>
2024-12-24 13:29:56 +00:00
Peter Bierma
3a8bdaf698
[3.13] gh-128083: Fix macro redefinition warning in clinic. (GH-127950) (#128102)
(cherry picked from commit b5d1e4552f)

Co-authored-by: Peter Bierma <zintensitydev@gmail.com>
2024-12-19 21:29:14 +00:00
Miss Islington (bot)
fe08cdf265
[3.13] gh-126742: Add _PyErr_SetLocaleString, use it for gdbm & dlerror messages (GH-126746) (GH-128023)
- Add a helper to set an error from locale-encoded `char*`
- Use the helper for gdbm & dlerror messages
(cherry picked from commit 7303f06846)

Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
Co-authored-by: Victor Stinner <vstinner@python.org>
2024-12-17 11:45:29 +00:00
Miss Islington (bot)
0f38b897f9
[3.13] gh-127870: Detect recursive calls in ctypes _as_parameter_ handling (GH-127872) (#127917)
gh-127870: Detect recursive calls in ctypes _as_parameter_ handling (GH-127872)
(cherry picked from commit 6ff38fc4e2)

Co-authored-by: Victor Stinner <vstinner@python.org>
2024-12-13 13:19:41 +00:00
Miss Islington (bot)
2a78663870
[3.13] gh-127257: ssl: Raise OSError for ERR_LIB_SYS (GH-127361) (GH-127812)
gh-127257: ssl: Raise OSError for ERR_LIB_SYS (GH-127361)

From the ERR_raise manpage:

    ERR_LIB_SYS

        This "library code" indicates that a system error is
        being reported.  In this case, the reason code given
        to `ERR_raise()` and `ERR_raise_data()` *must* be
        `errno(3)`.

This PR only handles ERR_LIB_SYS for the high-lever error types
SSL_ERROR_SYSCALL and SSL_ERROR_SSL, i.e., not the ones where
OpenSSL indicates it has some more information about the issue.
(cherry picked from commit f4b31edf2d)

Co-authored-by: Petr Viktorin <encukou@gmail.com>
2024-12-12 12:44:53 +01:00
Peter Bierma
bcdd10d0c8
[3.13] gh-127791: Fix, document, and test PyUnstable_AtExit (GH-127793) (#127819)
* Fix merge conflicts.

* [3.13] gh-127791: Fix, document, and test `PyUnstable_AtExit` (GH-127793)
(cherry picked from commit d5d84c3f13)

Co-authored-by: Peter Bierma <zintensitydev@gmail.com>
2024-12-11 13:40:45 +00:00
Miss Islington (bot)
468e8dad7e
[3.13] gh-122431: Disallow negative values in readline.append_history_file (GH-122469) (#127641)
gh-122431: Disallow negative values in `readline.append_history_file` (GH-122469)
(cherry picked from commit 208b0fb645)

Co-authored-by: Peter Bierma <zintensitydev@gmail.com>
Co-authored-by: Victor Stinner <vstinner@python.org>
2024-12-05 18:15:44 +01:00
Miss Islington (bot)
3e11b5c2ba
[3.13] gh-93312: Include <sys/pidfd.h> to get PIDFD_NONBLOCK (GH-127593) (#127630)
gh-93312: Include <sys/pidfd.h> to get PIDFD_NONBLOCK (GH-127593)
(cherry picked from commit fcbe6ecdb6)

Co-authored-by: Victor Stinner <vstinner@python.org>
2024-12-05 10:02:17 +00:00
Miss Islington (bot)
059114c0a0
[3.13] gh-126876: Fix socket internal_select() for large timeout (GH-126968) (#127002)
gh-126876: Fix socket internal_select() for large timeout (GH-126968)

If the timeout is larger than INT_MAX, replace it with INT_MAX, in
the poll() code path.

Add an unit test.
(cherry picked from commit b3687ad454)

Co-authored-by: Victor Stinner <vstinner@python.org>
2024-12-02 16:25:55 +00:00
Peter Bierma
cab2ef5125
[3.13] gh-126890: Restore stripped ssl docstrings (GH-127281) (#127513)
(cherry picked from commit c112de1da2)

Co-authored-by: Peter Bierma <zintensitydev@gmail.com>
2024-12-02 16:05:27 +01:00
Peter Bierma
b1051577de
[3.13] gh-124984: Enhance ssl thread safety (GH-124993) (#125780)
Make SSL objects thread safe in Free Theaded build by
using critical sections.

(cherry picked from commit 4c53b25775)

Co-authored-by: Peter Bierma <zintensitydev@gmail.com>
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
2024-12-02 15:03:44 +01:00
Miss Islington (bot)
4bafce0912
[3.13] gh-126618: fix repr(itertools.count(sys.maxsize)) (GH-127048) (#127508)
gh-126618: fix repr(itertools.count(sys.maxsize)) (GH-127048)
(cherry picked from commit 930ba0ce60)

Co-authored-by: Sergey B Kirpichev <skirpichev@gmail.com>
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
2024-12-02 13:38:13 +00:00
Miss Islington (bot)
5017c81824
[3.13] gh-127190: Fix local_setattro() error handling (GH-127366) (#127367)
gh-127190: Fix local_setattro() error handling (GH-127366)

Don't make the assumption that the 'name' argument is a string. Use
repr() to format the 'name' argument instead.
(cherry picked from commit 20657fbdb1)

Co-authored-by: Victor Stinner <vstinner@python.org>
2024-12-01 06:48:04 +00:00
Peter Bierma
a442c87c4c
[3.13] gh-127341: Argument Clinic: fix compiler warnings for getters with docstrings (GH-127310) (#127431)
(cherry picked from commit 99490913a0)

Co-authored-by: Erlend E. Aasland <erlend@python.org>
2024-11-30 23:25:51 +01:00
Miss Islington (bot)
d2d1055129
[3.13] gh-124008: Fix calculation of the number of written bytes for the Windows console (GH-124059) (GH-127325)
Since MultiByteToWideChar()/WideCharToMultiByte() is not reversible if
the data contains invalid UTF-8 sequences, use binary search to
calculate the number of written bytes from the number of written
characters.

Also fix writing incomplete UTF-8 sequences.

Also fix handling of memory allocation failures.
(cherry picked from commit 3cf83d91a5)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2024-11-30 09:16:45 +00:00
Victor Stinner
9187ac3f2d
[3.13] gh-126316: Make grp.getgrall() thread-safe: add a mutex (#127055) (#127104)
* gh-126316: Make grp.getgrall() thread-safe: add a mutex (#127055)

grpmodule.c is no longer built with the limited C API, since PyMutex
is excluded from the limited C API.

(cherry picked from commit 3c2bd66e21)

* Revert ABI changes

Don't use Argument Clinic for grp.getgrgid() to avoid changing the
ABI (change PyInterpreterState structure by adding an "id"
identifier).
2024-11-26 12:01:50 +01:00
Miss Islington (bot)
a1b9663c41
[3.13] gh-127182: Fix io.StringIO.__setstate__ crash when None is the first value (GH-127219) (#127262)
gh-127182: Fix `io.StringIO.__setstate__` crash when `None` is the first value (GH-127219)
(cherry picked from commit a2ee899682)

Co-authored-by: sobolevn <mail@sobolevn.me>
Co-authored-by: Victor Stinner <vstinner@python.org>
2024-11-25 17:56:42 +00:00
Serhiy Storchaka
75ef92da29
[3.13] gh-109746: Make _thread.start_new_thread delete state of new thread on its startup failure (GH-109761) (GH-127171)
If Python fails to start newly created thread
due to failure of underlying PyThread_start_new_thread() call,
its state should be removed from interpreter' thread states list
to avoid its double cleanup.

(cherry picked from commit ca3ea9ad05)

Co-authored-by: Radislav Chugunov <52372310+chgnrdv@users.noreply.github.com>
2024-11-22 19:55:44 +00:00
Miss Islington (bot)
5468d219df
[3.13] gh-127065: Make methodcaller thread-safe in free threading build (GH-127109) (GH-127150)
The `methodcaller` C vectorcall implementation uses an arguments array
that is shared across calls. The first argument is modified on every
invocation. This isn't thread-safe in the free threading build. I think
it's also not safe in general, but for now just disable it in the free
threading build.
(cherry picked from commit f83ca6962a)

Co-authored-by: Sam Gross <colesbury@gmail.com>
2024-11-22 14:51:40 +00:00
Serhiy Storchaka
6e5e7bc5f8
[3.13] gh-126727: Fix locale.nl_langinfo(locale.ERA) (GH-126730) (GH-127097)
It now returns multiple era description segments separated by semicolons.
Previously it only returned the first segment on platforms with Glibc.
(cherry picked from commit 4803cd0244)
2024-11-21 11:49:19 +00:00
Miss Islington (bot)
bb98a0afd8
[3.13] gh-126991: Fix reference leak in loading pickle's opcode BUILD (GH-126990) (GH-127018)
If PyObject_SetItem() fails in the `load_build()` function of _pickle.c, no DECREF for the `dict` variable.
(cherry picked from commit 29cbcbd73b)

Co-authored-by: Justin Applegate <70449145+Legoclones@users.noreply.github.com>
2024-11-19 20:19:39 +02:00