| Commit message (Collapse) | Author | Age | Files | Lines |
| |
|
|
|
|
|
|
|
|
| |
gh-58124: Avoid CP_UTF8 in UnicodeDecodeError (GH-137415)
Fix name of the Python encoding in Unicode errors of the code page
codec: use "cp65000" and "cp65001" instead of "CP_UTF7" and "CP_UTF8"
which are not valid Python code names.
(cherry picked from commit ce1b747ff68754635b7b12870dfc527184ee3b39)
Co-authored-by: Victor Stinner <vstinner@python.org>
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
(gh-136480)
The free threading build uses QSBR to delay the freeing of dictionary
keys and list arrays when the objects are accessed by multiple threads
in order to allow concurrent reads to proceed with holding the object
lock. The requests are processed in batches to reduce execution
overhead, but for large memory blocks this can lead to excess memory
usage.
Take into account the size of the memory block when deciding when to
process QSBR requests.
Also track the amount of memory being held by QSBR for mimalloc pages.
Advance the write sequence if this memory exceeds a limit. Advancing
the sequence will allow it to be freed more quickly.
Process the held QSBR items from the "eval breaker", rather than from
`_PyMem_FreeDelayed()`. This gives a higher chance that the global read
sequence has advanced enough so that items can be freed.
(cherry picked from commit 113de8545ffe74a4a1dddb9351fa1cbd3562b621)
Co-authored-by: Neil Schemenauer <nas-github@arctrix.com>
Co-authored-by: Sam Gross <colesbury@gmail.com>
|
| |
|
|
|
| |
search (#132574) (#136648)
(cherry picked from commit 85ec3b3b503ffd5b7e45f8b3fa2cec0c10e4bef0)
|
| |
|
|
|
|
|
| |
(#136642)
gh-109700: fix memory error handling in `PyDict_SetDefault` (#136338)
(cherry picked from commit d22e073d2b49313bbf42d40cbe74afa2b69385df)
|
| |
|
|
|
|
|
| |
`ind.__index__` has side-effects (GH-132379) (#136582)
(cherry picked from commit 5e1e21dee35b8e9066692d08033bbbdb562e2c28)
Co-authored-by: Bast <52266665+bast0006@users.noreply.github.com>
|
| |
|
|
|
|
|
|
|
|
| |
extension modules and objects (#135614) (#136126)
gh-135607: remove null checking of weakref list in dealloc of extension modules and objects (#135614)
(cherry picked from commit b1056c2a446b43452e457d5fd5f1bde66afd3883)
Co-authored-by: Xuanteng Huang <44627253+xuantengh@users.noreply.github.com>
Co-authored-by: Kumar Aditya <kumaraditya@python.org>
|
| |
|
|
|
|
|
|
| |
not instantiable (GH-135981) (GH-136031)
Previous error message suggested to use cls.__new__(), which
obviously does not work. Now the error message is the same as for
cls(...).
(cherry picked from commit c45f4f3ebe34529a8db3a7918e8dd2e9f7ce8e86)
|
| |
|
|
|
|
|
|
|
| |
(#135895)
gh-135878: Fix crash in `types.SimpleNamespace.__repr__` (GH-135889)
(cherry picked from commit b3ab94acd308591bbdf264f1722fedc7ee25d6fa)
Co-authored-by: sobolevn <mail@sobolevn.me>
Co-authored-by: Peter Bierma <zintensitydev@gmail.com>
|
| |
|
|
|
|
| |
Use `ma_used` instead of `ma_keys->dk_nentries` for modification check
so that we only check if the dictionary is modified, not if new keys are
added to a different dictionary that shared the same keys object.
(cherry picked from commit d8994b0a77cc9821772d05db00a6ab23382fa17d)
|
| |
|
|
|
|
|
| |
generator (GH-135453)
Backport of 8e20e42cc63321dacc500d7670bfc225ca04e78b from GH-126956
Closes GH-125723
|
| |
|
|
|
|
|
| |
(GH-133658) (GH-134965)
random.getrandbits() can now generate more that 2**31 bits.
random.randbytes() can now generate more that 256 MiB.
(cherry picked from commit 68784fed78aa297f0de0d038742495709185bef5)
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
error handler (GH-129648) (GH-133944)
If the error handler is used, a new bytes object is created to set as
the object attribute of UnicodeDecodeError, and that bytes object then
replaces the original data. A pointer to the decoded data will became invalid
after destroying that temporary bytes object. So we need other way to return
the first invalid escape from _PyUnicode_DecodeUnicodeEscapeInternal().
_PyBytes_DecodeEscape() does not have such issue, because it does not
use the error handlers registry, but it should be changed for compatibility
with _PyUnicode_DecodeUnicodeEscapeInternal().
(cherry picked from commit 9f69a58623bd01349a18ba0c7a9cb1dad6a51e8e)
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
|
| |
|
|
|
|
|
|
|
| |
This fixes a crash in `_PyObject_TryGetInstanceAttribute` due to the use
of `_PyDictKeys_StringLookup` on an unlocked dictionary that may be
concurrently modified.
The underlying bug was already fixed in 3.14 and the main branch.
(partially cherry picked from commit 1b15c89a17ca3de6b05de5379b8717e9738c51ef)
|
| |
|
|
| |
(GH-133617)
|
| |
|
| |
(cherry picked from commit 92337f666e8a076a68305a8d6dc8bc9c095000e9)
|
| |
|
|
|
|
|
|
|
|
|
| |
(gh-133686)
The function `dict_set_fromkeys()` adds elements of a set to an existing
dictionary. The size of the expanded dictionary was estimated with
`PySet_GET_SIZE(iterable)`, which did not take into account the size of the
existing dictionary.
(cherry picked from commit 421ba589d02b53131f793889d221ef3b1f1410a4)
Co-authored-by: Angela Liss <59097311+angela-tarantula@users.noreply.github.com>
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
(gh-133039) (gh-133126)
* gh-132070: Use _PyObject_IsUniquelyReferenced in unicodeobject (gh-133039)
---------
(cherry picked from commit 75cbb8d89e7e92ccaba5c615c72459f241dca8b1)
Co-authored-by: Donghee Na <donghee.na@python.org>
Co-authored-by: Kumar Aditya <kumaraditya@python.org>
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
* Add _PyObject_IsUniquelyReferenced
---------
Co-authored-by: Kumar Aditya <kumaraditya@python.org>
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
|
| |
|
|
|
| |
Two races related to the type lookup cache, when used in the
free-threaded build. This caused test_opcache to sometimes fail (as
well as other hard to re-produce failures).
|
| |
|
|
|
|
|
|
|
| |
gh-132713: Fix typing.Union[index] race condition (GH-132802)
Add union_init_parameters() helper function. Use a critical section
to initialize the 'parameters' member.
(cherry picked from commit dc3e9638c22fc1fa807a88c32316ac2558a4b879)
Co-authored-by: Victor Stinner <vstinner@python.org>
|
| |
|
|
|
| |
Hold a strong reference to the item while calling repr(item).
(cherry picked from commit a4ea80d52394bafffb2257abbe815c7ffdb003a3)
|
| |
|
|
|
|
|
| |
manually (GH-132772) (#132786)
(cherry picked from commit fa70bf85931eff62cb24fb2f5b7e86c1dcf642d0)
Co-authored-by: Peter Bierma <zintensitydev@gmail.com>
|
| |
|
|
|
|
|
|
|
| |
`bases` (GH-132212) (#132548)
gh-132176: Fix crash on `type()` when `tuple` subclass passed as `bases` (GH-132212)
(cherry picked from commit b6c552f9e614bab4acf21584baed997f57e74114)
Co-authored-by: sobolevn <mail@sobolevn.me>
Co-authored-by: Victor Stinner <vstinner@python.org>
|
| | |
|
| |
|
|
|
| |
code object (#129127)
GH-127953: Make line number lookup O(1) regardless of the size of the code object (GH-128350)
|
| |
|
|
|
|
|
| |
(gh-131722)
(cherry picked from commit 0a91456ad14bb598646f50bf8f034e8887c0c468)
Co-authored-by: Tomasz Pytel <tompytel@gmail.com>
|
| |
|
|
|
|
|
| |
The clearing of the key, hash, and value need to use atomic operations
to avoid a data race with concurrent read operations.
(cherry picked from commit c00ac578241b3213ceb79c1f32bc83ea471f02da)
Co-authored-by: Sam Gross <colesbury@gmail.com>
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
(GH-130901) (#130953)
The free-threading build interns and immortalizes most constants
generated by the bytecode compiler. However, users can construct their
own code objects with arbitrary constants. We should not intern or
immortalize these objects if they are not of a type that we know how to
handle.
This change fixes a reference leak failure in the recently added
`test_code.test_unusual_constants` test. It also addresses a potential
crash that could occur when attempting to destroy an immortalized
object during interpreter shutdown.
(cherry picked from commit 12db45211d411583cbe272c7ba6811a811b721ca)
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
_PyModule_IsPossiblyShadowing (GH-130934) (#130939)
gh-130932: Fix incorrect exception handling in _PyModule_IsPossiblyShadowing (GH-130934)
I chose to not raise an exception here because I think it would be
confusing for module attribute access to start raising something other
than AttributeError if e.g. the cwd goes away
Without the change in moduleobject.c
```
./python.exe -m unittest test.test_import.ImportTests.test_script_shadowing_stdlib_cwd_failure
...
Assertion failed: (PyErr_Occurred()), function _PyObject_SetAttributeErrorContext, file object.c, line 1253.
```
(cherry picked from commit 0a9ae5ed48e6ea078f67ba03635c1c26209b5def)
Co-authored-by: Shantanu <12621235+hauntsaninja@users.noreply.github.com>
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
(GH-130853) (#130880)
The bytecode compiler only generates a few different types of constants,
like str, int, tuple, slices, etc. Users can construct code objects with
various unusual constants, including ones that are not hashable or not
even constant.
The free threaded build previously crashed with a fatal error when
confronted with these constants. Instead, treat distinct objects of
otherwise unhandled types as not equal for the purposes of deduplication.
(cherry picked from commit 2905690a91bf72cdf0fb919b5193849bb67732e2)
Co-authored-by: Sam Gross <colesbury@gmail.com>
|
| |
|
|
|
|
|
|
| |
(gh-130778) (gh-130833)
gh-130547: Fix race between dict_dealloc and split_keys_entry_added (gh-130778)
(cherry picked from commit 80e6d3ec4972220587c8b883161311a49ea8d0ff)
Co-authored-by: Donghee Na <donghee.na@python.org>
|
| |
|
|
|
|
|
| |
(gh-130808) (#130857)
This avoids a case where the interpreter's queue of memory to be freed
could grow rapidly if there are many short lived threads.
(cherry picked from commit 2f6e0e9f7001769be746ee96356656d3ebdc7f96)
|
| |
|
|
|
|
|
|
|
|
|
|
|
| |
Postpone <stdbool.h> inclusion after Python.h (#130641)
Remove inclusions prior to Python.h.
<stdbool.h> will cause <features.h> to be included before Python.h can
define some macros to enable some additional features, causing multiple
types not to be defined down the line.
(cherry picked from commit 830f04b5056db92ba96387db0a778dcd19a39522)
Co-authored-by: Hugo Beauzée-Luyssen <hugo@beauzee.fr>
|
| |
|
|
|
|
|
|
|
|
| |
Fix a few thread-safety bugs to enable test_opcache when run with TSAN:
* Use relaxed atomics when clearing `ht->_spec_cache.getitem`
(gh-115999)
* Add temporary suppression for type slot modifications (gh-127266)
* Use atomic load when reading `*dictptr`
(cherry picked from commit f151d271591ec525eaf01fa7b128e575374888b9)
|
| |
|
|
|
|
|
|
|
|
| |
(GH-130556)
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().
(cherry picked from commit 0ef4ffeefd1737c18dc9326133c7894d58108c2e)
|
| |
|
|
|
|
|
|
|
|
|
|
| |
`__annotations__` and `__type_params__` in free-threading build (GH-129016) (#129729)
* gh-128714: Fix function object races in `__annotate__`, `__annotations__` and `__type_params__` in free-threading build (#129016)
(cherry picked from commit 55f17b77c305be877ac856d6426b13591cbc7fc8)
---------
Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
|
| |
|
|
|
|
| |
(#130311)
[3.13] gh-128396: Fix a crash when inline comprehension has the same local variable as the outside scope (GH-130235)
(cherry picked from commit ccf17323c218a2fdcf7f4845d3eaa74ebddefa44)
|
| |
|
|
|
|
|
|
| |
(GH-130237) (GH-130246)
(cherry picked from commit b93b7e566e5a4efe7f077af2083140e50bd2b08f)
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
(GH-130127)
We had the definition of what makes a character "printable" documented in three places, giving two different definitions.
The definition in the comment on `_PyUnicode_IsPrintable` was inverted; correct that.
With that correction, the two definitions turn out to be equivalent -- but to confirm that, you have to go look up, or happen to know, that those are the only five "Other" categories and only three "Separator" categories in the Unicode character database. That makes it hard for the reader to tell whether they really are the same, or if there's some subtle difference in the intended semantics.
Fix that by cutting the C API docs' and the C comment's copies of the subtle details, in favor of referring to the Python-level docs. That ensures it's explicit that these are all meant to agree, and also lets us concentrate improvements to the wording in one place.
Speaking of which, borrow some ideas from the C comment, along with other tweaks, to hopefully add a bit more clarity to that one newly-centralized copy in the docs.
Also add a thorough test that the implementation agrees with this definition.
Author: Greg Price <gnprice@gmail.com>
Co-authored-by: Greg Price <gnprice@gmail.com>
(cherry picked from commit 3402e133ef26736296c07992266a82b181a5d532)
|
| |
|
|
|
|
|
|
|
|
| |
We should use a relaxed atomic load in the free threading build in
`PyType_Modified()` because that's called without the type lock held.
It's not necessary to use atomics in `type_modified_unlocked()`.
We should also use `FT_ATOMIC_STORE_UINT_RELAXED()` instead of the
`UINT32` variant because `tp_version_tag` is declared as `unsigned int`.
(cherry picked from commit 57f45ee2d8ee23c2a1d1daba4095a5a044169419)
|
| |
|
|
|
| |
(cherry picked from commit 0706bab1c0985761cdbc07ab448f98c717276b36)
Co-authored-by: Abhijeet <abhijeetsharma2002@gmail.com>
|
| |
|
|
|
|
|
|
|
| |
The call to `PySequence_List()` could temporarily unlock and relock the
set, allowing the items to be cleared and return the incorrect
notation `{}` for a empty set (it should be `set()`).
(cherry picked from commit a7427f2db937adb4c787754deb4c337f1894fe86)
Co-authored-by: T. Wouters <thomas@python.org>
|
| |
|
|
|
|
|
| |
`_PyObject_GenericGetAttrWithDict` (GH-128297) (GH-129979)
(cherry picked from commit 47d2cb8eb7595df5940225867dbb66b6dd59413a)
Co-authored-by: Bogdan Romanyuk <65823030+wrongnull@users.noreply.github.com>
|
| |
|
|
|
|
| |
Found while running `test_load_attr_module` from `test_opcache` under TSan.
(cherry picked from commit 34379d0a593e5a76e2f754cdd7fccb79f25a4613)
Co-authored-by: Sam Gross <colesbury@gmail.com>
|
| |
|
|
|
|
|
|
|
| |
build (gh-129704) (gh-129742)
The MemoryError freelist was not thread-safe in the free threaded build.
Use a mutex to protect accesses to the freelist. Unlike other freelists,
the MemoryError freelist is not performance sensitive.
(cherry picked from commit 51b4edb1a4092f60d84f7d14eb41c12085e39c31)
|
| |
|
|
|
| |
(#129725)
(cherry picked from commit 63f0406d5ad25a55e49c3903b29407c50a17cfd5)
|
| |
|
| |
gh-129643: fix thread safety of `PyList_SetItem` (#129644)
|
| |
|
|
|
|
|
|
|
| |
`_PyGen_SetStopIterationValue` (GH-128287) (#128789)
gh-128078: Use `PyErr_SetRaisedException` in `_PyGen_SetStopIterationValue` (GH-128287)
(cherry picked from commit 402b91da87052878b4e7e8946ba91bdf4ee4bebe)
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
Co-authored-by: Kumar Aditya <kumaraditya@python.org>
|
| |
|
|
|
|
|
|
|
| |
`_PyGen_SetStopIterationValue` (GH-128780) (#128785)
gh-128078: Clear exception in `anext` before calling `_PyGen_SetStopIterationValue` (GH-128780)
(cherry picked from commit 76ffaef729c91bb79da6df2ade48f3ec51118300)
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
Co-authored-by: Kumar Aditya <kumaraditya@python.org>
|
| |
|
|
|
|
|
|
| |
(#128769)
* gh-128759: fix data race in `type_modified_unlocked` (GH-128764)
(cherry picked from commit 6e1e78054060ad326f26dd8dbf12adfedbb52883)
Co-authored-by: sobolevn <mail@sobolevn.me>
|
| |
|
|
|
|
|
|
| |
number of super-classes (GH-127523) (#128699)
gh-126862: Use `Py_ssize_t` instead of `int` when processing the number of super-classes (GH-127523)
(cherry picked from commit 2fcdc8488c32d18f4567f797094068a994777f16)
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
|