summaryrefslogtreecommitdiffstats
path: root/Objects/genericaliasobject.c
Commit message (Collapse)AuthorAgeFilesLines
* gh-99300: Use Py_NewRef() in Objects/ directory (#99335)Victor Stinner2022-11-101-16/+8
| | | | Replace Py_INCREF() and Py_XINCREF() with Py_NewRef() and Py_XNewRef() in C files of the Objects/ directory.
* gh-98852: Fix subscription of type aliases (GH-98920)Serhiy Storchaka2022-11-011-0/+7
| | | | | Fix subscription of type aliases containing bare generic types or types like TypeVar: for example tuple[A, T][int] and tuple[TypeVar, T][int], where A is a generic type, and T is a type variable.
* gh-94607: Fix subclassing generics (GH-94610)Ken Jin2022-07-091-0/+4
| | | Co-authored-by: Serhiy Storchaka <3659035+serhiy-storchaka@users.noreply.github.com>
* gh-89828: Do not relay the __class__ attribute in GenericAlias (#93754)Serhiy Storchaka2022-06-181-0/+1
| | | | | list[int].__class__ returned type, and isinstance(list[int], type) returned True. It caused numerous problems in code that checks isinstance(x, type).
* gh-91162: Support splitting of unpacked arbitrary-length tuple over TypeVar ↵Serhiy Storchaka2022-06-121-56/+43
| | | | | | | | | and TypeVarTuple parameters (alt) (GH-93412) For example: A[T, *Ts][*tuple[int, ...]] -> A[int, *tuple[int, ...]] A[*Ts, T][*tuple[int, ...]] -> A[*tuple[int, ...], int]
* gh-93345: Fix a crash in substitution of nested TypeVar after TypeVarTuple ↵Serhiy Storchaka2022-05-311-1/+1
| | | | | | (GH-93346) For example: tuple[*Ts, list[T]][int, str, bool]
* gh-91162: Fix substitution of unpacked tuples in generic aliases (GH-92335)Serhiy Storchaka2022-05-081-13/+108
|
* gh-87390: Fix starred tuple equality and pickling (GH-92337)Serhiy Storchaka2022-05-051-0/+26
|
* gh-87390: Add __unpacked__ attribute to types.GenericAlias (#92059)Jelle Zijlstra2022-05-021-0/+2
|
* bpo-43224: Implement substitution of unpacked TypeVarTuple in C (GH-31828)Serhiy Storchaka2022-04-301-14/+104
| | | | Co-authored-by: Matthew Rahtz <mrahtz@gmail.com>
* gh-91632: Fix generic_alias_iterator to be finalized at exit. (GH-91727)Dong-hee Na2022-04-201-2/+4
|
* gh-91118: Fix docstrings that do not honor --without-doc-strings (#31769)Oleg Iarygin2022-04-181-4/+6
| | | | Co-authored-by: Éric <merwok@netwok.org> Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
* bpo-47067: Optimize calling GenericAlias objects (GH-31996)penguin_wwy2022-03-211-7/+32
| | | Use vectorcall, and replace `PyObject_SetAttrString` with `PyObject_SetAttr` and a global string.
* bpo-43224: Implement PEP 646 changes to genericaliasobject.c (GH-31019)Matthew Rahtz2022-03-121-0/+75
| | | | | | | Specifically, prepare for starring of tuples via a new genericalias iter type. GenericAlias also partially supports the iterator protocol after this change. Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com> Co-authored-by: Kumar Aditya <59607654+kumaraditya303@users.noreply.github.com> Co-authored-by: Ken Jin <28750310+Fidget-Spinner@users.noreply.github.com>
* bpo-44796: Unify TypeVar and ParamSpec substitution (GH-31143)Serhiy Storchaka2022-03-111-32/+14
| | | | | | Add methods __typing_subst__() in TypeVar and ParamSpec. Simplify code by using more object-oriented approach, especially the C code for types.GenericAlias and the Python code for collections.abc.Callable.
* bpo-46541: Replace core use of _Py_IDENTIFIER() with statically initialized ↵Eric Snow2022-02-081-12/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | global objects. (gh-30928) We're no longer using _Py_IDENTIFIER() (or _Py_static_string()) in any core CPython code. It is still used in a number of non-builtin stdlib modules. The replacement is: PyUnicodeObject (not pointer) fields under _PyRuntimeState, statically initialized as part of _PyRuntime. A new _Py_GET_GLOBAL_IDENTIFIER() macro facilitates lookup of the fields (along with _Py_GET_GLOBAL_STRING() for non-identifier strings). https://bugs.python.org/issue46541#msg411799 explains the rationale for this change. The core of the change is in: * (new) Include/internal/pycore_global_strings.h - the declarations for the global strings, along with the macros * Include/internal/pycore_runtime_init.h - added the static initializers for the global strings * Include/internal/pycore_global_objects.h - where the struct in pycore_global_strings.h is hooked into _PyRuntimeState * Tools/scripts/generate_global_objects.py - added generation of the global string declarations and static initializers I've also added a --check flag to generate_global_objects.py (along with make check-global-objects) to check for unused global strings. That check is added to the PR CI config. The remainder of this change updates the core code to use _Py_GET_GLOBAL_IDENTIFIER() instead of _Py_IDENTIFIER() and the related _Py*Id functions (likewise for _Py_GET_GLOBAL_STRING() instead of _Py_static_string()). This includes adding a few functions where there wasn't already an alternative to _Py*Id(), replacing the _Py_Identifier * parameter with PyObject *. The following are not changed (yet): * stop using _Py_IDENTIFIER() in the stdlib modules * (maybe) get rid of _Py_IDENTIFIER(), etc. entirely -- this may not be doable as at least one package on PyPI using this (private) API * (maybe) intern the strings during runtime init https://bugs.python.org/issue46541
* bpo-45167: Fix deepcopying of GenericAlias (GH-28324)Serhiy Storchaka2021-09-151-0/+2
|
* bpo-44854: Remove trailing whitespaces (GH-27689)Serhiy Storchaka2021-08-091-1/+1
|
* bpo-44654: Refactor and clean up the union type implementation (GH-27196)Serhiy Storchaka2021-07-171-4/+3
|
* bpo-44490: Add __parameters__ and __getitem__ to types.Union (GH-26980)Yurii Karabas2021-07-061-19/+31
| | | | Co-authored-by: Ken Jin <28750310+Fidget-Spinner@users.noreply.github.com> Co-authored-by: Guido van Rossum <gvanrossum@gmail.com>
* bpo-44562: Use PyType_GenericAlloc in Py_GenericAlias (GH-27021)Pablo Galindo2021-07-051-2/+2
| | | | | | | | | * bpo-44562: Use PyType_GenericAlloc in Py_GenericAlias * Update Objects/genericaliasobject.c Co-authored-by: Serhiy Storchaka <storchaka@gmail.com> Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
* bpo-44562: Remove invalid PyObject_GC_Del from error path of ↵Ken Jin2021-07-041-3/+3
| | | | types.GenericAlias … (GH-27016)
* bpo-41559: Change PEP 612 implementation to pure Python (#25449)Ken Jin2021-04-281-62/+14
|
* bpo-42814: Fix undefined behavior in Objects/genericaliasobject.c (GH-24073)Zackery Spytz2021-01-031-1/+1
| | | | | In is_typing_name(), va_end() is not always called before the function returns. It is undefined behavior to call va_start() without also calling va_end().
* bpo-41559: Implement PEP 612 - Add ParamSpec and Concatenate to typing (#23702)kj2020-12-241-14/+62
|
* bpo-42195: Ensure consistency of Callable's __args__ in collections.abc and ↵kj2020-12-131-21/+39
| | | | typing (GH-23060)
* bpo-42576: Raise TypeError when passing in keyword arguments to GenericAlias ↵kj2020-12-051-1/+1
| | | | | | | | | (GH-23656) Use `_PyArg_NoKeywords` instead of `_PyArg_NoKwnames` when checking the `kwds` tuple when creating `GenericAlias`. This fixes an interpreter crash when passing in keyword arguments to `GenericAlias`'s constructor. Needs backport to 3.9. Automerge-Triggered-By: GH:gvanrossum
* bpo-42332: Add weakref slot to types.GenericAlias (GH-23250)kj2020-11-161-0/+6
| | | Automerge-Triggered-By: GH:gvanrossum
* bpo-42233: Add union type expression support for GenericAlias and fix ↵kj2020-11-091-0/+6
| | | | de-duplicating of GenericAlias (GH-23077)
* Fix the attribute names in the docstring of GenericAlias (GH-22594)Mikhail Golubev2020-10-081-1/+1
|
* bpo-41780: Fix __dir__ of types.GenericAlias (GH-22262)Batuhan Taskaya2020-09-151-0/+39
| | | Automerge-Triggered-By: @gvanrossum
* bpo-39573: Use the Py_TYPE() macro (GH-21433)Victor Stinner2020-07-101-1/+1
| | | Replace obj->ob_type with Py_TYPE(obj).
* bpo-39573: Use Py_IS_TYPE to check for types (GH-19882)Hai Shi2020-05-041-2/+2
|
* bpo-40408: Fix support of nested type variables in GenericAlias. (GH-19836)Serhiy Storchaka2020-05-041-19/+104
|
* Update ga_new to use _PyArg_CheckPositional and _PyArg_NoKwnames (GH-19679)Dong-hee Na2020-04-231-4/+2
|
* bpo-40268: Remove unused structmember.h includes (GH-19530)Victor Stinner2020-04-151-2/+2
| | | | | | If only offsetof() is needed: include stddef.h instead. When structmember.h is used, add a comment explaining that PyMemberDef is used.
* bpo-39481: Implementation for PEP 585 (#18239)Guido van Rossum2020-04-071-0/+507
This implements things like `list[int]`, which returns an object of type `types.GenericAlias`. This object mostly acts as a proxy for `list`, but has attributes `__origin__` and `__args__` that allow recovering the parts (with values `list` and `(int,)`. There is also an approximate notion of type variables; e.g. `list[T]` has a `__parameters__` attribute equal to `(T,)`. Type variables are objects of type `typing.TypeVar`.