Commit graph

8787 commits

Author SHA1 Message Date
Mark Shannon
f5b6356a11
GH-128563: Add new frame owner type for interpreter entry frames (GH-129078)
Add new frame owner type for interpreter entry frames
2025-01-21 10:15:02 +00:00
Mark Shannon
7239da7559
GH-127953: Make line number lookup O(1) regardless of the size of the code object (GH-128350) 2025-01-21 09:33:23 +00:00
Mark Shannon
ab61d3f430
GH-128914: Remove conditional stack effects from bytecodes.c and the code generators (GH-128918) 2025-01-20 17:09:23 +00:00
Erlend E. Aasland
da0f47ceab
gh-111178: Regen clinic and fix exceptions.c post gh-128447 (#129060) 2025-01-20 12:46:30 +00:00
Erlend E. Aasland
537296cdcd
gh-111178: Generate correct signature for most self converters (#128447) 2025-01-20 12:40:18 +01:00
Peter Bierma
4d0a6595a0
gh-128360: Add _Py_AssertHoldsTstate as assertion for holding a thread state (#128361)
Co-authored-by: Kumar Aditya <kumaraditya@python.org>
2025-01-20 17:04:35 +05:30
Sam Gross
d66c08aa75
gh-128923: Use zero to indicate unassigned unique id (#128925)
In the free threading build, the per thread reference counting uses a
unique id for some objects to index into the local reference count
table. Use 0 instead of -1 to indicate that the id is not assigned. This
avoids bugs where zero-initialized heap type objects look like they have
a unique id assigned.
2025-01-17 16:42:27 +01:00
Xuanteng Huang
b44ff6d0df
GH-126599: Remove the "counter" optimizer/executor (GH-126853) 2025-01-16 15:57:04 -08:00
Umar Butler
8d8b854824
gh-128016: Improved invalid escape sequence warning message (#128020) 2025-01-15 18:00:54 +01:00
mpage
b5ee0258bf
gh-115999: Specialize LOAD_ATTR for instance and class receivers in free-threaded builds (#128164)
Finish specialization for LOAD_ATTR in the free-threaded build by adding support for class and instance receivers.
2025-01-14 11:56:11 -08:00
Bénédikt Tran
402b91da87
gh-128078: Use PyErr_SetRaisedException in _PyGen_SetStopIterationValue (#128287)
Co-authored-by: Kumar Aditya <kumaraditya@python.org>
2025-01-13 21:24:13 +05:30
Kumar Aditya
75214f87f1
gh-128421: make getters and setters of BaseException thread safe (#128728) 2025-01-13 20:08:33 +05:30
Bénédikt Tran
4533036e50
gh-111178: fix UBSan failures in Objects/codeobject.c (GH-128240) 2025-01-13 14:25:04 +01:00
Petr Viktorin
aa6579cb60
gh-127773: Disable attribute cache on incompatible MRO entries (GH-127924) 2025-01-13 14:10:41 +01:00
Bénédikt Tran
76ffaef729
gh-128078: Clear exception in anext before calling _PyGen_SetStopIterationValue (#128780)
Co-authored-by: Kumar Aditya <kumaraditya@python.org>
2025-01-13 18:25:09 +05:30
sobolevn
6e1e780540
gh-128759: fix data race in type_modified_unlocked (#128764) 2025-01-13 07:40:52 +00:00
Pieter Eendebak
ff39e3ff7b
gh-126703: Add freelist for PyMethodObject (#128594) 2025-01-12 18:31:49 +05:30
Bénédikt Tran
613240bf03
gh-111178: fix UBSan failures in Objects/bytearrayobject.c (GH-128236)
* fix UBSan failures for `bytesiterobject`
* fix UBSan failures for `PyByteArrayObject`
2025-01-10 11:50:02 +01:00
Bénédikt Tran
295776c7f3
gh-111178: fix UBSan failures in Objects/bytesobject.c (GH-128237)
* remove redundant casts for `bytesobject`
* fix UBSan failures for `striterobject`
2025-01-10 11:48:06 +01:00
Bénédikt Tran
6cf31750e0
gh-111178: fix UBSan failures in Objects/complexobject.c (GH-128241)
fix UBSan failures for `PyComplexObject`
2025-01-10 10:46:36 +00:00
Bénédikt Tran
2fcdc8488c
gh-126862: Use Py_ssize_t instead of int when processing the number of super-classes (#127523) 2025-01-10 03:32:53 +00:00
Bénédikt Tran
845d924efb
gh-111178: fix UBSan failures in Objects/capsule.c (GH-128239)
fix UBSan failures for `PyCapsule`
2025-01-08 14:55:04 +01:00
Bénédikt Tran
1ef6bf4e29
gh-111178: fix UBSan failures in Objects/descrobject.c (GH-128245)
fix UBSan failures for `propertyobject`
2025-01-06 12:50:01 +01:00
Donghee Na
ae23a012e6
gh-128137: Update PyASCIIObject to handle interned field with the atomic operation (gh-128196) 2025-01-05 18:17:06 +09:00
Alexander Shadchin
46cb6340d7
gh-127903: Fix a crash on debug builds when calling Objects/unicodeobject::_copy_characters` (#127876) 2025-01-03 18:47:58 +00:00
Bénédikt Tran
5643032053
gh-111178: fix UBSan failures in Objects/tupleobject.c (GH-128251)
fix UBSan failures for `_PyTupleIterObject`
2025-01-03 15:35:05 +01:00
Bénédikt Tran
aad5ba4b6a
gh-111178: fix UBSan failures in Objects/enumobject.c (GH-128246)
* fix UBSan failures for `enumobject`
* fix UBSan failures for `reversedobject`
2025-01-03 15:29:41 +01:00
Bénédikt Tran
fa985bee61
gh-127787: refactor helpers for PyUnicodeErrorObject internal interface (GH-127789)
- Unify `get_unicode` and `get_string` in a single function.

- Allow to retrieve the underlying `object` attribute, its
  size, and the adjusted 'start' and 'end', all at once.
  Add a new `_PyUnicodeError_GetParams` internal function for this.
  (In `exceptions.c`, it's somewhat common to not need all the attributes,
  but the compiler has opportunity to inline the function and optimize
  unneeded work away. Outside that file, we'll usually need all or
  most of them at once.)

- Use a common implementation for the following functions:

  - `PyUnicode{Decode,Encode}Error_GetEncoding`
  - `PyUnicode{Decode,Encode,Translate}Error_GetObject`
  - `PyUnicode{Decode,Encode,Translate}Error_{Get,Set}Reason`
  - `PyUnicode{Decode,Encode,Translate}Error_{Get,Set}{Start,End}`
2025-01-03 13:37:02 +01:00
Abhijeet
0706bab1c0
gh-128133: use relaxed atomics for hash of bytes (#128412) 2025-01-03 13:50:56 +05:30
Sam Gross
8eebe4e6d0
gh-128212: Fix race in _PyUnicode_CheckConsistency (GH-128367)
There was a data race on the utf8 field between `PyUnicode_SET_UTF8` and
`_PyUnicode_CheckConsistency`. Use the `_PyUnicode_UTF8()` accessor,
which uses an atomic load internally, to avoid the data race.
2025-01-02 14:02:54 -05:00
Bogdan Romanyuk
47d2cb8eb7
gh-128100: Use atomic dictionary load in _PyObject_GenericGetAttrWithDict (GH-128297) 2024-12-30 20:38:49 +00:00
Pieter Eendebak
3bd7730bbd
gh-126868: Add freelist for compact ints to _PyLong_New (#128181)
Co-authored-by: Kumar Aditya <kumaraditya@python.org>
2024-12-26 15:17:22 +00:00
da-woods
42f7a00ae8
Clean up redundant ifdef in list getitem (#128257)
It's already inside a `Py_GIL_DISABLED` block so the `#else` clause is always unused.
2024-12-26 14:40:48 +00:00
Yan Yanchii
5c814c83cd
gh-128198: Add missing error checks for usages of PyIter_Next() (GH-128199) 2024-12-25 19:42:04 +02:00
Mark Shannon
128cc47fbd
GH-127705: Add debug mode for _PyStackRefs inspired by HPy debug mode (GH-128121) 2024-12-20 16:52:20 +00:00
mpage
255762c09f
gh-127274: Defer nested methods (#128012)
Methods (functions defined in class scope) are likely to be cleaned
up by the GC anyway.

Add a new code flag, `CO_METHOD`, that is set for functions defined
in a class scope. Use that when deciding to defer functions.
2024-12-19 13:03:14 -08:00
Neil Schemenauer
1b15c89a17
gh-115999: Specialize STORE_ATTR in free-threaded builds. (gh-127838)
* Add `_PyDictKeys_StringLookupSplit` which does locking on dict keys and
  use in place of `_PyDictKeys_StringLookup`.

* Change `_PyObject_TryGetInstanceAttribute` to use that function
  in the case of split keys.

* Add `unicodekeys_lookup_split` helper which allows code sharing
  between `_Py_dict_lookup` and `_PyDictKeys_StringLookupSplit`.

* Fix locking for `STORE_ATTR_INSTANCE_VALUE`.  Create
  `_GUARD_TYPE_VERSION_AND_LOCK` uop so that object stays locked and
  `tp_version_tag` cannot change.

* Pass `tp_version_tag` to `specialize_dict_access()`, ensuring
  the version we store on the cache is the correct one (in case of
  it changing during the specalize analysis).

* Split `analyze_descriptor` into `analyze_descriptor_load` and
  `analyze_descriptor_store` since those don't share much logic.
  Add `descriptor_is_class` helper function.

* In `specialize_dict_access`, double check `_PyObject_GetManagedDict()`
  in case we race and dict was materialized before the lock.

* Avoid borrowed references in `_Py_Specialize_StoreAttr()`.

* Use `specialize()` and `unspecialize()` helpers.

* Add unit tests to ensure specializing happens as expected in FT builds.

* Add unit tests to attempt to trigger data races (useful for running under TSAN).

* Add `has_split_table` function to `_testinternalcapi`.
2024-12-19 10:21:17 -08:00
Mark Shannon
d2f1d917e8
GH-122548: Implement branch taken and not taken events for sys.monitoring (GH-122564) 2024-12-19 16:59:51 +00:00
Sam Gross
7b811d0562
gh-128008: Add PyWeakref_IsDead() (GH-128009)
The `PyWeakref_IsDead()` function tests if a weak reference is dead
without any side effects. Although you can also detect if a weak
reference is dead using `PyWeakref_GetRef()`, that function returns a
strong reference that must be `Py_DECREF()`'d, which can introduce side
effects if the last reference is concurrently dropped (at least in the
free threading build).
2024-12-19 16:17:15 +01:00
Kumar Aditya
3c168f7f79
gh-128013: fix data race in PyUnicode_AsUTF8AndSize on free-threading (#128021) 2024-12-19 17:08:32 +05:30
Donghee Na
48c70b8f7d
gh-115999: Enable BINARY_SUBSCR_GETITEM for free-threaded build (gh-127737) 2024-12-19 11:08:17 +09:00
Victor Stinner
f802c8bf87
gh-128013: Convert unicodeobject.c macros to functions (#128061)
Convert unicodeobject.c macros to static inline functions.

* Add _PyUnicode_SET_UTF8() and _PyUnicode_SET_UTF8_LENGTH() macros.
* Add PyUnicode_HASH() and PyUnicode_SET_HASH() macros.
* Remove unused _PyUnicode_KIND() and _PyUnicode_GET_LENGTH() macros.
2024-12-18 16:34:31 +01:00
Edward Xu
4937ba54c0
gh-127085: fix some data races in memoryview in free-threading (#127412) 2024-12-17 00:42:19 +05:30
Inada Naoki
5dd775bed0
gh-126024: unicodeobject: optimize find_first_nonascii (GH-127790)
Remove 1 branch.
2024-12-13 17:21:46 +01:00
Bénédikt Tran
8bc18182a7
gh-127691: add type checks when using PyUnicodeError objects (GH-127694) 2024-12-13 17:16:22 +01:00
Victor Stinner
6446408d42
gh-102471, PEP 757: Add PyLong import and export API (#121339)
Co-authored-by: Sergey B Kirpichev <skirpichev@gmail.com>
Co-authored-by: Steve Dower <steve.dower@microsoft.com>
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
2024-12-13 14:24:48 +01:00
Pieter Eendebak
5fc6bb2754
gh-126868: Add freelist for compact int objects (GH-126865) 2024-12-13 10:06:26 +00:00
Mark Shannon
bc262de06b
GH-125174: Mark objects as statically allocated. (#127797)
* Set a bit in the unused part of the refcount on 64 bit machines and the free-threaded build.

* Use the top of the refcount range on 32 bit machines
2024-12-11 17:37:38 +00:00
Mark Shannon
5a23994a3d
GH-127058: Make PySequence_Tuple safer and probably faster. (#127758)
* Use a small buffer, then list when constructing a tuple from an arbitrary sequence.
2024-12-11 14:02:59 +00:00
Srinivas Reddy Thatiparthy (తాటిపర్తి శ్రీనివాస్ రెడ్డి)
db9bea0386
gh-127740: For odd-length input to bytes.fromhex(...) change the error message to ValueError: fromhex() arg must be of even length (#127756) 2024-12-11 08:35:17 +01:00