mirror of
https://github.com/python/cpython.git
synced 2025-08-09 11:29:45 +00:00
Python 3.12.0b2
This commit is contained in:
parent
2d9ead219e
commit
e6c0efa25a
54 changed files with 1207 additions and 234 deletions
|
@ -20,10 +20,10 @@
|
||||||
#define PY_MINOR_VERSION 12
|
#define PY_MINOR_VERSION 12
|
||||||
#define PY_MICRO_VERSION 0
|
#define PY_MICRO_VERSION 0
|
||||||
#define PY_RELEASE_LEVEL PY_RELEASE_LEVEL_BETA
|
#define PY_RELEASE_LEVEL PY_RELEASE_LEVEL_BETA
|
||||||
#define PY_RELEASE_SERIAL 1
|
#define PY_RELEASE_SERIAL 2
|
||||||
|
|
||||||
/* Version as a string */
|
/* Version as a string */
|
||||||
#define PY_VERSION "3.12.0b1+"
|
#define PY_VERSION "3.12.0b2"
|
||||||
/*--end constants--*/
|
/*--end constants--*/
|
||||||
|
|
||||||
/* Version as a single 4-byte hex number, e.g. 0x010502B2 == 1.5.2b2.
|
/* Version as a single 4-byte hex number, e.g. 0x010502B2 == 1.5.2b2.
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
# Autogenerated by Sphinx on Mon May 22 14:02:15 2023
|
# Autogenerated by Sphinx on Tue Jun 6 16:12:51 2023
|
||||||
topics = {'assert': 'The "assert" statement\n'
|
topics = {'assert': 'The "assert" statement\n'
|
||||||
'**********************\n'
|
'**********************\n'
|
||||||
'\n'
|
'\n'
|
||||||
|
@ -538,77 +538,7 @@ topics = {'assert': 'The "assert" statement\n'
|
||||||
' **PEP 492** - Coroutines with async and await syntax\n'
|
' **PEP 492** - Coroutines with async and await syntax\n'
|
||||||
' The proposal that made coroutines a proper standalone concept '
|
' The proposal that made coroutines a proper standalone concept '
|
||||||
'in\n'
|
'in\n'
|
||||||
' Python, and added supporting syntax.\n'
|
' Python, and added supporting syntax.\n',
|
||||||
'\n'
|
|
||||||
'-[ Footnotes ]-\n'
|
|
||||||
'\n'
|
|
||||||
'[1] The exception is propagated to the invocation stack unless '
|
|
||||||
'there\n'
|
|
||||||
' is a "finally" clause which happens to raise another '
|
|
||||||
'exception.\n'
|
|
||||||
' That new exception causes the old one to be lost.\n'
|
|
||||||
'\n'
|
|
||||||
'[2] In pattern matching, a sequence is defined as one of the\n'
|
|
||||||
' following:\n'
|
|
||||||
'\n'
|
|
||||||
' * a class that inherits from "collections.abc.Sequence"\n'
|
|
||||||
'\n'
|
|
||||||
' * a Python class that has been registered as\n'
|
|
||||||
' "collections.abc.Sequence"\n'
|
|
||||||
'\n'
|
|
||||||
' * a builtin class that has its (CPython) '
|
|
||||||
'"Py_TPFLAGS_SEQUENCE"\n'
|
|
||||||
' bit set\n'
|
|
||||||
'\n'
|
|
||||||
' * a class that inherits from any of the above\n'
|
|
||||||
'\n'
|
|
||||||
' The following standard library classes are sequences:\n'
|
|
||||||
'\n'
|
|
||||||
' * "array.array"\n'
|
|
||||||
'\n'
|
|
||||||
' * "collections.deque"\n'
|
|
||||||
'\n'
|
|
||||||
' * "list"\n'
|
|
||||||
'\n'
|
|
||||||
' * "memoryview"\n'
|
|
||||||
'\n'
|
|
||||||
' * "range"\n'
|
|
||||||
'\n'
|
|
||||||
' * "tuple"\n'
|
|
||||||
'\n'
|
|
||||||
' Note:\n'
|
|
||||||
'\n'
|
|
||||||
' Subject values of type "str", "bytes", and "bytearray" do '
|
|
||||||
'not\n'
|
|
||||||
' match sequence patterns.\n'
|
|
||||||
'\n'
|
|
||||||
'[3] In pattern matching, a mapping is defined as one of the '
|
|
||||||
'following:\n'
|
|
||||||
'\n'
|
|
||||||
' * a class that inherits from "collections.abc.Mapping"\n'
|
|
||||||
'\n'
|
|
||||||
' * a Python class that has been registered as\n'
|
|
||||||
' "collections.abc.Mapping"\n'
|
|
||||||
'\n'
|
|
||||||
' * a builtin class that has its (CPython) '
|
|
||||||
'"Py_TPFLAGS_MAPPING"\n'
|
|
||||||
' bit set\n'
|
|
||||||
'\n'
|
|
||||||
' * a class that inherits from any of the above\n'
|
|
||||||
'\n'
|
|
||||||
' The standard library classes "dict" and '
|
|
||||||
'"types.MappingProxyType"\n'
|
|
||||||
' are mappings.\n'
|
|
||||||
'\n'
|
|
||||||
'[4] A string literal appearing as the first statement in the '
|
|
||||||
'function\n'
|
|
||||||
' body is transformed into the function’s "__doc__" attribute '
|
|
||||||
'and\n'
|
|
||||||
' therefore the function’s *docstring*.\n'
|
|
||||||
'\n'
|
|
||||||
'[5] A string literal appearing as the first statement in the class\n'
|
|
||||||
' body is transformed into the namespace’s "__doc__" item and\n'
|
|
||||||
' therefore the class’s *docstring*.\n',
|
|
||||||
'atom-identifiers': 'Identifiers (Names)\n'
|
'atom-identifiers': 'Identifiers (Names)\n'
|
||||||
'*******************\n'
|
'*******************\n'
|
||||||
'\n'
|
'\n'
|
||||||
|
@ -1748,8 +1678,8 @@ topics = {'assert': 'The "assert" statement\n'
|
||||||
'standard\n'
|
'standard\n'
|
||||||
'type hierarchy):\n'
|
'type hierarchy):\n'
|
||||||
'\n'
|
'\n'
|
||||||
' classdef ::= [decorators] "class" classname [inheritance] ":" '
|
' classdef ::= [decorators] "class" classname [type_params] '
|
||||||
'suite\n'
|
'[inheritance] ":" suite\n'
|
||||||
' inheritance ::= "(" [argument_list] ")"\n'
|
' inheritance ::= "(" [argument_list] ")"\n'
|
||||||
' classname ::= identifier\n'
|
' classname ::= identifier\n'
|
||||||
'\n'
|
'\n'
|
||||||
|
@ -1813,6 +1743,19 @@ topics = {'assert': 'The "assert" statement\n'
|
||||||
'"assignment_expression". Previously, the grammar was much more\n'
|
'"assignment_expression". Previously, the grammar was much more\n'
|
||||||
'restrictive; see **PEP 614** for details.\n'
|
'restrictive; see **PEP 614** for details.\n'
|
||||||
'\n'
|
'\n'
|
||||||
|
'A list of type parameters may be given in square brackets '
|
||||||
|
'immediately\n'
|
||||||
|
'after the class’s name. This indicates to static type checkers '
|
||||||
|
'that\n'
|
||||||
|
'the class is generic. At runtime, the type parameters can be '
|
||||||
|
'retrieved\n'
|
||||||
|
'from the class’s "__type_params__" attribute. See Generic classes '
|
||||||
|
'for\n'
|
||||||
|
'more.\n'
|
||||||
|
'\n'
|
||||||
|
'Changed in version 3.12: Type parameter lists are new in Python '
|
||||||
|
'3.12.\n'
|
||||||
|
'\n'
|
||||||
'**Programmer’s note:** Variables defined in the class definition '
|
'**Programmer’s note:** Variables defined in the class definition '
|
||||||
'are\n'
|
'are\n'
|
||||||
'class attributes; they are shared by instances. Instance '
|
'class attributes; they are shared by instances. Instance '
|
||||||
|
@ -3554,8 +3497,8 @@ topics = {'assert': 'The "assert" statement\n'
|
||||||
'(see\n'
|
'(see\n'
|
||||||
'section The standard type hierarchy):\n'
|
'section The standard type hierarchy):\n'
|
||||||
'\n'
|
'\n'
|
||||||
' funcdef ::= [decorators] "def" funcname "(" '
|
' funcdef ::= [decorators] "def" funcname '
|
||||||
'[parameter_list] ")"\n'
|
'[type_params] "(" [parameter_list] ")"\n'
|
||||||
' ["->" expression] ":" suite\n'
|
' ["->" expression] ":" suite\n'
|
||||||
' decorators ::= decorator+\n'
|
' decorators ::= decorator+\n'
|
||||||
' decorator ::= "@" assignment_expression '
|
' decorator ::= "@" assignment_expression '
|
||||||
|
@ -3617,6 +3560,19 @@ topics = {'assert': 'The "assert" statement\n'
|
||||||
'"assignment_expression". Previously, the grammar was much more\n'
|
'"assignment_expression". Previously, the grammar was much more\n'
|
||||||
'restrictive; see **PEP 614** for details.\n'
|
'restrictive; see **PEP 614** for details.\n'
|
||||||
'\n'
|
'\n'
|
||||||
|
'A list of type parameters may be given in square brackets '
|
||||||
|
'between the\n'
|
||||||
|
'function’s name and the opening parenthesis for its parameter '
|
||||||
|
'list.\n'
|
||||||
|
'This indicates to static type checkers that the function is '
|
||||||
|
'generic.\n'
|
||||||
|
'At runtime, the type parameters can be retrieved from the '
|
||||||
|
'function’s\n'
|
||||||
|
'"__type_params__" attribute. See Generic functions for more.\n'
|
||||||
|
'\n'
|
||||||
|
'Changed in version 3.12: Type parameter lists are new in Python '
|
||||||
|
'3.12.\n'
|
||||||
|
'\n'
|
||||||
'When one or more *parameters* have the form *parameter* "="\n'
|
'When one or more *parameters* have the form *parameter* "="\n'
|
||||||
'*expression*, the function is said to have “default parameter '
|
'*expression*, the function is said to have “default parameter '
|
||||||
'values.”\n'
|
'values.”\n'
|
||||||
|
@ -3759,8 +3715,8 @@ topics = {'assert': 'The "assert" statement\n'
|
||||||
'standard\n'
|
'standard\n'
|
||||||
'type hierarchy):\n'
|
'type hierarchy):\n'
|
||||||
'\n'
|
'\n'
|
||||||
' classdef ::= [decorators] "class" classname [inheritance] '
|
' classdef ::= [decorators] "class" classname [type_params] '
|
||||||
'":" suite\n'
|
'[inheritance] ":" suite\n'
|
||||||
' inheritance ::= "(" [argument_list] ")"\n'
|
' inheritance ::= "(" [argument_list] ")"\n'
|
||||||
' classname ::= identifier\n'
|
' classname ::= identifier\n'
|
||||||
'\n'
|
'\n'
|
||||||
|
@ -3828,6 +3784,19 @@ topics = {'assert': 'The "assert" statement\n'
|
||||||
'"assignment_expression". Previously, the grammar was much more\n'
|
'"assignment_expression". Previously, the grammar was much more\n'
|
||||||
'restrictive; see **PEP 614** for details.\n'
|
'restrictive; see **PEP 614** for details.\n'
|
||||||
'\n'
|
'\n'
|
||||||
|
'A list of type parameters may be given in square brackets '
|
||||||
|
'immediately\n'
|
||||||
|
'after the class’s name. This indicates to static type checkers '
|
||||||
|
'that\n'
|
||||||
|
'the class is generic. At runtime, the type parameters can be '
|
||||||
|
'retrieved\n'
|
||||||
|
'from the class’s "__type_params__" attribute. See Generic '
|
||||||
|
'classes for\n'
|
||||||
|
'more.\n'
|
||||||
|
'\n'
|
||||||
|
'Changed in version 3.12: Type parameter lists are new in Python '
|
||||||
|
'3.12.\n'
|
||||||
|
'\n'
|
||||||
'**Programmer’s note:** Variables defined in the class definition '
|
'**Programmer’s note:** Variables defined in the class definition '
|
||||||
'are\n'
|
'are\n'
|
||||||
'class attributes; they are shared by instances. Instance '
|
'class attributes; they are shared by instances. Instance '
|
||||||
|
@ -3985,6 +3954,272 @@ topics = {'assert': 'The "assert" statement\n'
|
||||||
'concept in\n'
|
'concept in\n'
|
||||||
' Python, and added supporting syntax.\n'
|
' Python, and added supporting syntax.\n'
|
||||||
'\n'
|
'\n'
|
||||||
|
'\n'
|
||||||
|
'Type parameter lists\n'
|
||||||
|
'====================\n'
|
||||||
|
'\n'
|
||||||
|
'New in version 3.12.\n'
|
||||||
|
'\n'
|
||||||
|
' type_params ::= "[" type_param ("," type_param)* "]"\n'
|
||||||
|
' type_param ::= typevar | typevartuple | paramspec\n'
|
||||||
|
' typevar ::= identifier (":" expression)?\n'
|
||||||
|
' typevartuple ::= "*" identifier\n'
|
||||||
|
' paramspec ::= "**" identifier\n'
|
||||||
|
'\n'
|
||||||
|
'Functions (including coroutines), classes and type aliases may '
|
||||||
|
'contain\n'
|
||||||
|
'a type parameter list:\n'
|
||||||
|
'\n'
|
||||||
|
' def max[T](args: list[T]) -> T:\n'
|
||||||
|
' ...\n'
|
||||||
|
'\n'
|
||||||
|
' async def amax[T](args: list[T]) -> T:\n'
|
||||||
|
' ...\n'
|
||||||
|
'\n'
|
||||||
|
' class Bag[T]:\n'
|
||||||
|
' def __iter__(self) -> Iterator[T]:\n'
|
||||||
|
' ...\n'
|
||||||
|
'\n'
|
||||||
|
' def add(self, arg: T) -> None:\n'
|
||||||
|
' ...\n'
|
||||||
|
'\n'
|
||||||
|
' type ListOrSet[T] = list[T] | set[T]\n'
|
||||||
|
'\n'
|
||||||
|
'Semantically, this indicates that the function, class, or type '
|
||||||
|
'alias\n'
|
||||||
|
'is generic over a type variable. This information is primarily '
|
||||||
|
'used by\n'
|
||||||
|
'static type checkers, and at runtime, generic objects behave '
|
||||||
|
'much like\n'
|
||||||
|
'their non-generic counterparts.\n'
|
||||||
|
'\n'
|
||||||
|
'Type parameters are declared in square brackets ("[]") '
|
||||||
|
'immediately\n'
|
||||||
|
'after the name of the function, class, or type alias. The type\n'
|
||||||
|
'parameters are accessible within the scope of the generic '
|
||||||
|
'object, but\n'
|
||||||
|
'not elsewhere. Thus, after a declaration "def func[T](): pass", '
|
||||||
|
'the\n'
|
||||||
|
'name "T" is not available in the module scope. Below, the '
|
||||||
|
'semantics of\n'
|
||||||
|
'generic objects are described with more precision. The scope of '
|
||||||
|
'type\n'
|
||||||
|
'parameters is modeled with a special function (technically, an\n'
|
||||||
|
'annotation scope) that wraps the creation of the generic '
|
||||||
|
'object.\n'
|
||||||
|
'\n'
|
||||||
|
'Generic functions, classes, and type aliases have a '
|
||||||
|
'"__type_params__"\n'
|
||||||
|
'attribute listing their type parameters.\n'
|
||||||
|
'\n'
|
||||||
|
'Type parameters come in three kinds:\n'
|
||||||
|
'\n'
|
||||||
|
'* "typing.TypeVar", introduced by a plain name (e.g., "T").\n'
|
||||||
|
' Semantically, this represents a single type to a type '
|
||||||
|
'checker.\n'
|
||||||
|
'\n'
|
||||||
|
'* "typing.TypeVarTuple", introduced by a name prefixed with a '
|
||||||
|
'single\n'
|
||||||
|
' asterisk (e.g., "*Ts"). Semantically, this stands for a tuple '
|
||||||
|
'of any\n'
|
||||||
|
' number of types.\n'
|
||||||
|
'\n'
|
||||||
|
'* "typing.ParamSpec", introduced by a name prefixed with two '
|
||||||
|
'asterisks\n'
|
||||||
|
' (e.g., "**P"). Semantically, this stands for the parameters of '
|
||||||
|
'a\n'
|
||||||
|
' callable.\n'
|
||||||
|
'\n'
|
||||||
|
'"typing.TypeVar" declarations can define *bounds* and '
|
||||||
|
'*constraints*\n'
|
||||||
|
'with a colon (":") followed by an expression. A single '
|
||||||
|
'expression\n'
|
||||||
|
'after the colon indicates a bound (e.g. "T: int"). Semantically, '
|
||||||
|
'this\n'
|
||||||
|
'means that the "typing.TypeVar" can only represent types that '
|
||||||
|
'are a\n'
|
||||||
|
'subtype of this bound. A parenthesized tuple of expressions '
|
||||||
|
'after the\n'
|
||||||
|
'colon indicates a set of constraints (e.g. "T: (str, bytes)"). '
|
||||||
|
'Each\n'
|
||||||
|
'member of the tuple should be a type (again, this is not '
|
||||||
|
'enforced at\n'
|
||||||
|
'runtime). Constrained type variables can only take on one of the '
|
||||||
|
'types\n'
|
||||||
|
'in the list of constraints.\n'
|
||||||
|
'\n'
|
||||||
|
'For "typing.TypeVar"s declared using the type parameter list '
|
||||||
|
'syntax,\n'
|
||||||
|
'the bound and constraints are not evaluated when the generic '
|
||||||
|
'object is\n'
|
||||||
|
'created, but only when the value is explicitly accessed through '
|
||||||
|
'the\n'
|
||||||
|
'attributes "__bound__" and "__constraints__". To accomplish '
|
||||||
|
'this, the\n'
|
||||||
|
'bounds or constraints are evaluated in a separate annotation '
|
||||||
|
'scope.\n'
|
||||||
|
'\n'
|
||||||
|
'"typing.TypeVarTuple"s and "typing.ParamSpec"s cannot have '
|
||||||
|
'bounds or\n'
|
||||||
|
'constraints.\n'
|
||||||
|
'\n'
|
||||||
|
'The following example indicates the full set of allowed type '
|
||||||
|
'parameter\n'
|
||||||
|
'declarations:\n'
|
||||||
|
'\n'
|
||||||
|
' def overly_generic[\n'
|
||||||
|
' SimpleTypeVar,\n'
|
||||||
|
' TypeVarWithBound: int,\n'
|
||||||
|
' TypeVarWithConstraints: (str, bytes),\n'
|
||||||
|
' *SimpleTypeVarTuple,\n'
|
||||||
|
' **SimpleParamSpec,\n'
|
||||||
|
' ](\n'
|
||||||
|
' a: SimpleTypeVar,\n'
|
||||||
|
' b: TypeVarWithBound,\n'
|
||||||
|
' c: Callable[SimpleParamSpec, TypeVarWithConstraints],\n'
|
||||||
|
' *d: SimpleTypeVarTuple,\n'
|
||||||
|
' ): ...\n'
|
||||||
|
'\n'
|
||||||
|
'\n'
|
||||||
|
'Generic functions\n'
|
||||||
|
'-----------------\n'
|
||||||
|
'\n'
|
||||||
|
'Generic functions are declared as follows:\n'
|
||||||
|
'\n'
|
||||||
|
' def func[T](arg: T): ...\n'
|
||||||
|
'\n'
|
||||||
|
'This syntax is equivalent to:\n'
|
||||||
|
'\n'
|
||||||
|
' annotation-def TYPE_PARAMS_OF_func():\n'
|
||||||
|
' T = typing.TypeVar("T")\n'
|
||||||
|
' def func(arg: T): ...\n'
|
||||||
|
' func.__type_params__ = (T,)\n'
|
||||||
|
' return func\n'
|
||||||
|
' func = TYPE_PARAMS_OF_func()\n'
|
||||||
|
'\n'
|
||||||
|
'Here "annotation-def" indicates an annotation scope, which is '
|
||||||
|
'not\n'
|
||||||
|
'actually bound to any name at runtime. (One other liberty is '
|
||||||
|
'taken in\n'
|
||||||
|
'the translation: the syntax does not go through attribute access '
|
||||||
|
'on\n'
|
||||||
|
'the "typing" module, but creates an instance of '
|
||||||
|
'"typing.TypeVar"\n'
|
||||||
|
'directly.)\n'
|
||||||
|
'\n'
|
||||||
|
'The annotations of generic functions are evaluated within the\n'
|
||||||
|
'annotation scope used for declaring the type parameters, but '
|
||||||
|
'the\n'
|
||||||
|
'function’s defaults and decorators are not.\n'
|
||||||
|
'\n'
|
||||||
|
'The following example illustrates the scoping rules for these '
|
||||||
|
'cases,\n'
|
||||||
|
'as well as for additional flavors of type parameters:\n'
|
||||||
|
'\n'
|
||||||
|
' @decorator\n'
|
||||||
|
' def func[T: int, *Ts, **P](*args: *Ts, arg: Callable[P, T] = '
|
||||||
|
'some_default):\n'
|
||||||
|
' ...\n'
|
||||||
|
'\n'
|
||||||
|
'Except for the lazy evaluation of the "TypeVar" bound, this is\n'
|
||||||
|
'equivalent to:\n'
|
||||||
|
'\n'
|
||||||
|
' DEFAULT_OF_arg = some_default\n'
|
||||||
|
'\n'
|
||||||
|
' annotation-def TYPE_PARAMS_OF_func():\n'
|
||||||
|
'\n'
|
||||||
|
' annotation-def BOUND_OF_T():\n'
|
||||||
|
' return int\n'
|
||||||
|
' # In reality, BOUND_OF_T() is evaluated only on demand.\n'
|
||||||
|
' T = typing.TypeVar("T", bound=BOUND_OF_T())\n'
|
||||||
|
'\n'
|
||||||
|
' Ts = typing.TypeVarTuple("Ts")\n'
|
||||||
|
' P = typing.ParamSpec("P")\n'
|
||||||
|
'\n'
|
||||||
|
' def func(*args: *Ts, arg: Callable[P, T] = '
|
||||||
|
'DEFAULT_OF_arg):\n'
|
||||||
|
' ...\n'
|
||||||
|
'\n'
|
||||||
|
' func.__type_params__ = (T, Ts, P)\n'
|
||||||
|
' return func\n'
|
||||||
|
' func = decorator(TYPE_PARAMS_OF_func())\n'
|
||||||
|
'\n'
|
||||||
|
'The capitalized names like "DEFAULT_OF_arg" are not actually '
|
||||||
|
'bound at\n'
|
||||||
|
'runtime.\n'
|
||||||
|
'\n'
|
||||||
|
'\n'
|
||||||
|
'Generic classes\n'
|
||||||
|
'---------------\n'
|
||||||
|
'\n'
|
||||||
|
'Generic classes are declared as follows:\n'
|
||||||
|
'\n'
|
||||||
|
' class Bag[T]: ...\n'
|
||||||
|
'\n'
|
||||||
|
'This syntax is equivalent to:\n'
|
||||||
|
'\n'
|
||||||
|
' annotation-def TYPE_PARAMS_OF_Bag():\n'
|
||||||
|
' T = typing.TypeVar("T")\n'
|
||||||
|
' class Bag(typing.Generic[T]):\n'
|
||||||
|
' __type_params__ = (T,)\n'
|
||||||
|
' ...\n'
|
||||||
|
' return Bag\n'
|
||||||
|
' Bag = TYPE_PARAMS_OF_Bag()\n'
|
||||||
|
'\n'
|
||||||
|
'Here again "annotation-def" (not a real keyword) indicates an\n'
|
||||||
|
'annotation scope, and the name "TYPE_PARAMS_OF_Bag" is not '
|
||||||
|
'actually\n'
|
||||||
|
'bound at runtime.\n'
|
||||||
|
'\n'
|
||||||
|
'Generic classes implicitly inherit from "typing.Generic". The '
|
||||||
|
'base\n'
|
||||||
|
'classes and keyword arguments of generic classes are evaluated '
|
||||||
|
'within\n'
|
||||||
|
'the type scope for the type parameters, and decorators are '
|
||||||
|
'evaluated\n'
|
||||||
|
'outside that scope. This is illustrated by this example:\n'
|
||||||
|
'\n'
|
||||||
|
' @decorator\n'
|
||||||
|
' class Bag(Base[T], arg=T): ...\n'
|
||||||
|
'\n'
|
||||||
|
'This is equivalent to:\n'
|
||||||
|
'\n'
|
||||||
|
' annotation-def TYPE_PARAMS_OF_Bag():\n'
|
||||||
|
' T = typing.TypeVar("T")\n'
|
||||||
|
' class Bag(Base[T], typing.Generic[T], arg=T):\n'
|
||||||
|
' __type_params__ = (T,)\n'
|
||||||
|
' ...\n'
|
||||||
|
' return Bag\n'
|
||||||
|
' Bag = decorator(TYPE_PARAMS_OF_Bag())\n'
|
||||||
|
'\n'
|
||||||
|
'\n'
|
||||||
|
'Generic type aliases\n'
|
||||||
|
'--------------------\n'
|
||||||
|
'\n'
|
||||||
|
'The "type" statement can also be used to create a generic type '
|
||||||
|
'alias:\n'
|
||||||
|
'\n'
|
||||||
|
' type ListOrSet[T] = list[T] | set[T]\n'
|
||||||
|
'\n'
|
||||||
|
'Except for the lazy evaluation of the value, this is equivalent '
|
||||||
|
'to:\n'
|
||||||
|
'\n'
|
||||||
|
' annotation-def TYPE_PARAMS_OF_ListOrSet():\n'
|
||||||
|
' T = typing.TypeVar("T")\n'
|
||||||
|
'\n'
|
||||||
|
' annotation-def VALUE_OF_ListOrSet():\n'
|
||||||
|
' return list[T] | set[T]\n'
|
||||||
|
' # In reality, the value is lazily evaluated\n'
|
||||||
|
' return typing.TypeAliasType("ListOrSet", '
|
||||||
|
'VALUE_OF_ListOrSet(), type_params=(T,))\n'
|
||||||
|
' ListOrSet = TYPE_PARAMS_OF_ListOrSet()\n'
|
||||||
|
'\n'
|
||||||
|
'Here, "annotation-def" (not a real keyword) indicates an '
|
||||||
|
'annotation\n'
|
||||||
|
'scope. The capitalized names like "TYPE_PARAMS_OF_ListOrSet" are '
|
||||||
|
'not\n'
|
||||||
|
'actually bound at runtime.\n'
|
||||||
|
'\n'
|
||||||
'-[ Footnotes ]-\n'
|
'-[ Footnotes ]-\n'
|
||||||
'\n'
|
'\n'
|
||||||
'[1] The exception is propagated to the invocation stack unless '
|
'[1] The exception is propagated to the invocation stack unless '
|
||||||
|
@ -5692,6 +5927,10 @@ topics = {'assert': 'The "assert" statement\n'
|
||||||
'\n'
|
'\n'
|
||||||
'* "import" statements.\n'
|
'* "import" statements.\n'
|
||||||
'\n'
|
'\n'
|
||||||
|
'* "type" statements.\n'
|
||||||
|
'\n'
|
||||||
|
'* type parameter lists.\n'
|
||||||
|
'\n'
|
||||||
'The "import" statement of the form "from ... import *" binds '
|
'The "import" statement of the form "from ... import *" binds '
|
||||||
'all names\n'
|
'all names\n'
|
||||||
'defined in the imported module, except those beginning with an\n'
|
'defined in the imported module, except those beginning with an\n'
|
||||||
|
@ -5798,7 +6037,9 @@ topics = {'assert': 'The "assert" statement\n'
|
||||||
'scope.\n'
|
'scope.\n'
|
||||||
'"SyntaxError" is raised at compile time if the given name does '
|
'"SyntaxError" is raised at compile time if the given name does '
|
||||||
'not\n'
|
'not\n'
|
||||||
'exist in any enclosing function scope.\n'
|
'exist in any enclosing function scope. Type parameters cannot '
|
||||||
|
'be\n'
|
||||||
|
'rebound with the "nonlocal" statement.\n'
|
||||||
'\n'
|
'\n'
|
||||||
'The namespace for a module is automatically created the first '
|
'The namespace for a module is automatically created the first '
|
||||||
'time a\n'
|
'time a\n'
|
||||||
|
@ -5821,17 +6062,162 @@ topics = {'assert': 'The "assert" statement\n'
|
||||||
'the class. The scope of names defined in a class block is '
|
'the class. The scope of names defined in a class block is '
|
||||||
'limited to\n'
|
'limited to\n'
|
||||||
'the class block; it does not extend to the code blocks of '
|
'the class block; it does not extend to the code blocks of '
|
||||||
'methods –\n'
|
'methods.\n'
|
||||||
'this includes comprehensions and generator expressions since '
|
'This includes comprehensions and generator expressions, but it '
|
||||||
'they are\n'
|
'does\n'
|
||||||
'implemented using a function scope. This means that the '
|
'not include annotation scopes, which have access to their '
|
||||||
'following\n'
|
'enclosing\n'
|
||||||
'will fail:\n'
|
'class scopes. This means that the following will fail:\n'
|
||||||
'\n'
|
'\n'
|
||||||
' class A:\n'
|
' class A:\n'
|
||||||
' a = 42\n'
|
' a = 42\n'
|
||||||
' b = list(a + i for i in range(10))\n'
|
' b = list(a + i for i in range(10))\n'
|
||||||
'\n'
|
'\n'
|
||||||
|
'However, the following will succeed:\n'
|
||||||
|
'\n'
|
||||||
|
' class A:\n'
|
||||||
|
' type Alias = Nested\n'
|
||||||
|
' class Nested: pass\n'
|
||||||
|
'\n'
|
||||||
|
" print(A.Alias.__value__) # <type 'A.Nested'>\n"
|
||||||
|
'\n'
|
||||||
|
'\n'
|
||||||
|
'Annotation scopes\n'
|
||||||
|
'-----------------\n'
|
||||||
|
'\n'
|
||||||
|
'Type parameter lists and "type" statements introduce '
|
||||||
|
'*annotation\n'
|
||||||
|
'scopes*, which behave mostly like function scopes, but with '
|
||||||
|
'some\n'
|
||||||
|
'exceptions discussed below. *Annotations* currently do not use\n'
|
||||||
|
'annotation scopes, but they are expected to use annotation '
|
||||||
|
'scopes in\n'
|
||||||
|
'Python 3.13 when **PEP 649** is implemented.\n'
|
||||||
|
'\n'
|
||||||
|
'Annotation scopes are used in the following contexts:\n'
|
||||||
|
'\n'
|
||||||
|
'* Type parameter lists for generic type aliases.\n'
|
||||||
|
'\n'
|
||||||
|
'* Type parameter lists for generic functions. A generic '
|
||||||
|
'function’s\n'
|
||||||
|
' annotations are executed within the annotation scope, but '
|
||||||
|
'its\n'
|
||||||
|
' defaults and decorators are not.\n'
|
||||||
|
'\n'
|
||||||
|
'* Type parameter lists for generic classes. A generic class’s '
|
||||||
|
'base\n'
|
||||||
|
' classes and keyword arguments are executed within the '
|
||||||
|
'annotation\n'
|
||||||
|
' scope, but its decorators are not.\n'
|
||||||
|
'\n'
|
||||||
|
'* The bounds and constraints for type variables (lazily '
|
||||||
|
'evaluated).\n'
|
||||||
|
'\n'
|
||||||
|
'* The value of type aliases (lazily evaluated).\n'
|
||||||
|
'\n'
|
||||||
|
'Annotation scopes differ from function scopes in the following '
|
||||||
|
'ways:\n'
|
||||||
|
'\n'
|
||||||
|
'* Annotation scopes have access to their enclosing class '
|
||||||
|
'namespace. If\n'
|
||||||
|
' an annotation scope is immediately within a class scope, or '
|
||||||
|
'within\n'
|
||||||
|
' another annotation scope that is immediately within a class '
|
||||||
|
'scope,\n'
|
||||||
|
' the code in the annotation scope can use names defined in the '
|
||||||
|
'class\n'
|
||||||
|
' scope as if it were executed directly within the class body. '
|
||||||
|
'This\n'
|
||||||
|
' contrasts with regular functions defined within classes, '
|
||||||
|
'which\n'
|
||||||
|
' cannot access names defined in the class scope.\n'
|
||||||
|
'\n'
|
||||||
|
'* Expressions in annotation scopes cannot contain "yield", '
|
||||||
|
'"yield\n'
|
||||||
|
' from", "await", or ":=" expressions. (These expressions are '
|
||||||
|
'allowed\n'
|
||||||
|
' in other scopes contained within the annotation scope.)\n'
|
||||||
|
'\n'
|
||||||
|
'* Names defined in annotation scopes cannot be rebound with '
|
||||||
|
'"nonlocal"\n'
|
||||||
|
' statements in inner scopes. This includes only type '
|
||||||
|
'parameters, as\n'
|
||||||
|
' no other syntactic elements that can appear within annotation '
|
||||||
|
'scopes\n'
|
||||||
|
' can introduce new names.\n'
|
||||||
|
'\n'
|
||||||
|
'* While annotation scopes have an internal name, that name is '
|
||||||
|
'not\n'
|
||||||
|
' reflected in the *__qualname__* of objects defined within the '
|
||||||
|
'scope.\n'
|
||||||
|
' Instead, the "__qualname__" of such objects is as if the '
|
||||||
|
'object were\n'
|
||||||
|
' defined in the enclosing scope.\n'
|
||||||
|
'\n'
|
||||||
|
'New in version 3.12: Annotation scopes were introduced in '
|
||||||
|
'Python 3.12\n'
|
||||||
|
'as part of **PEP 695**.\n'
|
||||||
|
'\n'
|
||||||
|
'\n'
|
||||||
|
'Lazy evaluation\n'
|
||||||
|
'---------------\n'
|
||||||
|
'\n'
|
||||||
|
'The values of type aliases created through the "type" statement '
|
||||||
|
'are\n'
|
||||||
|
'*lazily evaluated*. The same applies to the bounds and '
|
||||||
|
'constraints of\n'
|
||||||
|
'type variables created through the type parameter syntax. This '
|
||||||
|
'means\n'
|
||||||
|
'that they are not evaluated when the type alias or type '
|
||||||
|
'variable is\n'
|
||||||
|
'created. Instead, they are only evaluated when doing so is '
|
||||||
|
'necessary\n'
|
||||||
|
'to resolve an attribute access.\n'
|
||||||
|
'\n'
|
||||||
|
'Example:\n'
|
||||||
|
'\n'
|
||||||
|
' >>> type Alias = 1/0\n'
|
||||||
|
' >>> Alias.__value__\n'
|
||||||
|
' Traceback (most recent call last):\n'
|
||||||
|
' ...\n'
|
||||||
|
' ZeroDivisionError: division by zero\n'
|
||||||
|
' >>> def func[T: 1/0](): pass\n'
|
||||||
|
' >>> T = func.__type_params__[0]\n'
|
||||||
|
' >>> T.__bound__\n'
|
||||||
|
' Traceback (most recent call last):\n'
|
||||||
|
' ...\n'
|
||||||
|
' ZeroDivisionError: division by zero\n'
|
||||||
|
'\n'
|
||||||
|
'Here the exception is raised only when the "__value__" '
|
||||||
|
'attribute of\n'
|
||||||
|
'the type alias or the "__bound__" attribute of the type '
|
||||||
|
'variable is\n'
|
||||||
|
'accessed.\n'
|
||||||
|
'\n'
|
||||||
|
'This behavior is primarily useful for references to types that '
|
||||||
|
'have\n'
|
||||||
|
'not yet been defined when the type alias or type variable is '
|
||||||
|
'created.\n'
|
||||||
|
'For example, lazy evaluation enables creation of mutually '
|
||||||
|
'recursive\n'
|
||||||
|
'type aliases:\n'
|
||||||
|
'\n'
|
||||||
|
' from typing import Literal\n'
|
||||||
|
'\n'
|
||||||
|
' type SimpleExpr = int | Parenthesized\n'
|
||||||
|
' type Parenthesized = tuple[Literal["("], Expr, '
|
||||||
|
'Literal[")"]]\n'
|
||||||
|
' type Expr = SimpleExpr | tuple[SimpleExpr, Literal["+", '
|
||||||
|
'"-"], Expr]\n'
|
||||||
|
'\n'
|
||||||
|
'Lazily evaluated values are evaluated in annotation scope, '
|
||||||
|
'which means\n'
|
||||||
|
'that names that appear inside the lazily evaluated value are '
|
||||||
|
'looked up\n'
|
||||||
|
'as if they were used in the immediately enclosing scope.\n'
|
||||||
|
'\n'
|
||||||
|
'New in version 3.12.\n'
|
||||||
|
'\n'
|
||||||
'\n'
|
'\n'
|
||||||
'Builtins and restricted execution\n'
|
'Builtins and restricted execution\n'
|
||||||
'---------------------------------\n'
|
'---------------------------------\n'
|
||||||
|
@ -6872,8 +7258,8 @@ topics = {'assert': 'The "assert" statement\n'
|
||||||
'(see\n'
|
'(see\n'
|
||||||
'section The standard type hierarchy):\n'
|
'section The standard type hierarchy):\n'
|
||||||
'\n'
|
'\n'
|
||||||
' funcdef ::= [decorators] "def" funcname "(" '
|
' funcdef ::= [decorators] "def" funcname '
|
||||||
'[parameter_list] ")"\n'
|
'[type_params] "(" [parameter_list] ")"\n'
|
||||||
' ["->" expression] ":" suite\n'
|
' ["->" expression] ":" suite\n'
|
||||||
' decorators ::= decorator+\n'
|
' decorators ::= decorator+\n'
|
||||||
' decorator ::= "@" assignment_expression '
|
' decorator ::= "@" assignment_expression '
|
||||||
|
@ -6935,6 +7321,19 @@ topics = {'assert': 'The "assert" statement\n'
|
||||||
'"assignment_expression". Previously, the grammar was much more\n'
|
'"assignment_expression". Previously, the grammar was much more\n'
|
||||||
'restrictive; see **PEP 614** for details.\n'
|
'restrictive; see **PEP 614** for details.\n'
|
||||||
'\n'
|
'\n'
|
||||||
|
'A list of type parameters may be given in square brackets '
|
||||||
|
'between the\n'
|
||||||
|
'function’s name and the opening parenthesis for its parameter '
|
||||||
|
'list.\n'
|
||||||
|
'This indicates to static type checkers that the function is '
|
||||||
|
'generic.\n'
|
||||||
|
'At runtime, the type parameters can be retrieved from the '
|
||||||
|
'function’s\n'
|
||||||
|
'"__type_params__" attribute. See Generic functions for more.\n'
|
||||||
|
'\n'
|
||||||
|
'Changed in version 3.12: Type parameter lists are new in Python '
|
||||||
|
'3.12.\n'
|
||||||
|
'\n'
|
||||||
'When one or more *parameters* have the form *parameter* "="\n'
|
'When one or more *parameters* have the form *parameter* "="\n'
|
||||||
'*expression*, the function is said to have “default parameter '
|
'*expression*, the function is said to have “default parameter '
|
||||||
'values.”\n'
|
'values.”\n'
|
||||||
|
@ -7277,19 +7676,24 @@ topics = {'assert': 'The "assert" statement\n'
|
||||||
'\n'
|
'\n'
|
||||||
'Some identifiers are only reserved under specific contexts. '
|
'Some identifiers are only reserved under specific contexts. '
|
||||||
'These are\n'
|
'These are\n'
|
||||||
'known as *soft keywords*. The identifiers "match", "case" '
|
'known as *soft keywords*. The identifiers "match", "case", '
|
||||||
'and "_" can\n'
|
'"type" and\n'
|
||||||
'syntactically act as keywords in contexts related to the '
|
'"_" can syntactically act as keywords in certain contexts, '
|
||||||
'pattern\n'
|
'but this\n'
|
||||||
'matching statement, but this distinction is done at the '
|
'distinction is done at the parser level, not when '
|
||||||
'parser level,\n'
|
'tokenizing.\n'
|
||||||
'not when tokenizing.\n'
|
|
||||||
'\n'
|
'\n'
|
||||||
'As soft keywords, their use with pattern matching is possible '
|
'As soft keywords, their use in the grammar is possible while '
|
||||||
'while\n'
|
'still\n'
|
||||||
'still preserving compatibility with existing code that uses '
|
'preserving compatibility with existing code that uses these '
|
||||||
'"match",\n'
|
'names as\n'
|
||||||
'"case" and "_" as identifier names.\n'
|
'identifier names.\n'
|
||||||
|
'\n'
|
||||||
|
'"match", "case", and "_" are used in the "match" statement. '
|
||||||
|
'"type" is\n'
|
||||||
|
'used in the "type" statement.\n'
|
||||||
|
'\n'
|
||||||
|
'Changed in version 3.12: "type" is now a soft keyword.\n'
|
||||||
'\n'
|
'\n'
|
||||||
'\n'
|
'\n'
|
||||||
'Reserved classes of identifiers\n'
|
'Reserved classes of identifiers\n'
|
||||||
|
@ -7809,6 +8213,10 @@ topics = {'assert': 'The "assert" statement\n'
|
||||||
'\n'
|
'\n'
|
||||||
'* "import" statements.\n'
|
'* "import" statements.\n'
|
||||||
'\n'
|
'\n'
|
||||||
|
'* "type" statements.\n'
|
||||||
|
'\n'
|
||||||
|
'* type parameter lists.\n'
|
||||||
|
'\n'
|
||||||
'The "import" statement of the form "from ... import *" binds all '
|
'The "import" statement of the form "from ... import *" binds all '
|
||||||
'names\n'
|
'names\n'
|
||||||
'defined in the imported module, except those beginning with an\n'
|
'defined in the imported module, except those beginning with an\n'
|
||||||
|
@ -7908,7 +8316,8 @@ topics = {'assert': 'The "assert" statement\n'
|
||||||
'scope.\n'
|
'scope.\n'
|
||||||
'"SyntaxError" is raised at compile time if the given name does '
|
'"SyntaxError" is raised at compile time if the given name does '
|
||||||
'not\n'
|
'not\n'
|
||||||
'exist in any enclosing function scope.\n'
|
'exist in any enclosing function scope. Type parameters cannot be\n'
|
||||||
|
'rebound with the "nonlocal" statement.\n'
|
||||||
'\n'
|
'\n'
|
||||||
'The namespace for a module is automatically created the first time '
|
'The namespace for a module is automatically created the first time '
|
||||||
'a\n'
|
'a\n'
|
||||||
|
@ -7930,18 +8339,156 @@ topics = {'assert': 'The "assert" statement\n'
|
||||||
'of\n'
|
'of\n'
|
||||||
'the class. The scope of names defined in a class block is limited '
|
'the class. The scope of names defined in a class block is limited '
|
||||||
'to\n'
|
'to\n'
|
||||||
'the class block; it does not extend to the code blocks of methods '
|
'the class block; it does not extend to the code blocks of '
|
||||||
'–\n'
|
'methods.\n'
|
||||||
'this includes comprehensions and generator expressions since they '
|
'This includes comprehensions and generator expressions, but it '
|
||||||
'are\n'
|
'does\n'
|
||||||
'implemented using a function scope. This means that the '
|
'not include annotation scopes, which have access to their '
|
||||||
'following\n'
|
'enclosing\n'
|
||||||
'will fail:\n'
|
'class scopes. This means that the following will fail:\n'
|
||||||
'\n'
|
'\n'
|
||||||
' class A:\n'
|
' class A:\n'
|
||||||
' a = 42\n'
|
' a = 42\n'
|
||||||
' b = list(a + i for i in range(10))\n'
|
' b = list(a + i for i in range(10))\n'
|
||||||
'\n'
|
'\n'
|
||||||
|
'However, the following will succeed:\n'
|
||||||
|
'\n'
|
||||||
|
' class A:\n'
|
||||||
|
' type Alias = Nested\n'
|
||||||
|
' class Nested: pass\n'
|
||||||
|
'\n'
|
||||||
|
" print(A.Alias.__value__) # <type 'A.Nested'>\n"
|
||||||
|
'\n'
|
||||||
|
'\n'
|
||||||
|
'Annotation scopes\n'
|
||||||
|
'=================\n'
|
||||||
|
'\n'
|
||||||
|
'Type parameter lists and "type" statements introduce *annotation\n'
|
||||||
|
'scopes*, which behave mostly like function scopes, but with some\n'
|
||||||
|
'exceptions discussed below. *Annotations* currently do not use\n'
|
||||||
|
'annotation scopes, but they are expected to use annotation scopes '
|
||||||
|
'in\n'
|
||||||
|
'Python 3.13 when **PEP 649** is implemented.\n'
|
||||||
|
'\n'
|
||||||
|
'Annotation scopes are used in the following contexts:\n'
|
||||||
|
'\n'
|
||||||
|
'* Type parameter lists for generic type aliases.\n'
|
||||||
|
'\n'
|
||||||
|
'* Type parameter lists for generic functions. A generic '
|
||||||
|
'function’s\n'
|
||||||
|
' annotations are executed within the annotation scope, but its\n'
|
||||||
|
' defaults and decorators are not.\n'
|
||||||
|
'\n'
|
||||||
|
'* Type parameter lists for generic classes. A generic class’s '
|
||||||
|
'base\n'
|
||||||
|
' classes and keyword arguments are executed within the '
|
||||||
|
'annotation\n'
|
||||||
|
' scope, but its decorators are not.\n'
|
||||||
|
'\n'
|
||||||
|
'* The bounds and constraints for type variables (lazily '
|
||||||
|
'evaluated).\n'
|
||||||
|
'\n'
|
||||||
|
'* The value of type aliases (lazily evaluated).\n'
|
||||||
|
'\n'
|
||||||
|
'Annotation scopes differ from function scopes in the following '
|
||||||
|
'ways:\n'
|
||||||
|
'\n'
|
||||||
|
'* Annotation scopes have access to their enclosing class '
|
||||||
|
'namespace. If\n'
|
||||||
|
' an annotation scope is immediately within a class scope, or '
|
||||||
|
'within\n'
|
||||||
|
' another annotation scope that is immediately within a class '
|
||||||
|
'scope,\n'
|
||||||
|
' the code in the annotation scope can use names defined in the '
|
||||||
|
'class\n'
|
||||||
|
' scope as if it were executed directly within the class body. '
|
||||||
|
'This\n'
|
||||||
|
' contrasts with regular functions defined within classes, which\n'
|
||||||
|
' cannot access names defined in the class scope.\n'
|
||||||
|
'\n'
|
||||||
|
'* Expressions in annotation scopes cannot contain "yield", "yield\n'
|
||||||
|
' from", "await", or ":=" expressions. (These expressions are '
|
||||||
|
'allowed\n'
|
||||||
|
' in other scopes contained within the annotation scope.)\n'
|
||||||
|
'\n'
|
||||||
|
'* Names defined in annotation scopes cannot be rebound with '
|
||||||
|
'"nonlocal"\n'
|
||||||
|
' statements in inner scopes. This includes only type parameters, '
|
||||||
|
'as\n'
|
||||||
|
' no other syntactic elements that can appear within annotation '
|
||||||
|
'scopes\n'
|
||||||
|
' can introduce new names.\n'
|
||||||
|
'\n'
|
||||||
|
'* While annotation scopes have an internal name, that name is not\n'
|
||||||
|
' reflected in the *__qualname__* of objects defined within the '
|
||||||
|
'scope.\n'
|
||||||
|
' Instead, the "__qualname__" of such objects is as if the object '
|
||||||
|
'were\n'
|
||||||
|
' defined in the enclosing scope.\n'
|
||||||
|
'\n'
|
||||||
|
'New in version 3.12: Annotation scopes were introduced in Python '
|
||||||
|
'3.12\n'
|
||||||
|
'as part of **PEP 695**.\n'
|
||||||
|
'\n'
|
||||||
|
'\n'
|
||||||
|
'Lazy evaluation\n'
|
||||||
|
'===============\n'
|
||||||
|
'\n'
|
||||||
|
'The values of type aliases created through the "type" statement '
|
||||||
|
'are\n'
|
||||||
|
'*lazily evaluated*. The same applies to the bounds and constraints '
|
||||||
|
'of\n'
|
||||||
|
'type variables created through the type parameter syntax. This '
|
||||||
|
'means\n'
|
||||||
|
'that they are not evaluated when the type alias or type variable '
|
||||||
|
'is\n'
|
||||||
|
'created. Instead, they are only evaluated when doing so is '
|
||||||
|
'necessary\n'
|
||||||
|
'to resolve an attribute access.\n'
|
||||||
|
'\n'
|
||||||
|
'Example:\n'
|
||||||
|
'\n'
|
||||||
|
' >>> type Alias = 1/0\n'
|
||||||
|
' >>> Alias.__value__\n'
|
||||||
|
' Traceback (most recent call last):\n'
|
||||||
|
' ...\n'
|
||||||
|
' ZeroDivisionError: division by zero\n'
|
||||||
|
' >>> def func[T: 1/0](): pass\n'
|
||||||
|
' >>> T = func.__type_params__[0]\n'
|
||||||
|
' >>> T.__bound__\n'
|
||||||
|
' Traceback (most recent call last):\n'
|
||||||
|
' ...\n'
|
||||||
|
' ZeroDivisionError: division by zero\n'
|
||||||
|
'\n'
|
||||||
|
'Here the exception is raised only when the "__value__" attribute '
|
||||||
|
'of\n'
|
||||||
|
'the type alias or the "__bound__" attribute of the type variable '
|
||||||
|
'is\n'
|
||||||
|
'accessed.\n'
|
||||||
|
'\n'
|
||||||
|
'This behavior is primarily useful for references to types that '
|
||||||
|
'have\n'
|
||||||
|
'not yet been defined when the type alias or type variable is '
|
||||||
|
'created.\n'
|
||||||
|
'For example, lazy evaluation enables creation of mutually '
|
||||||
|
'recursive\n'
|
||||||
|
'type aliases:\n'
|
||||||
|
'\n'
|
||||||
|
' from typing import Literal\n'
|
||||||
|
'\n'
|
||||||
|
' type SimpleExpr = int | Parenthesized\n'
|
||||||
|
' type Parenthesized = tuple[Literal["("], Expr, Literal[")"]]\n'
|
||||||
|
' type Expr = SimpleExpr | tuple[SimpleExpr, Literal["+", "-"], '
|
||||||
|
'Expr]\n'
|
||||||
|
'\n'
|
||||||
|
'Lazily evaluated values are evaluated in annotation scope, which '
|
||||||
|
'means\n'
|
||||||
|
'that names that appear inside the lazily evaluated value are '
|
||||||
|
'looked up\n'
|
||||||
|
'as if they were used in the immediately enclosing scope.\n'
|
||||||
|
'\n'
|
||||||
|
'New in version 3.12.\n'
|
||||||
|
'\n'
|
||||||
'\n'
|
'\n'
|
||||||
'Builtins and restricted execution\n'
|
'Builtins and restricted execution\n'
|
||||||
'=================================\n'
|
'=================================\n'
|
||||||
|
@ -9105,6 +9652,14 @@ topics = {'assert': 'The "assert" statement\n'
|
||||||
'\n'
|
'\n'
|
||||||
' New in version 3.3.\n'
|
' New in version 3.3.\n'
|
||||||
'\n'
|
'\n'
|
||||||
|
'definition.__type_params__\n'
|
||||||
|
'\n'
|
||||||
|
' The type parameters of generic classes, functions, and '
|
||||||
|
'type\n'
|
||||||
|
' aliases.\n'
|
||||||
|
'\n'
|
||||||
|
' New in version 3.12.\n'
|
||||||
|
'\n'
|
||||||
'class.__mro__\n'
|
'class.__mro__\n'
|
||||||
'\n'
|
'\n'
|
||||||
' This attribute is a tuple of classes that are considered '
|
' This attribute is a tuple of classes that are considered '
|
||||||
|
@ -13430,6 +13985,14 @@ topics = {'assert': 'The "assert" statement\n'
|
||||||
'| |\n'
|
'| |\n'
|
||||||
' '
|
' '
|
||||||
'+---------------------------+---------------------------------+-------------+\n'
|
'+---------------------------+---------------------------------+-------------+\n'
|
||||||
|
' | "__type_params__" | A tuple containing the type '
|
||||||
|
'| Writable |\n'
|
||||||
|
' | | parameters of a generic '
|
||||||
|
'| |\n'
|
||||||
|
' | | function. '
|
||||||
|
'| |\n'
|
||||||
|
' '
|
||||||
|
'+---------------------------+---------------------------------+-------------+\n'
|
||||||
'\n'
|
'\n'
|
||||||
' Most of the attributes labelled “Writable” check the type of '
|
' Most of the attributes labelled “Writable” check the type of '
|
||||||
'the\n'
|
'the\n'
|
||||||
|
@ -13754,6 +14317,10 @@ topics = {'assert': 'The "assert" statement\n'
|
||||||
' with "__annotations__", please see Annotations Best\n'
|
' with "__annotations__", please see Annotations Best\n'
|
||||||
' Practices.\n'
|
' Practices.\n'
|
||||||
'\n'
|
'\n'
|
||||||
|
' "__type_params__"\n'
|
||||||
|
' A tuple containing the type parameters of a generic '
|
||||||
|
'class.\n'
|
||||||
|
'\n'
|
||||||
'Class instances\n'
|
'Class instances\n'
|
||||||
' A class instance is created by calling a class object (see '
|
' A class instance is created by calling a class object (see '
|
||||||
'above).\n'
|
'above).\n'
|
||||||
|
|
530
Misc/NEWS.d/3.12.0b2.rst
Normal file
530
Misc/NEWS.d/3.12.0b2.rst
Normal file
|
@ -0,0 +1,530 @@
|
||||||
|
.. date: 2023-06-01-03-24-58
|
||||||
|
.. gh-issue: 103142
|
||||||
|
.. nonce: GLWDMX
|
||||||
|
.. release date: 2023-06-06
|
||||||
|
.. section: Security
|
||||||
|
|
||||||
|
The version of OpenSSL used in our binary builds has been upgraded to 1.1.1u
|
||||||
|
to address several CVEs.
|
||||||
|
|
||||||
|
..
|
||||||
|
|
||||||
|
.. date: 2023-05-24-09-29-08
|
||||||
|
.. gh-issue: 99108
|
||||||
|
.. nonce: hwS2cr
|
||||||
|
.. section: Security
|
||||||
|
|
||||||
|
Refresh our new HACL* built-in :mod:`hashlib` code from upstream. Built-in
|
||||||
|
SHA2 should be faster and an issue with SHA3 on 32-bit platforms is fixed.
|
||||||
|
|
||||||
|
..
|
||||||
|
|
||||||
|
.. date: 2023-06-06-11-37-53
|
||||||
|
.. gh-issue: 105259
|
||||||
|
.. nonce: E2BGKL
|
||||||
|
.. section: Core and Builtins
|
||||||
|
|
||||||
|
Don't include newline character for trailing ``NEWLINE`` tokens emitted in
|
||||||
|
the :mod:`tokenize` module. Patch by Pablo Galindo
|
||||||
|
|
||||||
|
..
|
||||||
|
|
||||||
|
.. date: 2023-06-05-17-35-50
|
||||||
|
.. gh-issue: 105324
|
||||||
|
.. nonce: BqhiJJ
|
||||||
|
.. section: Core and Builtins
|
||||||
|
|
||||||
|
Fix the main function of the :mod:`tokenize` module when reading from
|
||||||
|
``sys.stdin``. Patch by Pablo Galindo
|
||||||
|
|
||||||
|
..
|
||||||
|
|
||||||
|
.. date: 2023-06-02-17-39-19
|
||||||
|
.. gh-issue: 98963
|
||||||
|
.. nonce: J4wJgk
|
||||||
|
.. section: Core and Builtins
|
||||||
|
|
||||||
|
Restore the ability for a subclass of :class:`property` to define
|
||||||
|
``__slots__`` or otherwise be dict-less by ignoring failures to set a
|
||||||
|
docstring on such a class. This behavior had regressed in 3.12beta1. An
|
||||||
|
:exc:`AttributeError` where there had not previously been one was disruptive
|
||||||
|
to existing code.
|
||||||
|
|
||||||
|
..
|
||||||
|
|
||||||
|
.. date: 2023-06-02-11-37-12
|
||||||
|
.. gh-issue: 105194
|
||||||
|
.. nonce: 4eu56B
|
||||||
|
.. section: Core and Builtins
|
||||||
|
|
||||||
|
Do not escape with backslashes f-string format specifiers. Patch by Pablo
|
||||||
|
Galindo
|
||||||
|
|
||||||
|
..
|
||||||
|
|
||||||
|
.. date: 2023-06-01-11-37-03
|
||||||
|
.. gh-issue: 105162
|
||||||
|
.. nonce: r8VCXk
|
||||||
|
.. section: Core and Builtins
|
||||||
|
|
||||||
|
Fixed bug in generator.close()/throw() where an inner iterator would be
|
||||||
|
ignored when the outer iterator was instrumented.
|
||||||
|
|
||||||
|
..
|
||||||
|
|
||||||
|
.. date: 2023-05-31-19-35-22
|
||||||
|
.. gh-issue: 105164
|
||||||
|
.. nonce: 6Wajph
|
||||||
|
.. section: Core and Builtins
|
||||||
|
|
||||||
|
Ensure annotations are set up correctly if the only annotation in a block is
|
||||||
|
within a :keyword:`match` block. Patch by Jelle Zijlstra.
|
||||||
|
|
||||||
|
..
|
||||||
|
|
||||||
|
.. date: 2023-05-31-08-10-59
|
||||||
|
.. gh-issue: 104799
|
||||||
|
.. nonce: 8kDWti
|
||||||
|
.. section: Core and Builtins
|
||||||
|
|
||||||
|
Attributes of :mod:`ast` nodes that are lists now default to the empty list
|
||||||
|
if omitted. This means that some code that previously raised
|
||||||
|
:exc:`TypeError` when the AST node was used will now proceed with the empty
|
||||||
|
list instead. Patch by Jelle Zijlstra.
|
||||||
|
|
||||||
|
..
|
||||||
|
|
||||||
|
.. date: 2023-05-30-08-09-43
|
||||||
|
.. gh-issue: 105035
|
||||||
|
.. nonce: OWUlHy
|
||||||
|
.. section: Core and Builtins
|
||||||
|
|
||||||
|
Fix :func:`super` calls on types with custom :attr:`tp_getattro`
|
||||||
|
implementation (e.g. meta-types.)
|
||||||
|
|
||||||
|
..
|
||||||
|
|
||||||
|
.. date: 2023-05-27-21-50-48
|
||||||
|
.. gh-issue: 105017
|
||||||
|
.. nonce: 4sDyDV
|
||||||
|
.. section: Core and Builtins
|
||||||
|
|
||||||
|
Show CRLF lines in the tokenize string attribute in both NL and NEWLINE
|
||||||
|
tokens. Patch by Marta Gómez.
|
||||||
|
|
||||||
|
..
|
||||||
|
|
||||||
|
.. date: 2023-05-27-16-57-11
|
||||||
|
.. gh-issue: 105013
|
||||||
|
.. nonce: IsDgDY
|
||||||
|
.. section: Core and Builtins
|
||||||
|
|
||||||
|
Fix handling of multiline parenthesized lambdas in
|
||||||
|
:func:`inspect.getsource`. Patch by Pablo Galindo
|
||||||
|
|
||||||
|
..
|
||||||
|
|
||||||
|
.. date: 2023-05-27-16-23-16
|
||||||
|
.. gh-issue: 105017
|
||||||
|
.. nonce: KQrsC0
|
||||||
|
.. section: Core and Builtins
|
||||||
|
|
||||||
|
Do not include an additional final ``NL`` token when parsing files having
|
||||||
|
CRLF lines. Patch by Marta Gómez.
|
||||||
|
|
||||||
|
..
|
||||||
|
|
||||||
|
.. date: 2023-05-26-15-16-11
|
||||||
|
.. gh-issue: 104976
|
||||||
|
.. nonce: 6dLitD
|
||||||
|
.. section: Core and Builtins
|
||||||
|
|
||||||
|
Ensure that trailing ``DEDENT`` :class:`tokenize.TokenInfo` objects emitted
|
||||||
|
by the :mod:`tokenize` module are reported as in Python 3.11. Patch by Pablo
|
||||||
|
Galindo
|
||||||
|
|
||||||
|
..
|
||||||
|
|
||||||
|
.. date: 2023-05-26-14-09-47
|
||||||
|
.. gh-issue: 104972
|
||||||
|
.. nonce: El2UjE
|
||||||
|
.. section: Core and Builtins
|
||||||
|
|
||||||
|
Ensure that the ``line`` attribute in :class:`tokenize.TokenInfo` objects in
|
||||||
|
the :mod:`tokenize` module are always correct. Patch by Pablo Galindo
|
||||||
|
|
||||||
|
..
|
||||||
|
|
||||||
|
.. date: 2023-05-25-21-40-39
|
||||||
|
.. gh-issue: 104955
|
||||||
|
.. nonce: LZx7jf
|
||||||
|
.. section: Core and Builtins
|
||||||
|
|
||||||
|
Fix signature for the new :meth:`~object.__release_buffer__` slot. Patch by
|
||||||
|
Jelle Zijlstra.
|
||||||
|
|
||||||
|
..
|
||||||
|
|
||||||
|
.. date: 2023-05-24-12-10-54
|
||||||
|
.. gh-issue: 104690
|
||||||
|
.. nonce: HX3Jou
|
||||||
|
.. section: Core and Builtins
|
||||||
|
|
||||||
|
Starting new threads and process creation through :func:`os.fork` during
|
||||||
|
interpreter shutdown (such as from :mod:`atexit` handlers) is no longer
|
||||||
|
supported. It can lead to race condition between the main Python runtime
|
||||||
|
thread freeing thread states while internal :mod:`threading` routines are
|
||||||
|
trying to allocate and use the state of just created threads. Or forked
|
||||||
|
children trying to use the mid-shutdown runtime and thread state in the
|
||||||
|
child process.
|
||||||
|
|
||||||
|
..
|
||||||
|
|
||||||
|
.. date: 2023-05-24-10-19-35
|
||||||
|
.. gh-issue: 104879
|
||||||
|
.. nonce: v-29NL
|
||||||
|
.. section: Core and Builtins
|
||||||
|
|
||||||
|
Fix crash when accessing the ``__module__`` attribute of type aliases
|
||||||
|
defined outside a module. Patch by Jelle Zijlstra.
|
||||||
|
|
||||||
|
..
|
||||||
|
|
||||||
|
.. date: 2023-05-24-09-59-56
|
||||||
|
.. gh-issue: 104825
|
||||||
|
.. nonce: mQesie
|
||||||
|
.. section: Core and Builtins
|
||||||
|
|
||||||
|
Tokens emitted by the :mod:`tokenize` module do not include an implicit
|
||||||
|
``\n`` character in the ``line`` attribute anymore. Patch by Pablo Galindo
|
||||||
|
|
||||||
|
..
|
||||||
|
|
||||||
|
.. date: 2023-06-04-12-16-47
|
||||||
|
.. gh-issue: 105280
|
||||||
|
.. nonce: srRbCe
|
||||||
|
.. section: Library
|
||||||
|
|
||||||
|
Fix bug where ``isinstance([], collections.abc.Mapping)`` could evaluate to
|
||||||
|
``True`` if garbage collection happened at the wrong time. The bug was
|
||||||
|
caused by changes to the implementation of :class:`typing.Protocol` in
|
||||||
|
Python 3.12.
|
||||||
|
|
||||||
|
..
|
||||||
|
|
||||||
|
.. date: 2023-06-02-14-57-11
|
||||||
|
.. gh-issue: 105239
|
||||||
|
.. nonce: SAmuuj
|
||||||
|
.. section: Library
|
||||||
|
|
||||||
|
Fix longstanding bug where ``issubclass(object, typing.Protocol)`` would
|
||||||
|
evaluate to ``True`` in some edge cases. Patch by Alex Waygood.
|
||||||
|
|
||||||
|
..
|
||||||
|
|
||||||
|
.. date: 2023-06-02-02-38-26
|
||||||
|
.. gh-issue: 105080
|
||||||
|
.. nonce: 2imGMg
|
||||||
|
.. section: Library
|
||||||
|
|
||||||
|
Fixed inconsistent signature on derived classes for
|
||||||
|
:func:`inspect.signature`
|
||||||
|
|
||||||
|
..
|
||||||
|
|
||||||
|
.. date: 2023-05-31-16-58-42
|
||||||
|
.. gh-issue: 105144
|
||||||
|
.. nonce: Oqfn0V
|
||||||
|
.. section: Library
|
||||||
|
|
||||||
|
Fix a recent regression in the :mod:`typing` module. The regression meant
|
||||||
|
that doing ``class Foo(X, typing.Protocol)``, where ``X`` was a class that
|
||||||
|
had :class:`abc.ABCMeta` as its metaclass, would then cause subsequent
|
||||||
|
``isinstance(1, X)`` calls to erroneously raise :exc:`TypeError`. Patch by
|
||||||
|
Alex Waygood.
|
||||||
|
|
||||||
|
..
|
||||||
|
|
||||||
|
.. date: 2023-05-30-21-27-41
|
||||||
|
.. gh-issue: 105113
|
||||||
|
.. nonce: bDUPl_
|
||||||
|
.. section: Library
|
||||||
|
|
||||||
|
Improve performance of :meth:`pathlib.PurePath.match` by compiling an
|
||||||
|
:class:`re.Pattern` object for the entire pattern.
|
||||||
|
|
||||||
|
..
|
||||||
|
|
||||||
|
.. date: 2023-05-26-01-31-30
|
||||||
|
.. gh-issue: 101588
|
||||||
|
.. nonce: RaqxFy
|
||||||
|
.. section: Library
|
||||||
|
|
||||||
|
Deprecate undocumented copy/deepcopy/pickle support for itertools.
|
||||||
|
|
||||||
|
..
|
||||||
|
|
||||||
|
.. date: 2023-05-25-23-34-54
|
||||||
|
.. gh-issue: 103631
|
||||||
|
.. nonce: x5Urye
|
||||||
|
.. section: Library
|
||||||
|
|
||||||
|
Fix ``pathlib.PurePosixPath(pathlib.PureWindowsPath(...))`` not converting
|
||||||
|
path separators to restore 3.11 compatible behavior.
|
||||||
|
|
||||||
|
..
|
||||||
|
|
||||||
|
.. date: 2023-05-25-22-54-20
|
||||||
|
.. gh-issue: 104947
|
||||||
|
.. nonce: hi6TUr
|
||||||
|
.. section: Library
|
||||||
|
|
||||||
|
Make comparisons between :class:`pathlib.PureWindowsPath` objects consistent
|
||||||
|
across Windows and Posix to match 3.11 behavior.
|
||||||
|
|
||||||
|
..
|
||||||
|
|
||||||
|
.. date: 2023-05-25-08-50-47
|
||||||
|
.. gh-issue: 104935
|
||||||
|
.. nonce: -rm1BR
|
||||||
|
.. section: Library
|
||||||
|
|
||||||
|
Fix bugs with the interaction between :func:`typing.runtime_checkable` and
|
||||||
|
:class:`typing.Generic` that were introduced by the :pep:`695`
|
||||||
|
implementation. Patch by Jelle Zijlstra.
|
||||||
|
|
||||||
|
..
|
||||||
|
|
||||||
|
.. date: 2023-05-24-09-34-23
|
||||||
|
.. gh-issue: 104874
|
||||||
|
.. nonce: oqyJSy
|
||||||
|
.. section: Library
|
||||||
|
|
||||||
|
Document the ``__name__`` and ``__supertype__`` attributes of
|
||||||
|
:class:`typing.NewType`. Patch by Jelle Zijlstra.
|
||||||
|
|
||||||
|
..
|
||||||
|
|
||||||
|
.. date: 2023-05-23-18-31-49
|
||||||
|
.. gh-issue: 104799
|
||||||
|
.. nonce: MJYOw6
|
||||||
|
.. section: Library
|
||||||
|
|
||||||
|
Adjust the location of the (see :pep:`695`) ``type_params`` field on
|
||||||
|
:class:`ast.ClassDef`, :class:`ast.AsyncFunctionDef`, and
|
||||||
|
:class:`ast.FunctionDef` to better preserve backward compatibility. Patch by
|
||||||
|
Jelle Zijlstra
|
||||||
|
|
||||||
|
..
|
||||||
|
|
||||||
|
.. date: 2023-05-23-17-43-52
|
||||||
|
.. gh-issue: 104797
|
||||||
|
.. nonce: NR7KzF
|
||||||
|
.. section: Library
|
||||||
|
|
||||||
|
Allow :class:`typing.Protocol` classes to inherit from
|
||||||
|
:class:`collections.abc.Buffer`. Patch by Jelle Zijlstra.
|
||||||
|
|
||||||
|
..
|
||||||
|
|
||||||
|
.. date: 2023-05-22-18-39-53
|
||||||
|
.. gh-issue: 104372
|
||||||
|
.. nonce: 7tDRaK
|
||||||
|
.. section: Library
|
||||||
|
|
||||||
|
On Linux where :mod:`subprocess` can use the ``vfork()`` syscall for faster
|
||||||
|
spawning, prevent the parent process from blocking other threads by dropping
|
||||||
|
the GIL while it waits for the vfork'ed child process ``exec()`` outcome.
|
||||||
|
This prevents spawning a binary from a slow filesystem from blocking the
|
||||||
|
rest of the application.
|
||||||
|
|
||||||
|
..
|
||||||
|
|
||||||
|
.. date: 2023-05-19-19-46-22
|
||||||
|
.. gh-issue: 99108
|
||||||
|
.. nonce: wqCg0t
|
||||||
|
.. section: Library
|
||||||
|
|
||||||
|
We now release the GIL around built-in :mod:`hashlib` computations of
|
||||||
|
reasonable size for the SHA families and MD5 hash functions, matching what
|
||||||
|
our OpenSSL backed hash computations already does.
|
||||||
|
|
||||||
|
..
|
||||||
|
|
||||||
|
.. date: 2023-05-11-23-03-00
|
||||||
|
.. gh-issue: 104399
|
||||||
|
.. nonce: MMatTP
|
||||||
|
.. section: Library
|
||||||
|
|
||||||
|
Prepare the ``_tkinter`` module for building with Tcl 9.0 and future
|
||||||
|
libtommath by replacing usage of deprecated functions
|
||||||
|
:c:func:`mp_to_unsigned_bin_n` and :c:func:`mp_unsigned_bin_size` when
|
||||||
|
necessary.
|
||||||
|
|
||||||
|
..
|
||||||
|
|
||||||
|
.. date: 2023-02-18-22-55-48
|
||||||
|
.. gh-issue: 102024
|
||||||
|
.. nonce: RUmg_D
|
||||||
|
.. section: Library
|
||||||
|
|
||||||
|
Reduce calls of ``_idle_semaphore.release()`` in
|
||||||
|
:func:`concurrent.futures.thread._worker`.
|
||||||
|
|
||||||
|
..
|
||||||
|
|
||||||
|
.. date: 2023-05-28-21-01-00
|
||||||
|
.. gh-issue: 89455
|
||||||
|
.. nonce: qAKRrA
|
||||||
|
.. section: Documentation
|
||||||
|
|
||||||
|
Add missing documentation for the ``max_group_depth`` and
|
||||||
|
``max_group_width`` parameters and the ``exceptions`` attribute of the
|
||||||
|
:class:`traceback.TracebackException` class.
|
||||||
|
|
||||||
|
..
|
||||||
|
|
||||||
|
.. date: 2023-05-28-19-08-42
|
||||||
|
.. gh-issue: 89412
|
||||||
|
.. nonce: j4cg7K
|
||||||
|
.. section: Documentation
|
||||||
|
|
||||||
|
Add missing documentation for the ``end_lineno`` and ``end_offset``
|
||||||
|
attributes of the :class:`traceback.TracebackException` class.
|
||||||
|
|
||||||
|
..
|
||||||
|
|
||||||
|
.. date: 2023-05-25-22-34-31
|
||||||
|
.. gh-issue: 104943
|
||||||
|
.. nonce: J2v1Pc
|
||||||
|
.. section: Documentation
|
||||||
|
|
||||||
|
Remove mentions of old Python versions in :class:`typing.NamedTuple`.
|
||||||
|
|
||||||
|
..
|
||||||
|
|
||||||
|
.. date: 2023-06-06-09-08-10
|
||||||
|
.. gh-issue: 90005
|
||||||
|
.. nonce: 8mmeJQ
|
||||||
|
.. section: Build
|
||||||
|
|
||||||
|
Fix a regression in :file:`configure` where we could end up unintentionally
|
||||||
|
linking with ``libbsd``.
|
||||||
|
|
||||||
|
..
|
||||||
|
|
||||||
|
.. date: 2023-05-26-15-44-20
|
||||||
|
.. gh-issue: 89886
|
||||||
|
.. nonce: _iSW-p
|
||||||
|
.. section: Build
|
||||||
|
|
||||||
|
Autoconf 2.71 and aclocal 1.16.4 is now required to regenerate
|
||||||
|
:file:`!configure`.
|
||||||
|
|
||||||
|
..
|
||||||
|
|
||||||
|
.. date: 2023-05-31-16-14-31
|
||||||
|
.. gh-issue: 105146
|
||||||
|
.. nonce: gNjqq8
|
||||||
|
.. section: Windows
|
||||||
|
|
||||||
|
Updated the links at the end of the installer to point to Discourse rather
|
||||||
|
than the mailing lists.
|
||||||
|
|
||||||
|
..
|
||||||
|
|
||||||
|
.. date: 2023-05-29-17-09-31
|
||||||
|
.. gh-issue: 103646
|
||||||
|
.. nonce: U8oGQx
|
||||||
|
.. section: Windows
|
||||||
|
|
||||||
|
When installed from the Microsoft Store, ``pip`` no longer defaults to
|
||||||
|
per-user installs. However, as the install directory is unwritable, it
|
||||||
|
should automatically decide to do a per-user install anyway. This should
|
||||||
|
resolve issues when ``pip`` is passed an option that conflicts with
|
||||||
|
``--user``.
|
||||||
|
|
||||||
|
..
|
||||||
|
|
||||||
|
.. date: 2023-05-29-11-38-53
|
||||||
|
.. gh-issue: 88745
|
||||||
|
.. nonce: cldf9G
|
||||||
|
.. section: Windows
|
||||||
|
|
||||||
|
Improve performance of :func:`shutil.copy2` by using the operating system's
|
||||||
|
``CopyFile2`` function. This may result in subtle changes to metadata copied
|
||||||
|
along with some files, bringing them in line with normal OS behavior.
|
||||||
|
|
||||||
|
..
|
||||||
|
|
||||||
|
.. date: 2023-05-24-21-00-57
|
||||||
|
.. gh-issue: 104820
|
||||||
|
.. nonce: ibyrpp
|
||||||
|
.. section: Windows
|
||||||
|
|
||||||
|
Fixes :func:`~os.stat` and related functions on file systems that do not
|
||||||
|
support file ID requests. This includes FAT32 and exFAT.
|
||||||
|
|
||||||
|
..
|
||||||
|
|
||||||
|
.. date: 2023-05-23-19-26-28
|
||||||
|
.. gh-issue: 104803
|
||||||
|
.. nonce: gqxYml
|
||||||
|
.. section: Windows
|
||||||
|
|
||||||
|
Add :func:`os.path.isdevdrive` to detect whether a path is on a Windows Dev
|
||||||
|
Drive. Returns ``False`` on platforms that do not support Dev Drive, and is
|
||||||
|
absent on non-Windows platforms.
|
||||||
|
|
||||||
|
..
|
||||||
|
|
||||||
|
.. date: 2023-05-30-23-30-46
|
||||||
|
.. gh-issue: 103142
|
||||||
|
.. nonce: 55lMXQ
|
||||||
|
.. section: macOS
|
||||||
|
|
||||||
|
Update macOS installer to use OpenSSL 1.1.1u.
|
||||||
|
|
||||||
|
..
|
||||||
|
|
||||||
|
.. date: 2023-05-23-17-19-49
|
||||||
|
.. gh-issue: 104719
|
||||||
|
.. nonce: rvYXH-
|
||||||
|
.. section: IDLE
|
||||||
|
|
||||||
|
Remove IDLE's modification of tokenize.tabsize and test other uses of
|
||||||
|
tokenize data and methods.
|
||||||
|
|
||||||
|
..
|
||||||
|
|
||||||
|
.. date: 2023-05-30-17-45-32
|
||||||
|
.. gh-issue: 105115
|
||||||
|
.. nonce: iRho1K
|
||||||
|
.. section: C API
|
||||||
|
|
||||||
|
``PyTypeObject.tp_bases`` (and ``tp_mro``) for builtin static types are now
|
||||||
|
shared by all interpreters, whereas in 3.12-beta1 they were stored on
|
||||||
|
``PyInterpreterState``. Also note that now the tuples are immortal objects.
|
||||||
|
|
||||||
|
..
|
||||||
|
|
||||||
|
.. date: 2023-05-30-10-15-13
|
||||||
|
.. gh-issue: 105071
|
||||||
|
.. nonce: dPtp7c
|
||||||
|
.. section: C API
|
||||||
|
|
||||||
|
Add ``PyUnstable_Exc_PrepReraiseStar`` to the unstable C api to expose the
|
||||||
|
implementation of :keyword:`except* <except_star>`.
|
||||||
|
|
||||||
|
..
|
||||||
|
|
||||||
|
.. date: 2023-05-19-10-22-34
|
||||||
|
.. gh-issue: 104668
|
||||||
|
.. nonce: MLX1g9
|
||||||
|
.. section: C API
|
||||||
|
|
||||||
|
Don't call :c:var:`PyOS_InputHook` or :c:var:`PyOS_ReadlineFunctionPointer`
|
||||||
|
in subinterpreters, since it's generally difficult to avoid using global
|
||||||
|
state in their registered callbacks. This also avoids situations where
|
||||||
|
extensions may find themselves running in a subinterpreter they don't
|
||||||
|
support (or haven't yet been loaded in).
|
|
@ -1,2 +0,0 @@
|
||||||
Autoconf 2.71 and aclocal 1.16.4 is now required to regenerate
|
|
||||||
:file:`!configure`.
|
|
|
@ -1 +0,0 @@
|
||||||
Fix a regression in :file:`configure` where we could end up unintentionally linking with ``libbsd``.
|
|
|
@ -1,5 +0,0 @@
|
||||||
Don't call :c:var:`PyOS_InputHook` or :c:var:`PyOS_ReadlineFunctionPointer`
|
|
||||||
in subinterpreters, since it's generally difficult to avoid using global
|
|
||||||
state in their registered callbacks. This also avoids situations where
|
|
||||||
extensions may find themselves running in a subinterpreter they don't
|
|
||||||
support (or haven't yet been loaded in).
|
|
|
@ -1 +0,0 @@
|
||||||
Add ``PyUnstable_Exc_PrepReraiseStar`` to the unstable C api to expose the implementation of :keyword:`except* <except_star>`.
|
|
|
@ -1,3 +0,0 @@
|
||||||
``PyTypeObject.tp_bases`` (and ``tp_mro``) for builtin static types are now
|
|
||||||
shared by all interpreters, whereas in 3.12-beta1 they were stored on
|
|
||||||
``PyInterpreterState``. Also note that now the tuples are immortal objects.
|
|
|
@ -1,2 +0,0 @@
|
||||||
Tokens emitted by the :mod:`tokenize` module do not include an implicit
|
|
||||||
``\n`` character in the ``line`` attribute anymore. Patch by Pablo Galindo
|
|
|
@ -1,2 +0,0 @@
|
||||||
Fix crash when accessing the ``__module__`` attribute of type aliases
|
|
||||||
defined outside a module. Patch by Jelle Zijlstra.
|
|
|
@ -1,6 +0,0 @@
|
||||||
Starting new threads and process creation through :func:`os.fork` during interpreter
|
|
||||||
shutdown (such as from :mod:`atexit` handlers) is no longer supported. It can lead
|
|
||||||
to race condition between the main Python runtime thread freeing thread states while
|
|
||||||
internal :mod:`threading` routines are trying to allocate and use the state of just
|
|
||||||
created threads. Or forked children trying to use the mid-shutdown runtime and thread
|
|
||||||
state in the child process.
|
|
|
@ -1,2 +0,0 @@
|
||||||
Fix signature for the new :meth:`~object.__release_buffer__` slot. Patch by Jelle
|
|
||||||
Zijlstra.
|
|
|
@ -1,2 +0,0 @@
|
||||||
Ensure that the ``line`` attribute in :class:`tokenize.TokenInfo` objects in
|
|
||||||
the :mod:`tokenize` module are always correct. Patch by Pablo Galindo
|
|
|
@ -1,3 +0,0 @@
|
||||||
Ensure that trailing ``DEDENT`` :class:`tokenize.TokenInfo` objects emitted
|
|
||||||
by the :mod:`tokenize` module are reported as in Python 3.11. Patch by Pablo
|
|
||||||
Galindo
|
|
|
@ -1 +0,0 @@
|
||||||
Do not include an additional final ``NL`` token when parsing files having CRLF lines. Patch by Marta Gómez.
|
|
|
@ -1,2 +0,0 @@
|
||||||
Fix handling of multiline parenthesized lambdas in
|
|
||||||
:func:`inspect.getsource`. Patch by Pablo Galindo
|
|
|
@ -1 +0,0 @@
|
||||||
Show CRLF lines in the tokenize string attribute in both NL and NEWLINE tokens. Patch by Marta Gómez.
|
|
|
@ -1,2 +0,0 @@
|
||||||
Fix :func:`super` calls on types with custom :attr:`tp_getattro`
|
|
||||||
implementation (e.g. meta-types.)
|
|
|
@ -1,4 +0,0 @@
|
||||||
Attributes of :mod:`ast` nodes that are lists now default to the empty list
|
|
||||||
if omitted. This means that some code that previously raised
|
|
||||||
:exc:`TypeError` when the AST node was used will now proceed with the empty
|
|
||||||
list instead. Patch by Jelle Zijlstra.
|
|
|
@ -1,2 +0,0 @@
|
||||||
Ensure annotations are set up correctly if the only annotation in a block is
|
|
||||||
within a :keyword:`match` block. Patch by Jelle Zijlstra.
|
|
|
@ -1,2 +0,0 @@
|
||||||
Fixed bug in generator.close()/throw() where an inner iterator would be
|
|
||||||
ignored when the outer iterator was instrumented.
|
|
|
@ -1,2 +0,0 @@
|
||||||
Do not escape with backslashes f-string format specifiers. Patch by Pablo
|
|
||||||
Galindo
|
|
|
@ -1,4 +0,0 @@
|
||||||
Restore the ability for a subclass of :class:`property` to define ``__slots__``
|
|
||||||
or otherwise be dict-less by ignoring failures to set a docstring on such a
|
|
||||||
class. This behavior had regressed in 3.12beta1. An :exc:`AttributeError`
|
|
||||||
where there had not previously been one was disruptive to existing code.
|
|
|
@ -1,2 +0,0 @@
|
||||||
Fix the main function of the :mod:`tokenize` module when reading from
|
|
||||||
``sys.stdin``. Patch by Pablo Galindo
|
|
|
@ -1,2 +0,0 @@
|
||||||
Don't include newline character for trailing ``NEWLINE`` tokens emitted in
|
|
||||||
the :mod:`tokenize` module. Patch by Pablo Galindo
|
|
|
@ -1 +0,0 @@
|
||||||
Remove mentions of old Python versions in :class:`typing.NamedTuple`.
|
|
|
@ -1,2 +0,0 @@
|
||||||
Add missing documentation for the ``end_lineno`` and ``end_offset`` attributes
|
|
||||||
of the :class:`traceback.TracebackException` class.
|
|
|
@ -1,3 +0,0 @@
|
||||||
Add missing documentation for the ``max_group_depth`` and ``max_group_width``
|
|
||||||
parameters and the ``exceptions`` attribute of the
|
|
||||||
:class:`traceback.TracebackException` class.
|
|
|
@ -1,2 +0,0 @@
|
||||||
Remove IDLE's modification of tokenize.tabsize and test other uses of
|
|
||||||
tokenize data and methods.
|
|
|
@ -1 +0,0 @@
|
||||||
Reduce calls of ``_idle_semaphore.release()`` in :func:`concurrent.futures.thread._worker`.
|
|
|
@ -1,4 +0,0 @@
|
||||||
Prepare the ``_tkinter`` module for building with Tcl 9.0 and future
|
|
||||||
libtommath by replacing usage of deprecated functions
|
|
||||||
:c:func:`mp_to_unsigned_bin_n` and :c:func:`mp_unsigned_bin_size`
|
|
||||||
when necessary.
|
|
|
@ -1,3 +0,0 @@
|
||||||
We now release the GIL around built-in :mod:`hashlib` computations of
|
|
||||||
reasonable size for the SHA families and MD5 hash functions, matching
|
|
||||||
what our OpenSSL backed hash computations already does.
|
|
|
@ -1,5 +0,0 @@
|
||||||
On Linux where :mod:`subprocess` can use the ``vfork()`` syscall for faster
|
|
||||||
spawning, prevent the parent process from blocking other threads by dropping
|
|
||||||
the GIL while it waits for the vfork'ed child process ``exec()`` outcome.
|
|
||||||
This prevents spawning a binary from a slow filesystem from blocking the
|
|
||||||
rest of the application.
|
|
|
@ -1,2 +0,0 @@
|
||||||
Allow :class:`typing.Protocol` classes to inherit from
|
|
||||||
:class:`collections.abc.Buffer`. Patch by Jelle Zijlstra.
|
|
|
@ -1,4 +0,0 @@
|
||||||
Adjust the location of the (see :pep:`695`) ``type_params`` field on
|
|
||||||
:class:`ast.ClassDef`, :class:`ast.AsyncFunctionDef`, and
|
|
||||||
:class:`ast.FunctionDef` to better preserve backward compatibility. Patch by
|
|
||||||
Jelle Zijlstra
|
|
|
@ -1,2 +0,0 @@
|
||||||
Document the ``__name__`` and ``__supertype__`` attributes of
|
|
||||||
:class:`typing.NewType`. Patch by Jelle Zijlstra.
|
|
|
@ -1,3 +0,0 @@
|
||||||
Fix bugs with the interaction between :func:`typing.runtime_checkable` and
|
|
||||||
:class:`typing.Generic` that were introduced by the :pep:`695`
|
|
||||||
implementation. Patch by Jelle Zijlstra.
|
|
|
@ -1,2 +0,0 @@
|
||||||
Make comparisons between :class:`pathlib.PureWindowsPath` objects consistent
|
|
||||||
across Windows and Posix to match 3.11 behavior.
|
|
|
@ -1,2 +0,0 @@
|
||||||
Fix ``pathlib.PurePosixPath(pathlib.PureWindowsPath(...))`` not converting
|
|
||||||
path separators to restore 3.11 compatible behavior.
|
|
|
@ -1 +0,0 @@
|
||||||
Deprecate undocumented copy/deepcopy/pickle support for itertools.
|
|
|
@ -1,2 +0,0 @@
|
||||||
Improve performance of :meth:`pathlib.PurePath.match` by compiling an
|
|
||||||
:class:`re.Pattern` object for the entire pattern.
|
|
|
@ -1,5 +0,0 @@
|
||||||
Fix a recent regression in the :mod:`typing` module. The regression meant
|
|
||||||
that doing ``class Foo(X, typing.Protocol)``, where ``X`` was a class that
|
|
||||||
had :class:`abc.ABCMeta` as its metaclass, would then cause subsequent
|
|
||||||
``isinstance(1, X)`` calls to erroneously raise :exc:`TypeError`. Patch by
|
|
||||||
Alex Waygood.
|
|
|
@ -1 +0,0 @@
|
||||||
Fixed inconsistent signature on derived classes for :func:`inspect.signature`
|
|
|
@ -1,2 +0,0 @@
|
||||||
Fix longstanding bug where ``issubclass(object, typing.Protocol)`` would
|
|
||||||
evaluate to ``True`` in some edge cases. Patch by Alex Waygood.
|
|
|
@ -1,4 +0,0 @@
|
||||||
Fix bug where ``isinstance([], collections.abc.Mapping)`` could evaluate to
|
|
||||||
``True`` if garbage collection happened at the wrong time. The bug was
|
|
||||||
caused by changes to the implementation of :class:`typing.Protocol` in
|
|
||||||
Python 3.12.
|
|
|
@ -1,2 +0,0 @@
|
||||||
Refresh our new HACL* built-in :mod:`hashlib` code from upstream. Built-in
|
|
||||||
SHA2 should be faster and an issue with SHA3 on 32-bit platforms is fixed.
|
|
|
@ -1,2 +0,0 @@
|
||||||
The version of OpenSSL used in our binary builds has been upgraded to 1.1.1u
|
|
||||||
to address several CVEs.
|
|
|
@ -1,3 +0,0 @@
|
||||||
Add :func:`os.path.isdevdrive` to detect whether a path is on a Windows Dev
|
|
||||||
Drive. Returns ``False`` on platforms that do not support Dev Drive, and is
|
|
||||||
absent on non-Windows platforms.
|
|
|
@ -1,2 +0,0 @@
|
||||||
Fixes :func:`~os.stat` and related functions on file systems that do not
|
|
||||||
support file ID requests. This includes FAT32 and exFAT.
|
|
|
@ -1,3 +0,0 @@
|
||||||
Improve performance of :func:`shutil.copy2` by using the operating system's
|
|
||||||
``CopyFile2`` function. This may result in subtle changes to metadata copied
|
|
||||||
along with some files, bringing them in line with normal OS behavior.
|
|
|
@ -1,5 +0,0 @@
|
||||||
When installed from the Microsoft Store, ``pip`` no longer defaults to
|
|
||||||
per-user installs. However, as the install directory is unwritable, it
|
|
||||||
should automatically decide to do a per-user install anyway. This should
|
|
||||||
resolve issues when ``pip`` is passed an option that conflicts with
|
|
||||||
``--user``.
|
|
|
@ -1,2 +0,0 @@
|
||||||
Updated the links at the end of the installer to point to Discourse rather
|
|
||||||
than the mailing lists.
|
|
|
@ -1 +0,0 @@
|
||||||
Update macOS installer to use OpenSSL 1.1.1u.
|
|
|
@ -1,4 +1,4 @@
|
||||||
This is Python version 3.12.0 beta 1
|
This is Python version 3.12.0 beta 2
|
||||||
=====================================
|
=====================================
|
||||||
|
|
||||||
.. image:: https://github.com/python/cpython/workflows/Tests/badge.svg
|
.. image:: https://github.com/python/cpython/workflows/Tests/badge.svg
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue