41 Commits

Author SHA1 Message Date
Victor Stinner
8435a2278f gh-141376: Fix exported symbols (GH-141377)
* gh-141376: Fix exported symbols

* _io module: add "_Py_" prefix to "spec" variables. For example,
  rename bufferedrandom_spec to _Py_bufferedrandom_spec.
* typevarobject.c: add "static" to "spec" and "slots" variables.
* import.c: add "static" to "pkgcontext" variable.

* No longer export textiowrapper_slots
2025-11-11 09:21:24 +01:00
Petr Viktorin
ea4cc585cd gh-139817: Fix refleak in TypeAliasType(qualname=non_string) (GH-140197) 2025-10-16 11:04:04 +00:00
Mikhail Efimov
f673f0e7b4 gh-139817: Attribute __qualname__ is added to TypeAliasType (#139919) 2025-10-15 09:08:17 -07:00
Mikhail Efimov
be60e4b4f3 gh-140000: Traverse name attribute for TypeVar, TypeVarTuple, TypeAliasType, ParamSpec (#140016) 2025-10-13 13:10:39 -07:00
Peter Bierma
4f6ecd10c2 gh-138342: Use a common utility for visiting an object's type (GH-138343)
Add `_PyObject_VisitType` in place of `tp_traverse` functions that only visit the object's type.
2025-09-01 16:20:33 +00:00
Victor Stinner
f49a07b531 gh-133968: Add PyUnicodeWriter_WriteASCII() function (#133973)
Replace most PyUnicodeWriter_WriteUTF8() calls with
PyUnicodeWriter_WriteASCII().

Unrelated change to please the linter: remove an unused
import in test_ctypes.

Co-authored-by: Peter Bierma <zintensitydev@gmail.com>
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
2025-05-29 14:54:30 +00:00
Victor Stinner
5c44d7d99c gh-130931: Add pycore_interpframe.h internal header (#131249)
Move _PyInterpreterFrame and associated functions
to a new pycore_interpframe.h header.
2025-03-19 18:17:44 +01:00
Mark Shannon
a45f25361d GH-131238: More refactoring of core header files (GH-131351)
Adds new pycore_stats.h header file to help break dependencies involving the pycore_code.h header.
2025-03-17 14:41:05 +00:00
Victor Stinner
9a63138e09 gh-111178: Fix function signatures in misc files (#131180) 2025-03-13 16:55:08 +01:00
Victor Stinner
9d759b63d8 gh-111178: Change Argument Clinic signature for METH_O (#130682)
Use "PyObject*" for METH_O functions to fix an undefined behavior.
2025-03-11 16:33:36 +01:00
Jelle Zijlstra
dc6d66f44c gh-105499: Merge typing.Union and types.UnionType (#105511)
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
Co-authored-by: Ken Jin <kenjin@python.org>
Co-authored-by: Carl Meyer <carl@oddbird.net>
2025-03-04 11:44:19 -08:00
Tomas R.
e091520fdb gh-126085: Add tp_iter to TypeAliasType to allow star unpacking (#127981) 2025-03-04 11:34:59 -08: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
Jelle Zijlstra
dcf629213b gh-119180: Add VALUE_WITH_FAKE_GLOBALS format to annotationlib (#124415) 2024-11-26 15:40:13 +00:00
Serhiy Storchaka
06a8b0bb5e gh-122943: Remove the object converter for var-positional parameter (GH-126560) 2024-11-08 05:41:54 +00:00
sobolevn
2115d76acc gh-124787: Fix TypeAliasType and incorrect type_params (#124795)
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
2024-10-11 17:39:18 +03:00
Jelle Zijlstra
2c10832887 gh-119180: Rename SOURCE format to STRING (#124620) 2024-09-26 13:49:48 -07:00
sobolevn
abe5f799e6 gh-124498: Fix TypeAliasType not to be generic, when type_params=() (#124499) 2024-09-26 17:15:38 +03:00
Jelle Zijlstra
0268b072d8 gh-119180: Disallow instantiation of ConstEvaluator objects (#124561) 2024-09-25 23:30:17 +00:00
Sam Gross
f4997bb3ac gh-123923: Defer refcounting for f_funcobj in _PyInterpreterFrame (#124026)
Use a `_PyStackRef` and defer the reference to `f_funcobj` when
possible. This avoids some reference count contention in the common case
of executing the same code object from multiple threads concurrently in
the free-threaded build.
2024-09-24 20:08:18 +00:00
sobolevn
04eb5c8db1 gh-122361: Use proper PyUnicodeWriter_* API in constevaluator_call (#122362) 2024-07-27 21:33:38 +03:00
Jelle Zijlstra
ae192262ad gh-119180: Add evaluate functions for type params and type aliases (#122212) 2024-07-27 17:24:10 +00:00
Nikita Sobolev
004db2170e Rename notimplemented_methods into nodefault_methods (#118896) 2024-05-10 12:46:20 +00:00
Jelle Zijlstra
ca269e58c2 gh-116126: Implement PEP 696 (#116129)
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
Co-authored-by: Shantanu <12621235+hauntsaninja@users.noreply.github.com>
2024-05-03 06:17:32 -07:00
Nikita Sobolev
6a4528d70c gh-110864: TypeVar constructor: Partially revert gh-110784, constraints cannot be NULL (#110922) 2023-10-16 15:01:04 +00:00
Nikita Sobolev
bad7a35055 gh-110907: AC: Disallow using * with vararg (#110908) 2023-10-16 15:26:11 +01:00
Jelle Zijlstra
d2a536b170 gh-110782: Fix crash when TypeVar is constructed with keyword args (#110784) 2023-10-12 16:00:12 -07:00
Victor Stinner
fc2cb86d21 gh-107073: Make PyObject_VisitManagedDict() public (#108763)
Make PyObject_VisitManagedDict() and PyObject_ClearManagedDict()
functions public in Python 3.13 C API.

* Rename _PyObject_VisitManagedDict() to PyObject_VisitManagedDict().
* Rename _PyObject_ClearManagedDict() to PyObject_ClearManagedDict().
* Document these functions.
2023-10-02 19:24:08 +02:00
Nikita Sobolev
47af188593 Add missing PyDoc_STR calls (#109393)
In files:

* Modules/_ctypes/cfield.c
* Modules/_struct.c
* Objects/dictobject.c
* Objects/typevarobject.c
* Objects/unionobject.c
2023-09-15 15:10:48 +02:00
Serhiy Storchaka
9205dfeca5 gh-108635: Make parameters of some implementations of special methods positional-only (GH-108636) 2023-08-29 17:55:56 +03:00
Jelle Zijlstra
482fad7f01 gh-108295: Fix crashes with TypeVar weakrefs (#108517) 2023-08-26 17:13:33 -07:00
Mark Shannon
006e44f950 GH-108035: Remove the _PyCFrame struct as it is no longer needed for performance. (GH-108036) 2023-08-17 11:16:03 +01:00
Victor Stinner
1a3faba9f1 gh-106869: Use new PyMemberDef constant names (#106871)
* Remove '#include "structmember.h"'.
* If needed, add <stddef.h> to get offsetof() function.
* Update Parser/asdl_c.py to regenerate Python/Python-ast.c.
* Replace:

  * T_SHORT => Py_T_SHORT
  * T_INT => Py_T_INT
  * T_LONG => Py_T_LONG
  * T_FLOAT => Py_T_FLOAT
  * T_DOUBLE => Py_T_DOUBLE
  * T_STRING => Py_T_STRING
  * T_OBJECT => _Py_T_OBJECT
  * T_CHAR => Py_T_CHAR
  * T_BYTE => Py_T_BYTE
  * T_UBYTE => Py_T_UBYTE
  * T_USHORT => Py_T_USHORT
  * T_UINT => Py_T_UINT
  * T_ULONG => Py_T_ULONG
  * T_STRING_INPLACE => Py_T_STRING_INPLACE
  * T_BOOL => Py_T_BOOL
  * T_OBJECT_EX => Py_T_OBJECT_EX
  * T_LONGLONG => Py_T_LONGLONG
  * T_ULONGLONG => Py_T_ULONGLONG
  * T_PYSSIZET => Py_T_PYSSIZET
  * T_NONE => _Py_T_NONE
  * READONLY => Py_READONLY
  * PY_AUDIT_READ => Py_AUDIT_READ
  * READ_RESTRICTED => Py_AUDIT_READ
  * PY_WRITE_RESTRICTED => _Py_WRITE_RESTRICTED
  * RESTRICTED => (READ_RESTRICTED | _Py_WRITE_RESTRICTED)
2023-07-25 15:28:30 +02:00
Jelle Zijlstra
945d3cbf2e gh-106403: Restore weakref support for TypeVar and friends (#106418) 2023-07-11 08:43:24 -07:00
Victor Stinner
bc7eb17084 gh-106320: Use _PyInterpreterState_GET() (#106336)
Replace PyInterpreterState_Get() with inlined
_PyInterpreterState_GET().
2023-07-02 16:37:37 +00:00
Alex Waygood
8e755923c9 Miscellaneous improvements to the typing docs (#105529)
Mostly, these are changes so that we use shorter sentences and shorter paragraphs. In particular, I've tried to make the first sentence introducing each object in the typing API short and declarative.
2023-06-09 15:08:57 +00:00
Jelle Zijlstra
060277d96b gh-103921: Document PEP 695 (#104642)
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
2023-05-26 10:48:17 -07:00
Jelle Zijlstra
fe77a99fc8 gh-104879: Fix TypeAliasType.__module__ in exec() (#104881) 2023-05-24 11:48:13 -07:00
Jelle Zijlstra
b9dce3aec4 gh-104549: Set __module__ on TypeAliasType (#104550) 2023-05-18 15:56:15 -07:00
Jelle Zijlstra
26931944dd typing: Add more tests for TypeVar (#104571)
During the PEP 695 implementation at one point I made
TypeVar.__name__ return garbage, and all of test_typing passed.
So I decided to add a few more tests. In the process I discovered
a minor incompatibility from the C implementation of TypeVar:
empty constraints were returned as None instead of an empty tuple.
2023-05-17 06:08:21 -07:00
Jelle Zijlstra
24d8b88420 gh-103763: Implement PEP 695 (#103764)
This implements PEP 695, Type Parameter Syntax. It adds support for:

- Generic functions (def func[T](): ...)
- Generic classes (class X[T](): ...)
- Type aliases (type X = ...)
- New scoping when the new syntax is used within a class body
- Compiler and interpreter changes to support the new syntax and scoping rules 

Co-authored-by: Marc Mueller <30130371+cdce8p@users.noreply.github.com>
Co-authored-by: Eric Traut <eric@traut.com>
Co-authored-by: Larry Hastings <larry@hastings.org>
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
2023-05-15 20:36:23 -07:00