Commit graph

125635 commits

Author SHA1 Message Date
Bénédikt Tran
4466e91360
gh-111178: fix UBSan failures in Modules/_operator.c (GH-129785)
Fix UBSan failures for `itemgetterobject`, `attrgetterobject`, `methodcallerobject`

Suppress unused return values
2025-02-20 14:21:55 +01:00
Bénédikt Tran
e24a1ac17c
gh-129173: Use _PyUnicodeError_GetParams in PyCodec_SurrogateEscapeErrors (GH-129175) 2025-02-20 13:18:47 +00:00
Victor Stinner
519c2c6740
gh-128863: Deprecate the private _PyUnicodeWriter API (#129245)
Deprecate private C API functions:

* _PyUnicodeWriter_Init()
* _PyUnicodeWriter_Finish()
* _PyUnicodeWriter_Dealloc()
* _PyUnicodeWriter_WriteChar()
* _PyUnicodeWriter_WriteStr()
* _PyUnicodeWriter_WriteSubstring()
* _PyUnicodeWriter_WriteASCIIString()
* _PyUnicodeWriter_WriteLatin1String()

These functions are not deprecated in the internal C API (if the
Py_BUILD_CORE macro is defined).
2025-02-20 14:02:02 +01:00
Yuki Kobayashi
3bda821a83
gh-101100: Fix sphinx warnings in readline.rst (#130300) 2025-02-20 14:56:27 +02:00
Irit Katriel
048ee2d5ec
gh-130250: use support.swap_attr() in test and don't assume we're beginning with a clean system state (#130342) 2025-02-20 11:29:18 +00:00
Alcaro
417372bd43
Fix some ctypes docs typos (GH-130307) 2025-02-20 11:58:50 +01:00
Serhiy Storchaka
10b32054ad
gh-127750: Restore inspect and pydoc support of singledispatchmethod (GH-130309)
The code is still flawed, because it does not recognize class and static
methods, and the first argument is not removed from the signature of
bound methods, but at least it does not worse than in 3.13 and older.
2025-02-20 11:08:49 +02:00
Stan Ulbrych
ed831b95a2
gh-69001: Convert links to more usable buttons (#129591)
In Lib/idlelib/help_about.py, there are 2 links that are not underlined or colored, hence hard to tell that clicking works.  All buttons might get converted to colored and underlined links in the future.
---------

Co-authored-by: Terry Jan Reedy <tjreedy@udel.edu>
2025-02-20 08:30:57 +00:00
Sabfo
47ace53995
gh-130130: Clarify hash=False docs in dataclasses.field (#130324) 2025-02-20 02:43:27 -05:00
Russell Keith-Magee
1b070060c0
gh-130293: Ensure test__colorize will pass on dumb terminals. (#130333)
Ensure colorize tests will run on dumb terminals (or environment with TERM=dumb set)
Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
2025-02-20 06:49:18 +00:00
Tian Gao
ee337bea01
gh-57537: Support breakpoints for zipimport modules on pdb (#130290) 2025-02-19 21:01:04 -05:00
Irit Katriel
c718c6be0f
gh-130250: fix cleanup in test (impacts refleaks runs) (#130329) 2025-02-20 01:37:30 +00:00
Irit Katriel
6c982aeb54
gh-130250: fix regression in traceback.print_last (#130318) 2025-02-19 21:44:35 +00:00
za
73801864d8
gh-122876: Fix "End of lines" typo (#125310)
Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
2025-02-19 19:16:38 +00:00
Tian Gao
ccf17323c2
gh-128396: Fix a crash when inline comprehension has the same local variable as the outside scope (#130235) 2025-02-19 12:11:17 -05:00
Kumar Aditya
5f00501a94
gh-130221: fix crash when accessing module state while interp is finalizing in asyncio (#130245) 2025-02-19 22:07:56 +05:30
Kumar Aditya
660f126f87
gh-129898: per-thread current task implementation in asyncio (#129899)
Store the current running task on the thread state, it makes it thread safe for the free-threading build and while improving performance as there is no lock contention, this effectively makes it lock free.
When accessing the current task of the current running loop in current thread, no locking is required and can be acessed without locking.
In the rare case of accessing current task of a loop running in a different thread, the stop the world pauses is used in free-threading builds to stop all other running threads and find the task for the specified loop.

This also makes it easier for external introspection to find the current task, and now it will be always correct.
2025-02-19 16:34:49 +00:00
Diego Russo
fb17f41522
Revert "Use ubuntu-22.04-arm image for Arm runners. (#129834)" (#130305)
GitHub discovered it was an issue with the underlying hardware
and have migrated all the runners to a different arm sku (dpdsv5).

This reverts commit 80b9e79d84.
2025-02-19 17:06:11 +01:00
Mark Shannon
2498c22fa0
GH-91079: Implement C stack limits using addresses, not counters. (GH-130007)
* Implement C recursion protection with limit pointers

* Remove calls to PyOS_CheckStack

* Add stack protection to parser

* Make tests more robust to low stacks

* Improve error messages for stack overflow
2025-02-19 11:44:57 +00:00
Bénédikt Tran
c637bce20a
gh-111178: fix UBSan failures in Modules/_datetimemodule.c (GH-129774)
Add cast macros for date and time objects

Fix UBSan failures for `PyDateTime_Delta`, `PyDateTime_Date`, `PyDateTime_TZInfo`, `PyDateTime_TimeZone`, `PyDateTime_Time`, `PyDateTime_DateTime`, `PyDateTime_IsoCalendarDate`

Fix up naming
2025-02-19 11:18:37 +00:00
Bénédikt Tran
0d0be7f7f1
gh-111178: fix UBSan failures in Modules/mmapmodule.c (GH-129784)
Fix UBSan failures for `mmap_object`

Use 'ignored' for NOARGS method and 'args' for others
2025-02-19 12:02:32 +01:00
Bénédikt Tran
f8c041bff9
gh-111178: fix UBSan failures in Modules/itertoolsmodule.c (GH-129780) 2025-02-19 11:58:47 +01:00
Tomasz Pytel
1b6bef8086
gh-129107: make bytearray iterator thread safe (#130096)
Co-authored-by: Kumar Aditya <kumaraditya@python.org>
2025-02-19 15:42:45 +05:30
T. Wouters
388e1ca9f0
gh-115999: Make list and tuple iteration more thread-safe. (#128637)
Make tuple iteration more thread-safe, and actually test concurrent iteration of tuple, range and list. (This is prep work for enabling specialization of FOR_ITER in free-threaded builds.) The basic premise is:

Iterating over a shared iterable (list, tuple or range) should be safe, not involve data races, and behave like iteration normally does.

Using a shared iterator should not crash or involve data races, and should only produce items regular iteration would produce. It is not guaranteed to produce all items, or produce each item only once. (This is not the case for range iteration even after this PR.)

Providing stronger guarantees is possible for some of these iterators, but it's not always straight-forward and can significantly hamper the common case. Since iterators in general aren't shared between threads, and it's simply impossible to concurrently use many iterators (like generators), better to make sharing iterators without explicit synchronization clearly wrong.

Specific issues fixed in order to make the tests pass:

 - List iteration could occasionally fail an assertion when a shared list was shrunk and an item past the new end was retrieved concurrently. There's still some unsafety when deleting/inserting multiple items through for example slice assignment, which uses memmove/memcpy.

 - Tuple iteration could occasionally crash when the iterator's reference to the tuple was cleared on exhaustion. Like with list iteration, in free-threaded builds we can't safely and efficiently clear the iterator's reference to the iterable (doing it safely would mean extra, slow refcount operations), so just keep the iterable reference around.
2025-02-18 16:52:46 -08:00
Adam Turner
736ad664e0
Docs: Upgrade Sphinx to 8.2 (#130171) 2025-02-18 23:45:02 +00:00
Sam Gross
857bdba0ac
gh-130094: Fix race conditions in importlib (gh-130101)
Entries may be added or removed from `sys.meta_path` concurrently. For
example, setuptools temporarily adds and removes the `distutils` finder from
the beginning of the list. The local copy ensures that we don't skip over any
entries.

Some packages modify `sys.modules` during import. For example, `collections`
inserts the entry for `collections.abc`  into `sys.modules` during import. We
need to ensure that we re-check `sys.modules` *after* the parent module is
fully initialized.
2025-02-18 18:02:42 -05:00
Tian Gao
8207454bc0
gh-124703: Add extra checks for pdb quit test (#130286) 2025-02-18 16:55:39 -05:00
Sergey Miryanov
bcc9a5dddb
gh-129515: Clarify syntax error messages for conditional expressions (#129880)
Co-authored-by: Pablo Galindo Salgado <Pablogsal@gmail.com>
Co-authored-by: Stan Ulbrych <89152624+StanFromIreland@users.noreply.github.com>
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
2025-02-18 21:43:19 +00:00
Pablo Galindo Salgado
51d4bf1e0e
bpo-45325: Add a new 'p' parameter to Py_BuildValue to convert an integer into a Python bool (#28634) 2025-02-18 17:14:11 +00:00
Tian Gao
076300d795
gh-126944: Show explicit errors when required arguments of pdb commands are missing (#130240) 2025-02-18 10:58:15 -05:00
donBarbos
427dd10250
gh-127260: Improve error consistency in both fromisoformat implementations (#130134)
In the Python implementation, "Z" was allowed where only "+" or "-" should be allowed in time zone specifiers. In the C implementation, ":" was allowed as a separator between the whole and fractional portion of times (seconds). These have both been forbidden and the error messages harmonized.
2025-02-18 15:49:28 +00:00
Ken Jin
46ac85e4d9
gh-129989: Change Py_TAIL_CALL_INTERP ifndef to ! (#130269)
Change Py_TAIL_CALL_INTERP ifndef to !
2025-02-18 15:48:49 +00:00
Jacob Walls
dab456dcef
gh-130164: Fix inspect.Signature.bind() handling of positional-only args without defaults (GH-130192)
Follow-up to 9c15202.
2025-02-18 17:19:04 +02:00
Stan Ulbrych
01ba7df499
gh-44827: Improve error if BOM on first line of .po file (GH-130187) 2025-02-18 15:59:34 +02:00
Bénédikt Tran
185ac5adaf
gh-111178: fix UBSan failures in Modules/_lzmamodule.c (GH-129783)
fix UBSan failures for LZMA objects

suppress unused return values
2025-02-18 14:48:21 +01:00
sobolevn
97d0011e7e
gh-130160: use option instead of cmdoption in dis.rst (#130255) 2025-02-18 15:54:14 +03:00
Kanishk Pachauri
8cd7f8bf8d
gh-130160: use .. program:: directive for documenting ensurepip CLI (gh-130253) 2025-02-18 12:09:22 +00:00
Kumar Aditya
2e3e65380b
improve test_tasks to use correct idiom for starting task in asyncio (#130257)
The test should use the correct idiom for starting the task, `loop._run_once` is private API which should not be used directly, instead use `asyncio.sleep(0)` for 1 event loop cycle.
2025-02-18 12:08:25 +00:00
Serhiy Storchaka
b93b7e566e
gh-130230: Fix crash in pow() with only Decimal third argument (GH-130237) 2025-02-18 09:46:48 +02:00
Stan Ulbrych
4374e1de87
gh-130195: Remove unimplemented option from pygettext (#130196)
Co-authored-by: Tomas R. <tomas.roun8@gmail.com>
2025-02-17 19:01:36 -08:00
donBarbos
99d965635a
gh-118761: Improve import time of cmd module (#130056)
* Improve import time of `cmd` module
* Remove string import
2025-02-17 20:06:08 +00:00
Barney Gale
6f07016bf0
GH-127381: pathlib ABCs: remove ReadablePath.rglob() (#130207)
Remove `ReadablePath.rglob()` from the private pathlib ABCs. This method is
a trivial wrapper around `glob()` and easily replaced.
2025-02-17 19:15:59 +00:00
Barney Gale
7fcace99bb
GH-125413: Add private metadata methods to pathlib.Path.info (#129897)
Add the following private methods to `pathlib.Path.info`:

- `_posix_permissions()`: the POSIX file permissions (`S_IMODE(st_mode)`)
- `_file_id()`: the file ID (`(st_dev, st_ino)`)
- `_access_time_ns()`: the access time in nanoseconds (`st_atime_ns`)
- `_mod_time_ns()`: the modify time in nanoseconds (`st_mtime_ns`)
- `_bsd_flags()`: the BSD file flags (`st_flags`)
- `_xattrs()`: the file extended attributes as a list of key, value pairs,
  or an empty list if `listxattr()` or `getxattr()` fail in an ignorable 
  way.

These methods replace `LocalCopyReader.read_metadata()`, and so we can
delete the `CopyReader` and `LocalCopyReader` classes. Rather than reading
metadata via `source._copy_reader.read_metadata()`, we instead call
`source.info._posix_permissions()`, `_access_time_ns()`, etc.

Preserving metadata is only supported for local-to-local copies at the
moment. To support copying metadata between arbitrary `ReadablePath` and
`WritablePath` objects, we'd need to make the new methods public and
documented.

Co-authored-by: Petr Viktorin <encukou@gmail.com>
2025-02-17 19:15:25 +00:00
Gregory P. Smith
bd1642c6e5
cover **/*hashopenssl* in CODEOWNERS (#130236) 2025-02-17 11:09:16 -08:00
Tomas R.
25422561de
gh-125756: Document Pickler.clear_memo() (GH-125762) 2025-02-17 17:48:29 +02:00
Bénédikt Tran
a1d4b1c447
gh-111178: fix UBSan failures in Modules/_lsprof.c (GH-129782)
Fix UBSan failures for `ProfilerObject`

Suppress unused return value
2025-02-17 14:53:03 +01:00
Bénédikt Tran
31ad8b6d08
gh-111178: fix UBSan failures in Modules/_jsonmodule.c (GH-129781)
Fix UBSan failures for `PyScannerObject`, fix UBSan failures for `PyEncoderObject`
2025-02-17 14:51:18 +01:00
Andrey Efremov
ef8eeca9d8
gh-129678: ConfigParser: do not write an empty unnamed section (GH-129679)
Co-authored-by: Petr Viktorin <encukou@gmail.com>
2025-02-17 14:24:57 +01:00
Sam Gross
b9d2ee687c
gh-129701: Fix a data race in intern_common in the free threaded build (GH-130089)
* gh-129701: Fix a data race in `intern_common` in the free threaded build

* Use a mutex to avoid potentially returning a non-immortalized string,
  because immortalization happens after the insertion into the interned
  dict.

* Use `Py_DECREF()` calls instead of `Py_SET_REFCNT(s, Py_REFCNT(s) - 2)`
  for thread-safety. This code path isn't performance sensistive, so
  just use `Py_DECREF()` unconditionally for simplicity.
2025-02-17 14:15:40 +01:00
Yuki Kobayashi
fc8c99a8ce
gh-130214: Document PyEllipsis_Type (GH-130215) 2025-02-17 13:56:33 +01:00