Commit Graph

14370 Commits

Author SHA1 Message Date
Miss Islington (bot) 2da063e0b2
[3.13] gh-126405: fix use-after-free in `_asyncio.Future.remove_done_callback` (GH-126733) (#126736)
gh-126405: fix use-after-free in `_asyncio.Future.remove_done_callback` (GH-126733)
(cherry picked from commit 37c57dfad1)

Co-authored-by: Kumar Aditya <kumaraditya@python.org>
2024-11-12 13:04:27 +00:00
Miss Islington (bot) e194b21753
[3.13] gh-126654: Fix crash in several functions in `_interpreters` module (GH-126678) (#126681)
gh-126654: Fix crash in several functions in `_interpreters` module (GH-126678)
(cherry picked from commit 9fc2808eaf)

Co-authored-by: sobolevn <mail@sobolevn.me>
2024-11-11 12:01:22 +00:00
Miss Islington (bot) 07a6aa3f8f
[3.13] gh-125631: Enable setting persistent_id and persistent_load of pickler and unpickler (GH-125752) (GH-126528)
pickle.Pickler.persistent_id and pickle.Unpickler.persistent_load can
again be overridden as instance attributes.
(cherry picked from commit 223d3dc554)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2024-11-07 07:21:23 +00:00
Miss Islington (bot) 83827ad819
[3.13] gh-126461: Fix _Unpickler_ReadFromFile() error handling (GH-126485) (#126495)
gh-126461: Fix _Unpickler_ReadFromFile() error handling (GH-126485)

Handle _Unpickler_SetStringInput() failure.
(cherry picked from commit a1c57bcfd2)

Co-authored-by: Victor Stinner <vstinner@python.org>
2024-11-06 13:51:39 +00:00
Bénédikt Tran 6e9da38866
[3.13] gh-126313: Fix a crash in curses.napms() due to incorrect error handling (GH-126351) (#126493)
gh-126313: Fix a crash in curses.napms() due to incorrect error handling (GH-126351)
2024-11-06 14:33:23 +01:00
Miss Islington (bot) 6a084b9d60
[3.13] gh-126455: Disallow _ssl.SSLSocket instantiation (GH-126481) (#126486)
gh-126455: Disallow _ssl.SSLSocket instantiation (GH-126481)

Prevent creation of incomplete/invalid _ssl.SSLSocket objects when
created directly.
(cherry picked from commit b1c4ffc205)

Co-authored-by: Victor Stinner <vstinner@python.org>
2024-11-06 11:24:45 +00:00
Miss Islington (bot) ffb44cd08c
[3.13] gh-126425: Refactor `_lsprof_Profiler_enable` (GH-126426) (#126442)
gh-126425: Refactor `_lsprof_Profiler_enable` (GH-126426)

- Explicit memory management for `None` objects (since we still try to treat immortal objects as regular objects)
- Respect possible errors of `sys.monitoring.register_callback` call
(cherry picked from commit 75872605aa)

Co-authored-by: sobolevn <mail@sobolevn.me>
2024-11-05 12:48:18 +00:00
Miss Islington (bot) ce1a1a6021
[3.13] gh-126303: Fix pickling and copying of os.sched_param objects (GH-126336) (GH-126423)
(cherry picked from commit d3840503b0)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2024-11-05 06:50:33 +00:00
Miss Islington (bot) f58d5ab881
[3.13] gh-126138: Fix use-after-free in `_asyncio.Task` by evil `__getattribute__` (GH-126305) (#126324)
gh-126138: Fix use-after-free in `_asyncio.Task` by evil `__getattribute__` (GH-126305)
(cherry picked from commit f032f6ba8f)

Co-authored-by: Nico-Posada <102486290+Nico-Posada@users.noreply.github.com>
Co-authored-by: Carol Willing <carolcode@willingconsulting.com>
2024-11-02 08:09:18 +00:00
Miss Islington (bot) 1b9710c571
[3.13] gh-126220: Fix crash on calls to `_lsprof.Profiler` methods with 0 args (backportable) (GH-126271) (#126310)
gh-126220: Fix crash on calls to `_lsprof.Profiler` methods with 0 args (backportable) (GH-126271)
(cherry picked from commit 28b148fb32)

Co-authored-by: sobolevn <mail@sobolevn.me>
Co-authored-by: Erlend E. Aasland <erlend.aasland@protonmail.com>
2024-11-01 22:24:06 +00:00
Miss Islington (bot) abe64a3780
[3.13] gh-126080: fix UAF on `task->task_context` in `task_call_step_soon` due to an evil `loop.__getattribute__` (GH-126120) (#126250)
gh-126080: fix UAF on `task->task_context` in `task_call_step_soon` due to an evil `loop.__getattribute__` (GH-126120)
(cherry picked from commit 0e8665554b)

Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
2024-10-31 19:32:47 +00:00
Miss Islington (bot) 89664d4d48
[3.13] gh-126223: Propagate unicode errors in `_interpreters.create()` (GH-126224) (#126242)
gh-126223: Propagate unicode errors in `_interpreters.create()` (GH-126224)
(cherry picked from commit 01415213d7)

Co-authored-by: Peter Bierma <zintensitydev@gmail.com>
Co-authored-by: sobolevn <mail@sobolevn.me>
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
2024-10-31 14:46:36 +00:00
Miss Islington (bot) ac00bf0e96
[3.13] gh-126083: Fix a reference leak in `asyncio.Task` when reinitializing with new non-`None` context (GH-126103) (#126229)
gh-126083: Fix a reference leak in `asyncio.Task` when reinitializing with new non-`None` context (GH-126103)
(cherry picked from commit d07dcce693)

Co-authored-by: Nico-Posada <102486290+Nico-Posada@users.noreply.github.com>
2024-10-31 08:14:00 +00:00
Miss Islington (bot) e2c188455f
[3.13] gh-126106: Fix `NULL` possible derefrence in `Modules/_ssl.c` (GH-126111) (#126116)
gh-126106: Fix `NULL` possible derefrence in `Modules/_ssl.c` (GH-126111)
(cherry picked from commit a64a1c9206)

Co-authored-by: sobolevn <mail@sobolevn.me>
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
2024-10-29 09:29:10 +00:00
Miss Islington (bot) e7c63107d1
[3.13] Align functools.reduce() docstring with PEP-257 (GH-126045) (#126113)
Yak-shave in preparation for Argument Clinic adaption in gh-125999.

(cherry picked from commit 9b14083497)

Co-authored-by: Sergey B Kirpichev <skirpichev@gmail.com>
2024-10-29 10:13:35 +01:00
Miss Islington (bot) 97c2e6ac27
[3.13] gh-126035: add missing whitespace to *Py_EnterRecursiveCall() messages (GH-126036) (#126058)
(cherry picked from commit 19e93e2e26)

Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
2024-10-27 22:19:37 +00:00
Miss Islington (bot) ac31a2607f
[3.13] gh-125966: fix use-after-free on `fut->fut_callback0` due to an evil callback's `__eq__` in asyncio (GH-125967) (#126047)
gh-125966: fix use-after-free on `fut->fut_callback0` due to an evil callback's `__eq__` in asyncio (GH-125967)
(cherry picked from commit ed5059eeb1)

Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
2024-10-27 17:36:10 +00:00
Miss Islington (bot) 25421c715d
[3.13] gh-125984: fix use-after-free on `fut->fut_{callback,context}0` due to an evil `loop.__getattribute__` (GH-126003) (#126043)
gh-125984: fix use-after-free on `fut->fut_{callback,context}0` due to an evil `loop.__getattribute__` (GH-126003)
(cherry picked from commit f819d4301d)

Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
2024-10-27 15:28:02 +00:00
Miss Islington (bot) 9c6cda5ccb
[3.13] gh-125969: fix OOB in `future_schedule_callbacks` due to an evil `call_soon` (GH-125970) (#125991)
gh-125969: fix OOB in `future_schedule_callbacks` due to an evil `call_soon` (GH-125970)
(cherry picked from commit c5b99f5c2c)

Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
Co-authored-by: Andrew Svetlov <andrew.svetlov@gmail.com>
2024-10-25 18:43:07 +00:00
Kumar Aditya f54e1a2d64
[3.13] GH-125789: fix `fut._callbacks` to always return a copy of callbacks (#125922) (#125976)
GH-125789: fix `fut._callbacks` to always return a copy of callbacks (#125922)

Fix `asyncio.Future._callbacks` to always return a copy of the internal list of callbacks to avoid mutation from user code affecting the internal state.

(cherry picked from commit cae853e3b4)
2024-10-25 13:19:31 +00:00
Miss Islington (bot) 77d79989fd
[3.13] gh-123978: Remove broken time.thread_time() on NetBSD (GH-124116) (GH-124425)
(cherry picked from commit e670a113b5)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2024-10-23 19:39:34 +03:00
Miss Islington (bot) 0e350d4bf6
[3.13] gh-125716: Use a Global Mutex When Initializing Global State For the _interpqueues Module (gh-125817)
This includes a drive-by cleanup in _queues_init() and _queues_fini().

This change also applies to the _interpchannels module.

(cherry picked from commit 4848b0b92c, AKA gh-125803)

Co-authored-by: Eric Snow <ericsnowcurrently@gmail.com>
2024-10-21 22:16:32 +00:00
Miss Islington (bot) b752764f9e
[3.13] gh-125716: Raise an Exception If _globals_init() Fails In the _interpqueues Module (gh-125808)
The fix applies to the _interpchannels module as well.

I've also included a drive-by typo fix for _interpqueues.

(cherry picked from commit 44f841f01a, AKA gh-125802)

Co-authored-by: Eric Snow <ericsnowcurrently@gmail.com>
2024-10-21 20:05:06 +00:00
Miss Islington (bot) c1c3f5d19e
[3.13] gh-124969: Make locale.nl_langinfo(locale.ALT_DIGITS) returning a string again (GH-125774) (GH-125804)
This is a follow up of GH-124974. Only Glibc needed a fix.
Now the returned value is a string consisting of semicolon-separated
symbols on all Posix platforms.
(cherry picked from commit dcc4fb2c90)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2024-10-21 19:30:23 +00:00
Miss Islington (bot) e57831f301
[3.13] gh-125667: Statically Initialize the Arg Converter Data Values in _interpqueuesmodule.c (gh-125670)
gh-125667: Statically Initialize the Arg Converter Data Values in _interpqueuesmodule.c (gh-125668)
(cherry picked from commit 7cf2dbc3cb)

Co-authored-by: Eric Snow <ericsnowcurrently@gmail.com>
2024-10-18 00:13:54 +00:00
Serhiy Storchaka 08ccbb9b3f
[3.13] gh-52551: Fix encoding issues in strftime() (GH-125193) (GH-125657)
Fix time.strftime(), the strftime() method and formatting of the
datetime classes datetime, date and time.

* Characters not encodable in the current locale are now acceptable in
  the format string.
* Surrogate pairs and sequence of surrogatescape-encoded bytes are no
  longer recombinated.
* Embedded null character no longer terminates the format string.

This fixes also gh-78662 and gh-124531.

(cherry picked from commit ad3eac1963)
2024-10-17 22:48:34 +03:00
Miss Islington (bot) 6474e296c0
[3.13] gh-125243: Fix ZoneInfo data race in free threading build (GH-125281) (gh-125414)
Lock `ZoneInfoType` to protect accesses to `ZONEINFO_STRONG_CACHE`.
Refactor the `tp_new` handler to use Argument Clinic so that we can just
use `@critical_section` annotations on the relevant functions.

Also use `PyDict_SetDefaultRef` instead of `PyDict_SetDefault` when
inserting into the `TIMEDELTA_CACHE`.
(cherry picked from commit f1d33dbddd)

Co-authored-by: Sam Gross <colesbury@gmail.com>
2024-10-15 17:02:32 -04:00
Jelle Zijlstra e646cc369e
[3.13] gh-124917: Allow keyword args to os.path.exists/lexists on Windows (GH-124918) (#125332)
(cherry picked from commit cc2938a189)
2024-10-11 15:18:33 -07:00
Miss Islington (bot) f589513334
[3.13] gh-116738: Make `_csv` module thread-safe (GH-118344) (#125328)
gh-116738: Make `_csv` module thread-safe (GH-118344)
(cherry picked from commit a00221e5a7)

Co-authored-by: AN Long <aisk@users.noreply.github.com>
2024-10-11 18:22:56 +00:00
Miss Islington (bot) 66b8cb1142
[3.13] gh-125235: Keep `_tkinter` TCL paths pointing to base installation on Windows (GH-125250) (#125312)
gh-125235: Keep `_tkinter` TCL paths pointing to base installation on Windows (GH-125250)
(cherry picked from commit b3aa1b5fe2)

Signed-off-by: y5c4l3 <y5c4l3@proton.me>
Co-authored-by: Y5 <124019959+y5c4l3@users.noreply.github.com>
2024-10-11 09:34:04 +00:00
Serhiy Storchaka 26a93189e4
[3.13] gh-124969: Fix locale.nl_langinfo(locale.ALT_DIGITS) (GH-124974) (#125232)
Returns a tuple of up to 100 strings for ALT_DIGITS lookup (an empty tuple on most locales).
Previously it returned the first item of that tuple or an empty string.
(cherry picked from commit 21c04e1a97)
2024-10-11 05:56:22 +08:00
Sergey B Kirpichev c2cb1a89b7
[3.13] gh-125118: don't copy arbitrary values to _Bool in the struct module (GH-125169) (#125263)
memcopy'ing arbitrary values to _Bool variable triggers undefined
behaviour. Avoid this.
We assume that `false` is represented by all zero bytes.

Credits to Alex Gaynor.

(cherry picked from commit 87d7315ac5)

Co-authored-by: Sam Gross <colesbury@gmail.com>
Co-authored-by: Victor Stinner <vstinner@python.org>
Co-authored-by: Petr Viktorin <encukou@gmail.com>
2024-10-10 14:58:57 +00:00
Raymond Hettinger 7bc99dd49e
[3.13] Tee of tee was not producing n independent iterators (gh-123884) (gh-125081) 2024-10-08 14:11:43 -05:00
Kumar Aditya 20242a437c
[3.13] gh-117721: use PyMutex in `_thread.lock` (#125110) (#125116)
* gh-117721: use PyMutex in `_thread.lock` (#125110)

(cherry picked from commit fca552993d)
2024-10-08 21:16:48 +05:30
Jelle Zijlstra 761c3b280b
[3.13] gh-102511: Change the `os.path.splitroot` param name from `path` back to `p` (GH-124097) (#124919)
(cherry picked from commit 3b6bfa77aa)

Co-authored-by: sobolevn <mail@sobolevn.me>
2024-10-07 18:42:49 -07:00
Miss Islington (bot) 2d3087b3cf
[3.13] gh-120378: Fix crash caused by integer overflow in `curses` (GH-124555) (#124905)
gh-120378: Fix crash caused by integer overflow in `curses` (GH-124555)

This is actually an upstream problem in curses, and has been reported
to them already:
https://lists.gnu.org/archive/html/bug-ncurses/2024-09/msg00101.html

This is a nice workaround in the meantime to prevent the segfault.

(cherry picked from commit c2ba931318)

Co-authored-by: Peter Bierma <zintensitydev@gmail.com>
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
2024-10-07 23:46:57 +02:00
Miss Islington (bot) f5f1d45f17
[3.13] gh-116810: fix memory leak in ssl module (GH-123249) (#124800)
gh-116810: fix memory leak in ssl module (GH-123249)

Resolve a memory leak introduced in CPython 3.10's :mod:`ssl` when the :attr:`ssl.SSLSocket.session` property was accessed. Speeds up read and write access to said property by no longer unnecessarily cloning session objects via serialization.

(cherry picked from commit 7e7223e18f)

Co-authored-by: Jeffrey R. Van Voorst <jeff.vanvoorst@gmail.com>
Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com>
Co-authored-by: Peter Bierma <zintensitydev@gmail.com>
Co-authored-by: Gregory P. Smith <greg@krypto.org>
Co-authored-by: Antoine Pitrou <antoine@python.org>
2024-10-07 23:46:29 +02:00
Victor Stinner d432fa43b9
[3.13] Fix typos (#123775) (#123866)
Fix typos (#123775)

(cherry picked from commit 9017b95ff2)

Co-authored-by: algonell <algonell@gmail.com>
2024-10-07 23:44:31 +02:00
T. Wouters e0eb44ad49
[3.13] GH-124567: Revert the Incremental GC in 3.13 (#124770)
Revert the incremental GC in 3.13, since it's not clear that without further turning, the benefits outweigh the costs.

Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com>
2024-09-30 21:27:29 +00:00
Sergey B Kirpichev 99185bd649
[3.13] gh-123836: workaround fmod(x, y) bug on Windows (GH-124171) (#124187)
Buildbot failure on Windows 10 with MSC v.1916 64 bit (AMD64):
FAIL: testFmod (test.test_math.MathTests.testFmod)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "D:\buildarea\3.x.bolen-windows10\build\Lib\test\test_math.py", line 605, in testFmod
    self.ftest('fmod(-10, 1)', math.fmod(-10, 1), -0.0)
    ~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "D:\buildarea\3.x.bolen-windows10\build\Lib\test\test_math.py", line 258, in ftest
    self.fail("{}: {}".format(name, failure))
    ~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AssertionError: fmod(-10, 1): expected -0.0, got 0.0 (zero has wrong sign)

Here Windows loose sign of the result; if y is nonzero, the result
should have the same sign as x.

This amends commit 28aea5d07d.
(cherry picked from commit f4dd440210)
2024-09-29 18:14:02 -07:00
Miss Islington (bot) dbfc37a5f8
[3.13] gh-123797: Check for runtime availability of `ptsname_r` on macos (GH-123806) (#124270)
gh-123797: Check for runtime availability of `ptsname_r` on macos (GH-123806)
(cherry picked from commit 3e36e5aef1)

Co-authored-by: sobolevn <mail@sobolevn.me>
2024-09-29 18:06:53 -07:00
Miss Islington (bot) dddae6647e
[3.13] gh-124248: Fix crash in struct when processing 0p fields (GH-124251) (#124277)
gh-124248: Fix crash in struct when processing 0p fields (GH-124251)
(cherry picked from commit 63f196090f)

Co-authored-by: Brian Schubert <brianm.schubert@gmail.com>
2024-09-29 18:06:32 -07:00
Miss Islington (bot) 8169d2971f
[3.13] gh-123017: Add Android to the list of platforms where `strftime` doesn't support negative years (GH-124467) (#124674)
gh-123017: Add Android to the list of platforms where `strftime` doesn't support negative years (GH-124467)

Add Android to the list of platforms where `strftime` doesn't support negative years
(cherry picked from commit 0a3577bdfc)

Co-authored-by: Malcolm Smith <smith@chaquo.com>
2024-09-27 11:00:49 -07:00
Malcolm Smith 9f5b921491
[3.13] gh-123014: Disable pidfd API on older Android versions (GH-124458) (#124543)
gh-123014: Disable pidfd API on older Android versions (#124458)

(cherry picked from commit c58c572a65)
2024-09-26 13:36:12 -07:00
Miss Islington (bot) 9d21c46e31
[3.13] gh-121023: Improve `_xxtestfuzz/README.rst` (GH-121024) (#124140)
gh-121023: Improve `_xxtestfuzz/README.rst` (GH-121024)
(cherry picked from commit a9c2bc1634)

Co-authored-by: sobolevn <mail@sobolevn.me>
Co-authored-by: Illia Volochii <illia.volochii@gmail.com>
2024-09-23 17:23:54 -07:00
Miss Islington (bot) de8dc92db7
[3.13] gh-123880: Allow recursive import of single-phase-init modules (GH-123950) (#124273)
gh-123880: Allow recursive import of single-phase-init modules (GH-123950)

(cherry picked from commit aee219f455)

Co-authored-by: Petr Viktorin <encukou@gmail.com>
Co-authored-by: Shantanu <12621235+hauntsaninja@users.noreply.github.com>
Co-authored-by: Brett Cannon <brett@python.org>
2024-09-23 12:56:00 -07:00
Miss Islington (bot) e443187fce
[3.13] gh-123657: Fix crash and refleak in `decimal.getcontext()` (GH-123703) (GH-123774)
(cherry picked from commit 853588e24c)

Co-authored-by: neonene <53406459+neonene@users.noreply.github.com>
2024-09-06 15:18:01 +02:00
Miss Islington (bot) 9810dfa352
[3.13] gh-123678: Upgrade libexpat 2.6.3 (GH-123689) (GH-123707)
gh-123678: Upgrade libexpat 2.6.3 (GH-123689)

(cherry picked from commit 40bdb0deee)

Co-authored-by: Seth Michael Larson <seth@python.org>
2024-09-05 13:37:40 +02:00
Petr Viktorin d655c65561
[3.13] gh-123091: Use more _Py_IsImmortalLoose() (GH-123602) (GH-123622)
Switch more _Py_IsImmortal(...) assertions to _Py_IsImmortalLoose(...)

The remaining calls to _Py_IsImmortal are in free-threaded-only code,
initialization of core objects, tests, and guards that fall back to
code that works with mortal objects.

(cherry picked from commit 57c471a688)
2024-09-03 12:36:42 +02:00
Miss Islington (bot) ab29053784
[3.13] gh-123431: Harmonize extension code checks in pickle (GH-123434) (#123459)
gh-123431: Harmonize extension code checks in pickle (GH-123434)

This checks are redundant in normal circumstances and can only work if
the extension registry was intentionally broken.

* The Python implementation now raises exception for the extension code
  with false boolean value.
* Simplify the C code. RuntimeError is now raised in explicit checks.
* Add many tests.
(cherry picked from commit 0c3ea30238)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2024-09-02 13:17:16 +02:00
Miss Islington (bot) cbcb9e1c0f
[3.13] gh-111495: Add tests for PyNumber C API (GH-111996) (#123375)
gh-111495: Add tests for PyNumber C API (GH-111996)
(cherry picked from commit 2f20f5a9bc)

Co-authored-by: Sergey B Kirpichev <skirpichev@gmail.com>
2024-09-02 13:11:06 +02:00
Miss Islington (bot) d9e4c4b61c
[3.13] gh-123213: Fixed xml.etree.ElementTree.Element.extend and assignment to no longer hide exceptions (GH-123214) (#123257)
gh-123213: Fixed xml.etree.ElementTree.Element.extend and assignment to no longer hide exceptions (GH-123214)
(cherry picked from commit 90b6d0e0f8)

Co-authored-by: Bar Harel <bharel@barharel.com>
2024-09-02 13:10:09 +02:00
Serhiy Storchaka 8b6dd92db7
[3.13] gh-122688: Fix support of var-positional parameter in Argument Clinic (GH-122689) (#122852)
* Parameters after the var-positional parameter are now keyword-only
  instead of positional-or-keyword.
* Correctly calculate min_kw_only.
* Raise errors for invalid combinations of the var-positional parameter
  with "*", "/" and deprecation markers.
(cherry picked from commit 8393608dd9)
2024-09-02 13:03:04 +02:00
Miss Islington (bot) f070398669
[3.13] gh-100256: Skip inaccessible registry keys in the WinAPI mimetype implementation (GH-122047) (#122786)
gh-100256: Skip inaccessible registry keys in the WinAPI mimetype implementation (GH-122047)
(cherry picked from commit 0bd93755f3)

Co-authored-by: Lucas Esposito <LucasEsposito@users.noreply.github.com>
2024-09-02 12:58:53 +02:00
Miss Islington (bot) bd29ce8509
[3.13] gh-123448: Move `_PyNoDefault_Type` to the static types array (GH-123449) (#123450)
(cherry picked from commit c9930f5022)

Co-authored-by: Peter Bierma <zintensitydev@gmail.com>
2024-08-28 18:57:28 -07:00
Sergey B Kirpichev ee464309a5
[3.13] gh-111495: Add tests for PyTuple C API (GH-118757) (GH-123371)
(cherry picked from commit dbc1752d41)

Co-authored-by: kalyanr <kalyan.ben10@live.com>
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
Co-authored-by: Victor Stinner <vstinner@python.org>
2024-08-27 12:07:17 +03:00
Miss Islington (bot) a65fe07db4
[3.13] gh-123243: Fix reference leak in `_decimal` (GH-123244) (#123280)
gh-123243: Fix reference leak in `_decimal` (GH-123244)
(cherry picked from commit 5ff638f1b5)

Co-authored-by: neonene <53406459+neonene@users.noreply.github.com>
2024-08-24 04:33:49 +00:00
Miss Islington (bot) 032b6467fa
[3.13] gh-122081: fixed crash in decimal.IEEEContext() (GH-122082) (#123136)
gh-122081: fixed crash in decimal.IEEEContext() (GH-122082)

* gh-122081: fixed crash in decimal.IEEEContext()

Now

$ ./configure CFLAGS=-DEXTRA_FUNCTIONALITY -q && make -s && \
     ./python -m test test_decimal

- PASS

* Apply suggestions from code review



* Update Misc/NEWS.d/next/Library/2024-07-21-10-45-24.gh-issue-122081.dNrYMq.rst

* Apply suggestions from code review

---------

(cherry picked from commit b9e10d1a0f)

Co-authored-by: Sergey B Kirpichev <skirpichev@gmail.com>
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
Co-authored-by: Kumar Aditya <kumaraditya@python.org>
2024-08-19 14:14:11 +05:30
Miss Islington (bot) 69cf92fbca
[3.13] gh-116622: Don't expose `FICLONE` ioctl on Android (GH-122522) (#122539)
gh-116622: Don't expose `FICLONE` ioctl on Android (GH-122522)

Don't expose `FICLONE` ioctl on Android

(cherry picked from commit 06656e259b)

Co-authored-by: Malcolm Smith <smith@chaquo.com>
Co-authored-by: Russell Keith-Magee <russell@keith-magee.com>
2024-08-16 16:07:27 +08:00
Miss Islington (bot) 42005c77a0
[3.13] gh-116622: Rename build variable MODULE_LDFLAGS back to LIBPYTHON (GH-122764) (GH-122842)
gh-116622: Rename build variable MODULE_LDFLAGS back to LIBPYTHON (GH-122764)

(LIBPYTHON was renamed MODULE_LDFLAGS in commit 7f5e3f04f.)
(cherry picked from commit 2f5c3b09e4)

Co-authored-by: Malcolm Smith <smith@chaquo.com>
2024-08-09 14:45:04 -07:00
Peter Bierma e8fb088dba
[3.13] gh-122695: Fix double-free when using `gc.get_referents` with a freed `_asyncio.FutureIter` (#122837)
* Backport #122834 for 3.13
2024-08-09 19:36:36 +05:30
Serhiy Storchaka 1fd1c6c738
[3.13] gh-118814: Fix the TypeVar constructor when name is passed by keyword (GH-122664) (GH-122806)
Fix _PyArg_UnpackKeywordsWithVararg for the case when argument for
positional-or-keyword parameter is passed by keyword.
There was only one such case in the stdlib -- the TypeVar constructor.
(cherry picked from commit 540fcc62f5)
2024-08-08 09:49:21 +03:00
Miss Islington (bot) 5c161cb832
[3.13] gh-122728: Fix SystemError in PyEval_GetLocals() (GH-122735) (#122757)
gh-122728: Fix SystemError in PyEval_GetLocals() (GH-122735)

Fix PyEval_GetLocals() to avoid SystemError ("bad argument to
internal function"). Don't redefine the 'ret' variable in the if
block.

Add an unit test on PyEval_GetLocals().
(cherry picked from commit 4767a6e31c)

Co-authored-by: Victor Stinner <vstinner@python.org>
2024-08-06 23:37:10 +02:00
Miss Islington (bot) c1efeb3234
[3.13] gh-120974: Make asyncio `swap_current_task` safe in free-threaded build (GH-122317) (#122612)
gh-120974: Make asyncio `swap_current_task` safe in free-threaded build (GH-122317)

* gh-120974: Make asyncio `swap_current_task` safe in free-threaded build
(cherry picked from commit b5e6fb39a2)

Co-authored-by: Sam Gross <colesbury@gmail.com>
2024-08-02 13:58:24 +00:00
Miss Islington (bot) d8701e2f7e
[3.13] gh-122311: Fix a refleak in pickle (GH-122411) (GH-122415)
(cherry picked from commit 68840e91ac)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2024-07-29 19:16:15 +00:00
Serhiy Storchaka 9f6f8790ef
Revert "[3.13] gh-120713: Normalize year with century for datetime.strftime (GH-120820) (GH-121144)" (GH-122408)
This reverts commit 009618f112.
2024-07-29 21:55:28 +03:00
Miss Islington (bot) c26dd270f7
[3.13] gh-122311: Fix some error messages in pickle (GH-122386) (GH-122387)
(cherry picked from commit 3b034d26eb)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2024-07-29 12:27:14 +03:00
Miss Islington (bot) 6b9a5af72f
[3.13] gh-122332: Fix missing `NULL` check in `asyncio.Task.get_coro` (GH-122338) (#122344)
gh-122332: Fix missing `NULL` check in `asyncio.Task.get_coro` (GH-122338)
(cherry picked from commit c08696286f)

Co-authored-by: Peter Bierma <zintensitydev@gmail.com>
2024-07-27 12:36:50 +05:30
Miss Islington (bot) aca41cfe99
[3.13] GH-121832: Assert that the version number of static builtin types is not changed by PyType_Modified (gh-122290)
Update datetime module and test_type_cache.py to not call PyType_Modified.

(cherry picked from commit e55b05f29e, AKA gh--122182)

Co-authored-by: Mark Shannon <mark@hotpy.org>
2024-07-25 17:34:01 +00:00
Miss Islington (bot) dd270f610c
[3.13] gh-121489: Export private _PyBytes_Join() again (GH-122267) (#122287)
gh-121489: Export private _PyBytes_Join() again (GH-122267)
(cherry picked from commit aef95eb107)

Co-authored-by: Marc Mueller <30130371+cdce8p@users.noreply.github.com>
2024-07-25 16:06:31 +00:00
Miss Islington (bot) 984f8aaa2f
[3.13] gh-82951: Fix serializing by name in pickle protocols < 4 (GH-122149) (GH-122264)
Serializing objects with complex __qualname__ (such as unbound methods and
nested classes) by name no longer involves serializing parent objects by value
in pickle protocols < 4.
(cherry picked from commit dc07f65a53)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2024-07-25 13:44:55 +03:00
Miss Islington (bot) 6933c4ace9
[3.13] gh-113785: csv: fields starting with escapechar are not quoted (GH-122110) (GH-122258)
(cherry picked from commit a3327dbfd4)

Co-authored-by: Mikołaj Kuranowski <mkuranowski@gmail.com>
2024-07-25 07:29:36 +00:00
Miss Islington (bot) 77ab53a5f3
[3.13] gh-120974: Make _asyncio._leave_task atomic in the free-threaded build (GH-122139) (#122186)
gh-120974: Make _asyncio._leave_task atomic in the free-threaded build (GH-122139)

* gh-120974: Make _asyncio._leave_task atomic in the free-threaded build

Update `_PyDict_DelItemIf` to allow for an argument to be passed to the
predicate.
(cherry picked from commit a15feded71)

Co-authored-by: Sam Gross <colesbury@gmail.com>
2024-07-23 17:30:58 +00:00
Miss Islington (bot) 48154e7053
[3.13] gh-120974: Make _asyncio._enter_task atomic in the free-threaded build (GH-122138) (#122152)
gh-120974: Make _asyncio._enter_task atomic in the free-threaded build (GH-122138)

Use `PyDict_SetDefaultRef` to set the current task in a single operation
under the dictionary's lock.
(cherry picked from commit 47847aa8ef)

Co-authored-by: Sam Gross <colesbury@gmail.com>
2024-07-23 09:17:52 +00:00
Miss Islington (bot) 148beb6de9
[3.13] gh-121957: Emit audit events for `python -i` and `python -m asyncio` (GH-121958) (GH-122115)
Relatedly, emit the `cpython.run_startup` event from the Python version of
`PYTHONSTARTUP` handling.
(cherry picked from commit dc93d1125f)

Co-authored-by: Łukasz Langa <lukasz@langa.pl>
2024-07-22 13:36:57 +02:00
Sam Gross f3c79cb400
[3.13] gh-121621: Disable asyncio freelist in free-threaded build (GH-122046) (#122048)
The futureobj freelist isn't thread-safe. We intend to re-enable the
freelist in a thread-safe way for 3.14 (but not 3.13).
(cherry picked from commit 97248204a1)
2024-07-19 19:55:15 +00:00
Miss Islington (bot) bf7f4f357b
[3.13] gh-120973: Fix thread-safety issues with `threading.local` (GH-121655) (#122042)
This is a small refactoring to the current design that allows us to
avoid manually iterating over threads.

This should also fix gh-118490.
(cherry picked from commit e059aa6b01)

Co-authored-by: mpage <mpage@meta.com>
2024-07-19 17:49:34 +00:00
Serhiy Storchaka a45d9051ed
[3.13] gh-121905: Consistently use "floating-point" instead of "floating point" (GH-121907) (GH-122012)
(cherry picked from commit 1a0c7b9ba4)
2024-07-19 09:13:08 +00:00
Miss Islington (bot) e992cc3922
[3.13] gh-120289: Add external timer in traverse of _lsprof.Profiler (GH-121998) (#122000)
gh-120289: Add external timer in traverse of _lsprof.Profiler (GH-121998)
(cherry picked from commit eaf094c09b)

Co-authored-by: Tian Gao <gaogaotiantian@hotmail.com>
2024-07-19 04:10:11 +00:00
Miss Islington (bot) 721a7dde11
[3.13] gh-120289: Disallow disable() and clear() in external timer to prevent use-after-free (GH-120297) (#121984)
gh-120289: Disallow disable() and clear() in external timer to prevent use-after-free (GH-120297)
(cherry picked from commit 1ab1778283)

Co-authored-by: Tian Gao <gaogaotiantian@hotmail.com>
2024-07-18 13:26:47 -07:00
Miss Islington (bot) afa5321c6c
[3.13] gh-121621: Move asyncio_running_loop to private struct (GH-121939) (#121943)
gh-121621: Move asyncio_running_loop to private struct (GH-121939)

This avoids changing the ABI and keeps the field in the private struct.
(cherry picked from commit 81fd625b5c)

Co-authored-by: Sam Gross <colesbury@gmail.com>
2024-07-18 01:52:39 -07:00
Miss Islington (bot) 449529a8c2
[3.13] gh-121925: Fix uninitialized variables in `main.c` (GH-121926) (#121931)
gh-121925: Fix uninitialized variables in `main.c` (GH-121926)
(cherry picked from commit f4bc84d261)

Co-authored-by: sobolevn <mail@sobolevn.me>
2024-07-17 17:00:42 +00:00
Miss Islington (bot) 3d9692dbf8
[3.13] gh-120678: pyrepl: Include globals from modules passed with `-i` (GH-120904) (#121916)
(cherry picked from commit ac07451116)

Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
Co-authored-by: Łukasz Langa <lukasz@langa.pl>
2024-07-17 16:52:46 +02:00
Petr Viktorin 4395d68c70
[3.13] gh-113993: Don't immortalize in PyUnicode_InternInPlace; keep immortalizing in other API (GH-121364) (GH-121854)
* Switch PyUnicode_InternInPlace to _PyUnicode_InternMortal, clarify docs

* Document immortality in some functions that take `const char *`

This is PyUnicode_InternFromString;
PyDict_SetItemString, PyObject_SetAttrString;
PyObject_DelAttrString; PyUnicode_InternFromString;
and the PyModule_Add convenience functions.

Always point out a non-immortalizing alternative.

* Don't immortalize user-provided attr names in _ctypes
(cherry picked from commit b4aedb23ae)
2024-07-17 14:51:42 +02:00
Miss Islington (bot) 06d76c4b94
[3.13] gh-121621: Move asyncio running loop to thread state (GH-121695) (GH-121864)
gh-121621: Move asyncio running loop to thread state (GH-121695)
(cherry picked from commit 69c68de43a)

Co-authored-by: Ken Jin <kenjin@python.org>
2024-07-17 01:57:37 +08:00
Miss Islington (bot) 93ee63ae20
[3.13] gh-121791: Check for `NULL` in `MethodDescriptor2_new` in `_testcapi` (GH-121792) (#121839)
gh-121791: Check for `NULL` in `MethodDescriptor2_new` in `_testcapi` (GH-121792)
(cherry picked from commit 8b6d475581)

Co-authored-by: sobolevn <mail@sobolevn.me>
2024-07-16 08:55:37 +00:00
Miss Islington (bot) 835f4add60
[3.13] gh-76785: Expand How Interpreter Channels Handle Interpreter Finalization (gh-121811)
See 6b98b274b6 for an explanation of the problem and solution.  Here I've applied the solution to channels.

(cherry picked from commit 8b209fd4f8, AKA gh-121805)

Co-authored-by: Eric Snow <ericsnowcurrently@gmail.com>
2024-07-15 20:15:47 +00:00
Miss Islington (bot) f19ccfdae0
[3.13] gh-76785: Expand How Interpreter Queues Handle Interpreter Finalization (gh-121807)
Any cross-interpreter mechanism for passing objects between interpreters must be very careful to respect isolation, even when the object is effectively immutable (e.g. int, str).  Here this especially relates to when an interpreter sends one of its objects, and then is destroyed while the inter-interpreter machinery (e.g. queue) still holds a reference to the object.

When I added interpreters.Queue, I dealt with that case (using an atexit hook) by silently removing all items from the queue that were added by the finalizing interpreter.

Later, while working on concurrent.futures.InterpreterPoolExecutor (gh-116430), I noticed it was somewhat surprising when items were silently removed from the queue when the originating interpreter was destroyed.  (See my comment on that PR.)
 It took me a little while to realize what was going on.  I expect that users, which much less context than I have, would experience the same pain.

My approach, here, to improving the situation is to give users three options:

1. return a singleton (interpreters.queues.UNBOUND) from Queue.get() in place of each removed item
2. raise an exception (interpreters.queues.ItemInterpreterDestroyed) from Queue.get() in place of each removed item
3. existing behavior: silently remove each item (i.e. Queue.get() skips each one)

The default will now be (1), but users can still explicitly opt in any of them, including to the silent removal behavior.

The behavior for each item may be set with the corresponding Queue.put() call. and a queue-wide default may be set when the queue is created.  (This is the same as I did for "synconly".)

(cherry picked from commit 6b98b274b6, AKA gh-116431)

Co-authored-by: Eric Snow <ericsnowcurrently@gmail.com>
2024-07-15 19:13:51 +00:00
Sam Gross a2a4f5ebc5
[3.13] gh-121621: Use PyMutex for writes to asyncio state (GH-121622) (#121774)
(cherry picked from commit 5d6861ad06)

Co-authored-by: Ken Jin <kenjin@python.org>
Co-authored-by: Kumar Aditya <kumaraditya@python.org>
2024-07-15 10:44:35 +05:30
Miss Islington (bot) 15c875a57c
[3.13] Update retroactive comments from GH-117741 (segfault in `FutureIter_dealloc`) (GH-121638) (GH-121642)
Update retroactive comments from GH-117741 (segfault in `FutureIter_dealloc`) (GH-121638)

Address comments
(cherry picked from commit 65fededf9c)

Co-authored-by: Savannah Ostrowski <savannahostrowski@gmail.com>
2024-07-12 09:00:09 +00:00
Miss Islington (bot) 35f7155bc3
[3.13] gh-121103: Put free-threaded libraries in `lib/python3.14t` (GH-121293) (#121631)
On POSIX systems, excluding macOS framework installs, the lib directory
for the free-threaded build now includes a "t" suffix to avoid conflicts
with a co-located default build installation.
(cherry picked from commit e8c91d90ba)

Co-authored-by: Sam Gross <colesbury@gmail.com>
2024-07-11 21:00:28 +00:00
Miss Islington (bot) 3b5f8d256c
[3.13] gh-121592: Make select.poll() and related objects thread-safe (GH-121594) (#121623)
This makes select.poll() and kqueue() objects thread-safe in the
free-threaded build. Note that calling close() concurrently with other
functions is still not thread-safe due to races on file descriptors
(gh-121544).
(cherry picked from commit 44937d11a6)

Co-authored-by: Sam Gross <colesbury@gmail.com>
2024-07-11 14:44:54 +00:00
Miss Islington (bot) 5bb117586e
[3.13] gh-121596: Fix Sharing Interpreter Channels (gh-121600)
This fixes a mistake in gh-113012 and adds a test that verifies the fix.

(cherry picked from commit 35a67e36aa, AKA gh-121597)

Co-authored-by: Eric Snow <ericsnowcurrently@gmail.com>
2024-07-10 21:54:47 +00:00
Miss Islington (bot) c128718f30
[3.13] gh-121368: Fix seq lock memory ordering in _PyType_Lookup (GH-121388) (#121505)
The `_PySeqLock_EndRead` function needs an acquire fence to ensure that
the load of the sequence happens after any loads within the read side
critical section. The missing fence can trigger bugs on macOS arm64.

Additionally, we need a release fence in `_PySeqLock_LockWrite` to
ensure that the sequence update is visible before any modifications to
the cache entry.
(cherry picked from commit 1d3cf79a50)

Co-authored-by: Sam Gross <colesbury@gmail.com>
2024-07-08 19:15:58 +00:00
Miss Islington (bot) bccfd8a53f
[3.13] gh-121374: Correct docstrings in `_interpchannels` (gh-121501)
(cherry picked from commit 5289550b33, AKA gh-121418)

Co-authored-by: Max Muoto <maxmuoto@gmail.com>
2024-07-08 16:57:10 +00:00
neonene 2c3aa527fd
[3.13] gh-120782: Update internal type cache when reloading datetime (GH-120829) (#120855)
* [3.13] gh-120782: Update internal type cache when reloading datetime

When reloading _datetime module, the single-phase version did not invoke the PyInit__datetime function, whereas the current multi-phase version updates the static types through the module init. The outdated static type cache in the interpreter state needs to be invalidated at the end of reloading the multi-phase module.
2024-07-03 13:52:51 +05:30
Miss Islington (bot) 85971492b7
[3.13] gh-116181: Remove Py_BUILD_CORE_BUILTIN and Py_BUILD_CORE_MODULE in rotatingtree.c (GH-121260) (#121307)
gh-116181: Remove Py_BUILD_CORE_BUILTIN and Py_BUILD_CORE_MODULE in rotatingtree.c (GH-121260)
(cherry picked from commit 705a123898)

Co-authored-by: AN Long <aisk@users.noreply.github.com>
2024-07-03 07:59:26 +00:00
Miss Islington (bot) 06fd745dd9
[3.13] gh-117657: Fix data races reported by TSAN in some set methods (GH-120914) (#121240)
Refactor the fast Unicode hash check into `_PyObject_HashFast` and use relaxed
atomic loads in the free-threaded build.

After this change, the TSAN doesn't report data races for this method.
(cherry picked from commit 294e724964)

Co-authored-by: AN Long <aisk@users.noreply.github.com>
2024-07-01 19:40:28 +00:00
Miss Islington (bot) 82777cd024
[3.13] gh-113565: Improve and harden detection of curses dependencies (GH-119816) (#121202)
1. Use pkg-config to check for ncursesw/panelw. If that fails, use
   pkg-config to check for ncurses/panel.
2. Regardless of pkg-config output, search for curses/panel headers, so
   we're sure we have all defines in pyconfig.h.
3. Regardless of pkg-config output, check if libncurses or libncursesw
   contains the 'initscr' symbol; if it does _and_ pkg-config failed
   earlier, add the resulting -llib linker option to CURSES_LIBS.
   Ditto for 'update_panels' and PANEL_LIBS.
4. Wrap the rest of the checks with WITH_SAVE_ENV and make sure we're
   using updated LIBS and CPPFLAGS for those.

Add the PY_CHECK_CURSES convenience macro.
(cherry picked from commit f80376b129)

Co-authored-by: Erlend E. Aasland <erlend@python.org>
2024-07-01 08:35:38 +00:00
Miss Islington (bot) 009618f112
[3.13] gh-120713: Normalize year with century for datetime.strftime (GH-120820) (GH-121144)
(cherry picked from commit 6d34938dc8)

Co-authored-by: blhsing <blhsing@gmail.com>
2024-06-29 06:57:33 +00:00