Commit graph

124874 commits

Author SHA1 Message Date
Bénédikt Tran
8fa5ecec01
gh-123378: fix post-merge typos in comments and NEWS (#127739) 2024-12-08 13:47:22 +00:00
Apostol Fet
1503fc8f88
gh-127610: Added validation for more than one var-positional and var-keyword parameters in inspect.Signature (GH-127657) 2024-12-08 12:05:15 +02:00
Filipe Laíns 🇵🇸
70154855cf
GH-126789: fix some sysconfig data on late site initializations (#127729) 2024-12-08 05:57:22 +00:00
Barney Gale
79b7cab50a
GH-127090: Fix urllib.response.addinfourl.url value for opened file: URIs (#127091)
The canonical `file:` URL (as generated by `pathname2url()`) is now used as the `url` attribute of the returned `addinfourl` object. The `addinfourl.url` attribute reflects the resolved URL for both `file:` or `http[s]:` URLs now.
2024-12-07 17:58:42 +00:00
Stan Ulbrych
27d0d21413
Give poplib.POP3.rpop a proper docstring (#127370)
Previously `poplib.POP3.rpop` had a "Not sure what this does" docstring, now it has been fixed.
2024-12-07 18:13:49 +02:00
Srinivas Reddy Thatiparthy (తాటిపర్తి శ్రీనివాస్ రెడ్డి)
72dca6c4ed
gh-119786: fix typo in InternalDocs/garbage_collector.md (#127687) 2024-12-07 15:42:45 +05:30
Barney Gale
31c9f3ced2
GH-127381: pathlib ABCs: remove PathBase.resolve() and absolute() (#127707)
Remove our implementation of POSIX path resolution in `PathBase.resolve()`.
This functionality is rather fragile and isn't necessary in most cases. It
depends on `PathBase.stat()`, which we're looking to remove.

Also remove `PathBase.absolute()`. Many legitimate virtual filesystems lack
the notion of a 'current directory', so it's wrong to include in the basic
interface.
2024-12-06 21:39:45 +00:00
Brett Cannon
0fc4063747
GH-127652: stop using --wasi preview2 in wasi.py (GH-127704)
It's only to use WASI 0.2 code to back preview1 APIs and is considered experimental anyway.
2024-12-06 18:42:05 +00:00
Barney Gale
5b6635f772
GH-127381: pathlib ABCs: remove PathBase.rename() and replace() (#127658)
These methods are obviated by `PathBase.move()`, which can move directories
and supports any `PathBase` object as a target.
2024-12-06 18:10:00 +00:00
Stan Ulbrych
e59caf67cd
Fix typo in Lib/_android_support.py (#127699) 2024-12-06 19:50:58 +02:00
Irit Katriel
89fa7ec74e
gh-119786: Add jit.md. Move adaptive.md to a section of interpreter.md. (#127175) 2024-12-06 16:36:06 +00:00
Victor Stinner
67b18a18b6
gh-59705: Add _thread.set_name() function (#127338)
On Linux, threading.Thread now sets the thread name to the operating
system.

* configure now checks if pthread_getname_np()
  and pthread_setname_np() functions are available.
* Add PYTHREAD_NAME_MAXLEN macro.
* Add _thread._NAME_MAXLEN constant for test_threading.

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2024-12-06 16:27:12 +00:00
Peter Bierma
12680ec5bd
gh-127314: Don't mention the GIL when calling without a thread state on the free-threaded build (#127315)
Co-authored-by: Victor Stinner <vstinner@python.org>
2024-12-06 16:58:19 +01:00
Sam Gross
a353455fca
gh-125610: Fix STORE_ATTR_INSTANCE_VALUE specialization check (GH-125612)
The `STORE_ATTR_INSTANCE_VALUE` opcode doesn't support objects with
non-NULL managed dictionaries, so don't specialize to that op in that case.
2024-12-06 10:48:24 -05:00
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