Commit graph

124633 commits

Author SHA1 Message Date
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
Sergey B Kirpichev
930ba0ce60
gh-126618: fix repr(itertools.count(sys.maxsize)) (#127048)
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
2024-12-02 14:14:40 +01:00
Peter Bierma
c112de1da2
gh-126890: Restore stripped ssl docstrings (GH-127281) 2024-12-02 13:50:34 +01:00
Victor Stinner
bf21e2160d
Fix Unicode encode_wstr_utf8() (#127420)
Raise RuntimeError instead of RuntimeWarning.
2024-12-02 11:14:47 +01:00
Mark Shannon
a8dd821d5b
GH-126491: GC: Mark objects reachable from roots before doing cycle collection (GH-127110)
* Mark almost all reachable objects before doing collection phase

* Add stats for objects marked

* Visit new frames before each increment

* Update docs

* Clearer calculation of work to do.
2024-12-02 10:12:17 +00:00
CF Bolz-Tereick
2a373da770
add missing gc_collect() calls in sqlite3 tests (#127446) 2024-12-02 11:11:28 +01:00
Bénédikt Tran
1f8267b85d
gh-127443: Fix some entries in Doc/data/refcounts.dat (#127451)
Fix incorrect entries in `Doc/data/refcounts.dat`
2024-12-02 10:21:00 +02:00
Filipe Laíns 🇵🇸
2950bc50af
GH-127429: fix sysconfig data generation on cross-builds (#127430) 2024-12-02 07:12:36 +00:00
Donghee Na
e2713409cf
gh-115999: Add partial free-thread specialization for BINARY_SUBSCR (gh-127227) 2024-12-02 10:38:17 +09:00
Zhikang Yan
7ea523f47c
gh-126899: Add **kw to tkinter.Misc.after and tkinter.Misc.after_idle (#126900)
---------
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2024-12-01 19:29:27 +00:00
Bénédikt Tran
04673d2f14
gh-119786: cleanup internal docs and fix internal links (#127485) 2024-12-01 17:12:22 +00:00
Tian Gao
1bc4f076d1
gh-127321: Avoid stopping at an opcode without an associated line number for breakpoint() (#127457) 2024-12-01 11:57:03 -05:00
Rafael Fontenelle
a880358af0
gh-127356: Fix prepend doctrees directory for gettext target (#127357) 2024-12-01 11:15:44 +02:00
Gregory P. Smith
11c01092d5
Add the missing f on an f-string error message in multiprocessing. (GH-127462) 2024-12-01 06:44:43 +00:00
Peter Bierma
46bfd26fb2
gh-127165: Disallow embedded NULL characters in _interpreters (#127199) 2024-12-01 06:33:23 +00:00
Barney Gale
328187cc4f
GH-127381: pathlib ABCs: remove PathBase.cwd() and home() (#127427)
These classmethods presume that the user has retained the original
`__init__()` signature, which may not be the case. Also, many virtual
filesystems don't provide current or home directories.
2024-11-30 18:39:39 +00:00
alm
4e0a4cafe8
summarize: Fix typo in stats (#127450) 2024-11-30 18:07:54 +02:00
Yuki Kobayashi
33ce8dcf79
Docs: Fix incorrect indents in c-api/type.rst (#127449) 2024-11-30 15:01:15 +00:00
Inada Naoki
7043bbd1ca
gh-127417: fix UTF-8 decoder optimization on AIX (#127433) 2024-11-30 21:52:37 +09:00
Bénédikt Tran
49f15d8667
gh-119786: improve internal docs on co_linetable (#123198) 2024-11-30 00:25:55 +00:00
Barney Gale
38264a060a
GH-127381: pathlib ABCs: remove PathBase.lstat() (#127382)
Remove the `PathBase.lstat()` method, which is a trivial variation of
`stat()`.

No user-facing changes because the pathlib ABCs are still private.
2024-11-29 21:03:39 +00:00
Ollanta Cuba Gyllensten
15d6506d17
Link to correct class methods in asyncio primitives docs (#127270) 2024-11-29 16:20:40 +00:00
Kumar Aditya
45c5cba318
gh-127316: fix incorrect assertion in setting __class__ in free-threading (#127399) 2024-11-29 21:44:20 +05:30
Victor Stinner
b14fdadc6c
gh-127208: Reject null character in _imp.create_dynamic() (#127400)
_imp.create_dynamic() now rejects embedded null characters in the
path and in the module name.
2024-11-29 16:20:38 +01:00
biggus-developerus
3afb639f39
fix param type in PyObject_HasAttrWithError (docs) (#127403) 2024-11-29 10:53:34 +00:00
Inada Naoki
322b486010
gh-126024: optimize UTF-8 decoder for short non-ASCII string (#126025) 2024-11-29 19:48:02 +09:00
Victor Stinner
bfabf96b50
gh-127258: Fix asyncio test_staggered_race_with_eager_tasks() (#127358)
Replace the sleep(2) with a task which is blocked forever.
2024-11-29 11:39:54 +01:00
Peter Bierma
99490913a0
gh-127341: Argument Clinic: fix compiler warnings for getters with docstrings (#127310)
Co-authored-by: Erlend E. Aasland <erlend@python.org>
2024-11-29 11:12:13 +01:00