125691 Commits

Author SHA1 Message Date
Sam Gross
7aeaa5af2c
gh-130091: Reorder _PyThreadState_Attach to avoid data race (gh-130092)
This moves `tstate_activate()` down to avoid a data race in the free
threading build on the `_PyRuntime`'s thread-local `autoTSSkey`. This
key is deleted during runtime finalization, which may happen
concurrently with a call to `_PyThreadState_Attach`.

The earlier `tstate_try/wait_attach` ensures that the thread is blocked
before it attempts to access the deleted `autoTSSkey`.

This fixes a TSAN reported data race in
`test_threading.test_import_from_another_thread`.
2025-02-27 13:57:19 -05:00
Pablo Galindo Salgado
e06bebb87e
gh-130618: Fix parser error when using lambdas inside f-strings (#130638) 2025-02-27 15:51:17 +00:00
Yuki Kobayashi
b26286ca49
Docs: Fix a misplaced statement in the document for ServerProxy (GH-130616)
The sentence "If an HTTPS URL ..." explains what the parameter means,
so moved it to the paragraph explaining what the other parameters mean.
2025-02-27 16:14:56 +01:00
Tomasz Pytel
e85f81f430
gh-129107: fix thread safety of bytearray where two critical sections are needed (#130227) 2025-02-27 20:29:58 +05:30
Tomasz Pytel
8ba0d7bbc2
gh-128942: make array module thread safe (#128943)
Co-authored-by: Kumar Aditya <kumaraditya@python.org>
2025-02-27 14:00:14 +00:00
Sam Gross
d027787c8d
gh-130421: Fix data race on timebase initialization (gh-130592)
Windows and macOS require precomputing a "timebase" in order to convert
OS timestamps into nanoseconds. Retrieve and compute this value during
runtime initialization to avoid data races when accessing the time.
2025-02-27 13:27:54 +00:00
Fredrik Ahlberg
45a24f54af
gh-129288: Add optional l2_cid and l2_bdaddr_type in BTPROTO_L2CAP socket address tuple (#129293)
Add two optional, traling elements in the AF_BLUETOOTH socket address tuple:

- l2_cid, to allow e.g raw LE ATT connections
- l2_bdaddr_type. To be able to connect L2CAP sockets to Bluetooth LE devices,
  the l2_bdaddr_type must be set to BDADDR_LE_PUBLIC or BDADDR_LE_RANDOM.
2025-02-27 12:51:47 +00:00
Victor Stinner
a083633fa0
gh-109959: Remove test_glob.test_selflink() (#130551)
The test is not reliable, it fails randomly on Linux:
https://github.com/python/cpython/issues/109959#issuecomment-2577550700
2025-02-27 11:07:08 +01:00
Mark Shannon
2a18e80695
GH-128534: Instrument branches for async for loops. (GH-130569) 2025-02-27 09:36:41 +00:00
Adam Turner
fda056e64b
gh-130604: Always run all matrix workflows in GitHub Actions (#130603) 2025-02-26 21:44:48 +00:00
Sam Gross
959f43315e
gh-130605: Temporarily disable test_concurrent_futures in TSAN CI job (gh-130606)
There are a number of data races in the default build without
suppressions that are exposed by this test. Disable the test for now
under TSAN until we have suppressions or fix the data races.
2025-02-26 21:36:53 +00:00
Barney Gale
b251d409f9
GH-125413: Add private pathlib.Path method to write metadata (#130238)
Replace `WritablePath._copy_writer` with a new `_write_info()` method. This
method allows the target of a `copy()` to preserve metadata.

Replace `pathlib._os.CopyWriter` and `LocalCopyWriter` classes with new
`copy_file()` and `copy_info()` functions. The `copy_file()` function uses
`source_path.info` wherever possible to save on `stat()`s.
2025-02-26 21:07:27 +00:00
shenxianpeng
5ba69e747f
gh-127785: Reduce permissions in the check labels workflow (#130596) 2025-02-26 20:47:41 +00:00
Victor Stinner
daeb0efaf4
gh-111178: Fix function signatures in sliceobject.c (#130575)
Rename slicehash() to slice_hash() for consistency.
2025-02-26 21:37:22 +01:00
Victor Stinner
05aba4e799
gh-111178: Fix function signatures in instruction_sequence.c (#130591) 2025-02-26 21:36:26 +01:00
Victor Stinner
d5d4cbbd8f
gh-111178: Fix function signatures in namespaceobject.c (#130590) 2025-02-26 21:35:56 +01:00
Victor Stinner
1b635d86cd
gh-111178: Fix function signatures in symtable.c (#130589) 2025-02-26 21:35:24 +01:00
Adam Turner
3f3e1c4095
Doc: Strip trailing whitespace in `pydoc_topics` (#130492) 2025-02-26 20:10:55 +00:00
Sam Gross
45bc120d45
gh-130519: Fix crash in QSBR when destructor reenters QSBR (gh-130553)
The `free_work_item()` function in QSBR may call arbitrary code via
Python object destructors, which may reenter the QSBR code. Reorder
the processing of work items to be robust to reentrancy.

Also fix the TODO for the out of memory situation.
2025-02-26 14:55:15 -05:00
Dino Viehland
5c8e8704c3
gh-130595: Keep traceback alive for WITH_EXCEPT_START (#130562)
Keep traceback alive for WITH_EXCEPT_START
2025-02-26 10:41:26 -08:00
Petr Viktorin
9e474a98af
gh-128982: Revert "#128982: Substitute regular expression in http.cookiejar.join_header_words for an efficient alternative (GH-128983)" and add tests (GH-130584)
* Revert "gh-128982: Substitute regular expression in `http.cookiejar.join_header_words` for an efficient alternative (GH-128983)"

This reverts commit 56e190068177855266f32a7efa329d145b279f94.

* Add tests
2025-02-26 15:42:39 +01:00
Bénédikt Tran
56e1900681
gh-128982: Substitute regular expression in http.cookiejar.join_header_words for an efficient alternative (GH-128983)
The function does not anymore rely on a regular expression
to find alphanumeric characters and underscores.
2025-02-26 13:01:32 +01:00
Paul Moore
64ccbbbf36
gh-130379: Fix incorrect zipapp logic to avoid including the target in itself (gh-130509) 2025-02-26 11:25:30 +00:00
Bénédikt Tran
f976892b7d
gh-111178: fix UBSan failures in Modules/_hashopenssl.c (GH-129802)
Fix UBSan failures for `EVPobject`, `HMACobject`
2025-02-26 09:24:44 +00:00
Mark Shannon
129db32d6f
GH-130396: Treat clang -Og as optimized for gdb tests (GH-130550) 2025-02-26 09:01:58 +00:00
Mark Shannon
263d56e1e2
GH-130396: Increase trashcan overhead (GH-130552)
Double trashcan overhead
2025-02-26 08:54:24 +00:00
Bénédikt Tran
59d3ad0c62
gh-111178: fix UBSan failures in Modules/_tkinter.c (GH-129795)
Fix UBSan failures for `TkappObject`, `PyTclObject`, `TkttObject`

Implement CHECK_TCL_APPARTMENT as a static inline function
2025-02-26 09:40:48 +01:00
Bénédikt Tran
18bc5b7839
gh-111178: fix UBSan failures in Modules/_zoneinfo.c (GH-129798)
Fix UBSan failures for `PyZoneInfo_ZoneInfo`

Fix semantic naming
2025-02-26 09:36:59 +01:00
Yuki Kobayashi
b536e37104
gh-130433: Update documentation for MultipartConversionError (GH-130436) 2025-02-26 08:34:10 +00:00
Neil Schemenauer
baae9cb159
gh-117657: Use an atomic store to set type flags. (gh-127588)
The `PyType_HasFeature()` function reads the flags with a relaxed atomic
load and without holding the type lock.  To avoid data races, use atomic
stores if `PyType_Ready()` has already been called.
2025-02-25 21:24:20 -08:00
Serhiy Storchaka
0ef4ffeefd
gh-130163: Fix crashes related to PySys_GetObject() (GH-130503)
The use of PySys_GetObject() and _PySys_GetAttr(), which return a borrowed
reference, has been replaced by using one of the following functions, which
return a strong reference and distinguish a missing attribute from an error:
_PySys_GetOptionalAttr(), _PySys_GetOptionalAttrString(),
_PySys_GetRequiredAttr(), and _PySys_GetRequiredAttrString().
2025-02-25 23:04:27 +02:00
Mark Shannon
2dad1e08ec
GH-130396: Include stack margin for debug windows builds (GH-130554) 2025-02-25 19:26:21 +00:00
Sam Gross
f963239ff1
gh-130202: Fix bug in _PyObject_ResurrectEnd in free threaded build (gh-130281)
This fixes a fairly subtle bug involving finalizers and resurrection in
debug free threaded builds: if `_PyObject_ResurrectEnd` returns `1`
(i.e., the object was resurrected by a finalizer), it's not safe to
access the object because it might still be deallocated. For example:

 * The finalizer may have exposed the object to another thread. That
   thread may hold the last reference and concurrently deallocate it any
   time after `_PyObject_ResurrectEnd()` returns `1`.
 * `_PyObject_ResurrectEnd()` may call `_Py_brc_queue_object()`, which
   may internally deallocate the object immediately if the owning thread
   is dead.

Therefore, it's important not to access the object after it's
resurrected. We only violate this in two cases, and only in debug
builds:

 * We assert that the object is tracked appropriately. This is now moved
   up betewen the finalizer and the `_PyObject_ResurrectEnd()` call.

 * The `--with-trace-refs` builds may need to remember the object if
   it's resurrected. This is now handled by `_PyObject_ResurrectStart()`
   and `_PyObject_ResurrectEnd()`.

Note that `--with-trace-refs` is currently disabled in `--disable-gil`
builds because the refchain hash table isn't thread-safe, but this
refactoring avoids an additional thread-safety issue.
2025-02-25 12:03:28 -05:00
Tian Gao
c5f925c8c9
gh-122029: Move monitoring after method expand for CALL_KW (GH-130488) 2025-02-25 15:43:49 +00:00
Sam Gross
3774d9f7b5
gh-129824: Temporarily skip InterpreterPoolMixin tests under TSAN (gh-129826)
There are multiple data races reported when running the
InterpreterPoolMixin tests, but it's still useful to run the other
test_concurrent_futures tests under TSAN.

Add test_concurrent_futures to the TSAN test suite.
2025-02-25 10:33:04 -05:00
Sergey B Kirpichev
f39a07be47
gh-87790: support thousands separators for formatting fractional part of floats (#125304)
```pycon
>>> f"{123_456.123_456:_._f}"  # Whole and fractional
'123_456.123_456'
>>> f"{123_456.123_456:_f}"    # Integer component only
'123_456.123456'
>>> f"{123_456.123_456:._f}"   # Fractional component only
'123456.123_456'
>>> f"{123_456.123_456:.4_f}"  # with precision
'123456.1_235'
```
2025-02-25 16:27:07 +01:00
Bénédikt Tran
fa6a8140dd
gh-129173: refactor PyCodec_ReplaceErrors into separate functions (#129893)
The logic of `PyCodec_ReplaceErrors` is now split into separate functions,
each of which handling a specific exception type.
2025-02-25 14:24:46 +01:00
Yuki Kobayashi
4d3a7ea354
Docs: Fix some semantic usages of iterator.__iter__ (GH-130172)
These references to an `__iter__` method mean `object.__iter__`, not `iterator.__iter__`.
2025-02-25 13:38:47 +01:00
Kanishk Pachauri
85f1cc8d60
gh-130461: Remove unnecessary usages of .. index:: directives in Doc/library/uuid.rst (#130526)
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
2025-02-25 14:27:50 +02:00
Bénédikt Tran
c1478d1ebb
gh-111178: fix UBSan failures in Modules/unicodedata.c (GH-129801)
fix UBSan failures for `PreviousDBVersion`
2025-02-25 13:13:47 +01:00
Bénédikt Tran
ecde940025
gh-111178: fix UBSan failures in Objects/typevarobject.c (GH-129800)
Fix UBSan failures for `typealiasobject`, `paramspecobject`, `typevarobject`, `typevartupleobject`, `paramspecattrobject`

Use _PyCFunction_CAST macros

Use macro for `constevaluatorobject` casts
2025-02-25 13:12:47 +01:00
Bénédikt Tran
ead091357d
gh-111178: fix UBSan failures in Modules/xx*.c (GH-129797)
Fix UBSan failures in `Modules/xxlimited.c`, `Modules/xxlimited_35.c`, `Modules/xxsubtype.c`, `Modules/xxmodule.c`
2025-02-25 13:02:32 +01:00
Bénédikt Tran
3d40317ed2
gh-111178: fix UBSan failures in Objects/typeobject.c (#129799)
Fix UBSan failures for `PyTypeObject`.
Introduce a macro cast for `superobject` and remove redundant casts.
Rename the unused parameter in getter/setter methods  to `closure`
for semantic purposes.
2025-02-25 10:44:59 +00:00
Tomas R.
44213bc57c
gh-130453: pygettext: Extend support for specifying custom keywords (GH-130463) 2025-02-25 12:10:54 +02:00
Justine Krejcha
31ef8fd8e2
Fix a typo in Py_DECREF comment (#128387) 2025-02-25 11:10:40 +01:00
Mark Shannon
014223649c
GH-130396: Use computed stack limits on linux (GH-130398)
* Implement C recursion protection with limit pointers for Linux, MacOS and Windows

* 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-25 09:24:48 +00:00
Russell Keith-Magee
99088ab081
gh-130292: Allow for empty simulator list when running iOS testbed (#130388)
Adds error handling when there are no pre-existing test simulators.
2025-02-25 14:49:05 +08:00
Tian Gao
56e337d32b
Fix a typo in code module test (#130530) 2025-02-25 00:33:52 -05:00
Adam D. Thomas
ccb4ad9219
gh-124703: Change back to raising bdb.BdbQuit when exiting pdb in 'inline' mode in a REPL session (#130395) 2025-02-24 21:27:26 -05:00
Chris Eibl
3a555f09f3
gh-130419: Do not build the _freeze_module project twice in Windows PGO builds (GH-130420) 2025-02-24 21:35:00 +00:00