124660 Commits

Author SHA1 Message Date
Bénédikt Tran
36c6178d37
gh-126024: fix UBSan failure in unicodeobject.c:find_first_nonascii (GH-127566) 2024-12-06 09:31:30 -05:00
Yuki Kobayashi
77a61c0465
gh-101100: amend references starting with !~ in gh-127054 (#127684) 2024-12-06 16:09:20 +02:00
Mark Shannon
023b7d2141
GH-126491: Lower heap size limit with faster marking (GH-127519)
* Faster marking of reachable objects

* Changes calculation of work to do and work done.

* Merges transitive closure calculations
2024-12-06 10:46:59 +00:00
Sergey B Kirpichev
8b7c194c7b
gh-120010: Fix invalid (nan+nanj) results in _Py_c_prod() (GH-120287)
In some cases, previously computed as (nan+nanj), we could recover
meaningful component values in the result, see e.g. the C11, Annex
G.5.1, routine _Cmultd():

>>> z = 1e300+1j
>>> z*(nan+infj)  # was (nan+nanj)
(-inf+infj)

That also fix some complex powers for small integer exponents, computed
with optimized algorithm (by squaring):

>>> z**5  # was (nan+nanj)
Traceback (most recent call last):
  File "<python-input-1>", line 1, in <module>
    z**5
    ~^^~
OverflowError: complex exponentiation
2024-12-06 12:28:32 +02:00
J. Nick Koston
e991ac8f20
gh-127655: Ensure _SelectorSocketTransport.writelines pauses the protocol if needed (#127656)
Ensure `_SelectorSocketTransport.writelines` pauses the protocol if it reaches the high water mark as needed. 

Co-authored-by: Kumar Aditya <kumaraditya@python.org>
2024-12-06 10:03:03 +05:30
Hood Chatham
25eee578c8
gh-127627: Add posix._emscripten_debugger function (#127628)
Add a posix._emscripten_debugger function to add an emscripten breakpoint.
2024-12-06 10:47:51 +08:00
Barney Gale
8b3cccf3f9
GH-125413: Revert addition of pathlib.Path.scandir() method (#127377)
Remove documentation for `pathlib.Path.scandir()`, and rename the method to
`_scandir()`. In the private pathlib ABCs, make `iterdir()` abstract and
call it from `_scandir()`.

It's not worthwhile to add this method at the moment - see discussion:
https://discuss.python.org/t/ergonomics-of-new-pathlib-path-scandir/71721

Co-authored-by: Steve Dower <steve.dower@microsoft.com>
2024-12-05 21:39:43 +00:00
Sam Gross
f4f530804b
gh-127582: Make object resurrection thread-safe for free threading. (GH-127612)
Objects may be temporarily "resurrected" in destructors when calling
finalizers or watcher callbacks. We previously undid the resurrection
by decrementing the reference count using `Py_SET_REFCNT`. This was not
thread-safe because other threads might be accessing the object
(modifying its reference count) if it was exposed by the finalizer,
watcher callback, or temporarily accessed by a racy dictionary or list
access.

This adds internal-only thread-safe functions for temporary object
resurrection during destructors.
2024-12-05 16:07:31 -05:00
Maciej Olko
657d0e99aa
[Docs] GDB howto: Fix block type of a cast example (#127621) 2024-12-05 22:52:58 +02:00
Hugo van Kemenade
23f2e8f13c
gh-127221: Add colour to unittest output (#127223)
Co-authored-by: Kirill Podoprigora <kirill.bast9@mail.ru>
2024-12-05 21:10:46 +02:00
Jakub Kulík
d958d9f4a1
GH-126727: Fix test_era_nl_langinfo with Japanese ERAs on Solaris (GH-127327)
Fix test_era_nl_langinfo with Japanese ERAs on Solaris
2024-12-05 20:43:19 +02:00
Peter Bierma
208b0fb645
gh-122431: Disallow negative values in readline.append_history_file (#122469)
Co-authored-by: Victor Stinner <vstinner@python.org>
2024-12-05 16:07:38 +00:00
Bénédikt Tran
67b9a5331a
gh-127413: allow to show specialized bytecode via dis CLI (#127414) 2024-12-05 15:01:59 +00:00
Victor Stinner
fcbe6ecdb6
gh-93312: Include <sys/pidfd.h> to get PIDFD_NONBLOCK (#127593) 2024-12-05 10:39:44 +01:00
Victor Stinner
1ef6e8ca3f
gh-119182: Complete PyUnicodeWriter documentation (#127607) 2024-12-05 10:37:14 +01:00
Feodor Fitsner
6cf77949fb
gh-127434: Fix iOS xcrun --sdk clang/ar scripts to allow arguments with spaces (#127575)
Added shell escaping to ensure iOS compiler shims can accept arguments with spaces.
2024-12-05 11:00:20 +08:00
Hood Chatham
87faf0a9c4
gh-127503: Emscripten make Python.sh function as proper Python CLI (#127506)
Modifies the python.sh script to work on macOS, and adapt to recent emscripten changes.
2024-12-05 08:44:50 +08:00
Hood Chatham
43634fc1fc
gh-127146: Emscripten: Skip segfaults in test suite (#127151)
Added skips for tests known to cause problems when running on Emscripten. 
These mostly relate to the limited stack depth on Emscripten.
2024-12-05 08:26:25 +08:00
Hood Chatham
2f1cee8477
gh-127111: Apply prettier formatter to Emscripten web example (#127551)
Cleaned up formatting (and a stray closing tag) of the web example HTML and JS.
2024-12-05 08:25:06 +08:00
Brandt Bucher
94b8f8b409
GH-126795: Increase the JIT side-exit threshold from 64 to 4096 (GH-127155) 2024-12-04 15:01:28 -08:00
Diego Russo
7c5a6f67c7
Enable native AArch64 Ubuntu CI jobs (#127584)
Co-authored-by: Brandt Bucher <brandtbucher@gmail.com>
2024-12-04 14:12:06 -08:00
Sam Gross
e51da64ac3
gh-127536: Add missing locks in listobject.c (GH-127580)
We were missing locks around some list operations in the free threading
build.
2024-12-04 14:12:15 -05:00
Beomsoo Kim
51cfa569e3
gh-127552: Remove comment questioning 4-digit restriction for ‘Y’ in datetime.strptime patterns (#127590)
The code has required 4 digits for the year since its inclusion in the stdlib in 2002 (over 22 years ago as of this commit).
2024-12-04 10:30:51 -08:00
RUANG (James Roy)
6bc3e830a5
gh-127481: Add EPOLLWAKEUP to the select module (GH-127482) 2024-12-04 14:30:38 +01:00
Bénédikt Tran
bc0f2e9459
gh-123378: Ensure results of PyUnicode*Error_Get{Start,End} are clamped (GH-123380)
Co-authored-by: Sergey B Kirpichev <skirpichev@gmail.com>
2024-12-04 14:13:52 +01:00
sobolevn
ad9d059eb1
gh-126524: Run regen-unicodedata as a part of our CI (#126682) 2024-12-04 13:01:46 +03:00
Sam Gross
6fc6436749
gh-127572: Fix test_structmembers initialization (GH-127577)
gh-127572: Fix `test_structmembers` initialization.

The 'C' format code expects an `int` as a destination (not a `char`).
This led to test failures on big-endian platforms like s390x. Use the
'c' format code, which expects a `char` as the destination (but requires
a Python byte objects instead of a str).
2024-12-04 09:58:22 +01:00
Raymond Hettinger
7f882c88cf
Itertool recipe additions (gh-127483) 2024-12-03 18:20:01 -06:00
Hood Chatham
0f91078170
gh-127146: Resolve some minor problems in Emscripten tests (#127565)
Adjusts some Emscripten test exclusions regarding strftime, fma, and stack depth.
2024-12-04 08:06:20 +08:00
RUANG (James Roy)
12397a5781
gh-112192: Increase the trace module coverage precision to one decimal (#126972) 2024-12-03 23:33:13 +01:00
mpage
dabcecfd6d
gh-115999: Enable specialization of CALL instructions in free-threaded builds (#127123)
The CALL family of instructions were mostly thread-safe already and only required a small number of changes, which are documented below.

A few changes were needed to make CALL_ALLOC_AND_ENTER_INIT thread-safe:

Added _PyType_LookupRefAndVersion, which returns the type version corresponding to the returned ref.

Added _PyType_CacheInitForSpecialization, which takes an init method and the corresponding type version and only populates the specialization cache if the current type version matches the supplied version. This prevents potentially caching a stale value in free-threaded builds if we race with an update to __init__.

Only cache __init__ functions that are deferred in free-threaded builds. This ensures that the reference to __init__ that is stored in the specialization cache is valid if the type version guard in _CHECK_AND_ALLOCATE_OBJECT passes.
Fix a bug in _CREATE_INIT_FRAME where the frame is pushed to the stack on failure.

A few other miscellaneous changes were also needed:

Use {LOCK,UNLOCK}_OBJECT in LIST_APPEND. This ensures that the list's per-object lock is held while we are appending to it.

Add missing co_tlbc for _Py_InitCleanup.

Stop/start the world around setting the eval frame hook. This allows us to read interp->eval_frame non-atomically and preserves the behavior of _CHECK_PEP_523 documented below.
2024-12-03 11:20:20 -08:00
Neil Schemenauer
fc5a0dc224
gh-127271: Replace use of PyCell_GET/SET (gh-127272)
* Replace uses of `PyCell_GET` and `PyCell_SET`.  These macros are not
  safe to use in the free-threaded build.  Use `PyCell_GetRef()` and
  `PyCell_SetTakeRef()` instead. 

* Since `PyCell_GetRef()` returns a strong rather than borrowed ref, some
  code restructuring was required, e.g. `frame_get_var()` returns a strong
  ref now.

* Add critical sections to `PyCell_GET` and `PyCell_SET`.

* Move critical_section.h earlier in the Python.h file.

* Add `PyCell_GET` to the free-threading howto table of APIs that return
  borrowed refs.

* Add additional unit tests for free-threading.
2024-12-03 10:33:06 -08:00
Neil Schemenauer
276cd66ccb
gh-115999: Add free-threaded specialization for SEND (gh-127426)
No additional thread safety changes are required.  Note that sending to
a generator that is shared between threads is currently not safe in the
free-threaded build.
2024-12-03 10:25:12 -08:00
mpage
13b68e1a61
gh-127421: Fix race in test_start_new_thread_failed (#127549)
Fix race in test_start_new_thread_failed

When we succeed in starting a new thread, for example if setrlimit
was ineffective, we must wait for the newly spawned thread to exit.
Otherwise, we run the risk that the newly spawned thread will race
with runtime finalization and access memory that has already been
clobbered/freed.

`_thread.start_new_thread()` only spawns daemon threads, which the runtime
does not wait for at shutdown, and does not return a handle. Use
`_thread.start_joinable_thread()` and join the resulting handle when
the thread is started successfully.
2024-12-03 09:50:58 -08:00
Neil Schemenauer
0cb5222079
gh-115999: Specialize LOAD_SUPER_ATTR in free-threaded builds (gh-127128)
Use existing helpers to atomically modify the bytecode.  Add unit tests
to ensure specializing is happening as expected.  Add test_specialize.py
that can be used with ThreadSanitizer to detect data races.  
Fix thread safety issue with cell_set_contents().
2024-12-03 09:32:26 -08:00
Tomas R.
8ba9f5bca9
gh-127347: Document traceback.print_list (#127348)
Previously, `traceback.print_list` didn't have a documentation entry and was not exposed in `traceback.__all__`. Now it has a documentation entry and is exposed in `__all__`.
2024-12-03 18:08:39 +02:00
Jun Komoda
412e11fe6e
gh-127255: Make CopyComPointer public and add to ctypes doc. (GH-127275) 2024-12-03 16:35:08 +01:00
Daniele Parmeggiani
979bf2489d
gh-117657: TSAN Fix races in PyMember_Get and PyMember_Set for C extensions (GH-123211) 2024-12-03 09:41:53 -05:00
RUANG (James Roy)
84ff1313d0
gh-126585: Add EHWPOISON error code (#126586) 2024-12-03 12:45:50 +00:00
Petr Viktorin
35d37d6592
gh-127253: Note that Stable ABI is about ABI stability (GH-127254) 2024-12-03 13:30:27 +01:00
Alexander Stepchenko
8c3fd1f245
docs(logging): fix phrasing from "operation on" to "operate on" (#127543) 2024-12-03 12:22:12 +05:30
Raymond Hettinger
dffb90911a
Speed-up lazy heapq import in collections (gh-127538) 2024-12-02 20:45:36 -06:00
Hood Chatham
bfb0788bfc
gh-127111: Emscripten Make web example work again (#127113)
Moves the Emscripten web example into a standalone folder, and updates 
Makefile targets to build the web example. Instructions for usage have
also been added.
2024-12-03 07:30:24 +08:00
Michael Droettboom
edefb8678a
gh-127518: Fix pystats build after #127169 (#127526)
gh-127518: Fix pystats build after #127619
2024-12-02 20:17:08 +00:00
Sam Gross
c7dec02de2
gh-127521: Mark list as "shared" before resizing if necessary (#127524)
In the free threading build, if a non-owning thread resizes a list,
it must use QSBR to free the old list array because there may be a
concurrent access (without a lock) from the owning thread.

To match the pattern in dictobject.c, we just mark the list as "shared"
before resizing if it's from a non-owning thread and not already marked
as shared.
2024-12-02 14:38:26 -05:00
mpage
c4303763da
gh-127411: Fix invalid conversion of load of TLBC array when compiled in C++ (#127466)
Cast the result of the load to the correct type
2024-12-02 10:13:30 -08:00
Victor Stinner
c46acd3588
gh-126876: Fix test_socket.testLargeTimeout() for missing _testcapi (#127517) 2024-12-02 16:51:50 +01:00
Donghee Na
7c2bd9b226
gh-115999: Use light-weight lock for UNPACK_SEQUENCE_LIST (gh-127514) 2024-12-03 00:14:40 +09:00
Yuki Kobayashi
3e812253ab
gh-101100: Fix Sphinx warnings about list methods (#127054) 2024-12-02 15:51:35 +02:00
Giovanni Siragusa
31f16e427b
gh-109523: Raise a BlockingIOError if reading text from a non-blocking stream cannot immediately return bytes. (GH-122933) 2024-12-02 14:18:30 +01:00