Python 3.11.0

-----BEGIN PGP SIGNATURE-----
 
 iQIzBAABCAAdFiEEz9yiRbEEPPKl+Xhl/+h0BBaL2EcFAmNWzOwACgkQ/+h0BBaL
 2EcepxAAmZLGMrL4D7Zxzo6N2ezkuiuoQH4JvxIUaB7cjU5h0GSUFlmcJQCHhCwk
 AvToQrmH/7uuuEZKST1fomtUE83wudfHhX2t+CMBdbLG1hIwhTfLNMTqFhONturF
 XlkVUcva1i9XrYZPLl1pIcBf1Sjm6pPW5QZ4BP1ZHJ5C2pHEzaBRFX/q0lU5aF9O
 z5nBBpnga2gShUTqM1VkXucU4lKXsi4blbn/Z8giganMXY1SXIsEOoCaDZYN1Hh/
 xQiOpSrjy/uSz4vGSNuPwp9J2lRlw8n4RBd/P7om01CrJMAKotH+62OqwhlQ8ydB
 ywp0kygtPtMdSK7F1WKMWkYX4CXfLpYwN0+x3Z3iYFBFiuzOFrUCQYgqqfEPNq+o
 bQxxnhAvYcOVINUub6oL23hgFZIoM6l54L66qujQVFM0usCY2f23Ikqd0Z7K8+6e
 uDRAvGiCHkbbfhdnfXzc/Wgj4zLaPnNs8S2s8ojK32NPV8gyWVBumcsRvlocfl6K
 hoA5wqeAXsOv+pFjkGtk90Yg+8R9n+n47//o6uYW/vvZtksm2wPm3hnuCA0WqPzN
 IM7SJE5VrtSRqQpXT9j4G3zyHDNT/Qhrh+cyBM5kgoPSdbU0ugZN8P7GWVtsFhmK
 rrHRns85gNZJ6qTN1pU22MybYCPIsg5Dt6+jZ8hJWIzOOy9apIk=
 =Ryd2
 -----END PGP SIGNATURE-----
gpgsig -----BEGIN PGP SIGNATURE-----
 
 iQIzBAABCAAdFiEEz9yiRbEEPPKl+Xhl/+h0BBaL2EcFAmNW55YACgkQ/+h0BBaL
 2EfCLg//bMWtb/X3D+IM+9BIrpEscj/vw22zH9j8PIRd8iWfW80TNEIBh4uPEc0j
 SDTkA5bqN6CB7xqIxDlWQcJpGiImVZ2LzOw8HHye1QCfVZk741CF78UhEnb+hTbO
 gr7nIznytv+VdMSDRHTSgpnkRNQ9FjFEHLu7YQTMof5i/YmTxWZcsru6dTLlEutg
 F3+PfxbKwPgJkfare91X62XSQwyTL6k0mvl5+Sdq2WEQdgMqv4I8V9dHbnk9K3VI
 B+K2xsfIyWHrLDwQa3LBZj4YOKTwnwqlr1sEqO47NfasWaMYa1vBsktLVtPVQ3xS
 Hz0lLhJXJLzf5hmf2r4Tw1S5spn5ijsZ7CwK2Zl+1+dbJMpRoK4VeSSYy/OfEpwy
 8Hx1YitMyORF3HkGWa+pPYPNaIOw4S/EQQPYd5osg3NnknYjkkKZZaliq7EZra7c
 GANPJamXhHREQyhux9KeiYZer3SU3CSXopyxm8ClcBZJAiAOjhAdeOk+Q4Ta9T6+
 gRWBOrelroyFTWHsOd8V7gSz3XJNuAzlNZ/+1Oj/7Em+5DGLFcxJrZGLxn+hruZ5
 GPK9IQXbURAuxqVrqCzw2tzf/NzJr0fs4QDYEVI95pfLjzk1tuJ5WR6zFNC0COK2
 qw8TTvXglsvHqVMnK8u73GVSTv1UGYqbQH9uAeEikAQYr3TTdZo=
 =dsZm
 -----END PGP SIGNATURE-----

Merge tag 'v3.11.0' into 3.11

Python 3.11.0
This commit is contained in:
Pablo Galindo 2022-10-24 20:29:24 +01:00
commit 69b6b56d85
7 changed files with 518 additions and 131 deletions

View File

@ -129,6 +129,19 @@ You can deactivate a virtual environment by typing ``deactivate`` in your shell.
The exact mechanism is platform-specific and is an internal implementation
detail (typically, a script or shell function will be used).
.. warning:: Because scripts installed in environments should not expect the
environment to be activated, their shebang lines contain the absolute paths
to their environment's interpreters. Because of this, environments are
inherently non-portable, in the general case. You should always have a
simple means of recreating an environment (for example, if you have a
requirements file ``requirements.txt``, you can invoke ``pip install -r
requirements.txt`` using the environment's ``pip`` to install all of the
packages needed by the environment). If for any reason you need to move the
environment to a new location, you should recreate it at the desired
location and delete the one at the old location. If you move an environment
because you moved a parent directory of it, you should recreate the
environment in its new location. Otherwise, software installed into the
environment may not work as expected.
.. _venv-api:

View File

@ -1590,6 +1590,10 @@ Changed/removed opcodes
:opcode:`!POP_BLOCK`, :opcode:`!SETUP_FINALLY` and :opcode:`!YIELD_FROM`.
.. _whatsnew311-deprecated:
.. _whatsnew311-python-api-deprecated:
.. _whatsnew311-deprecated:
.. _whatsnew311-python-api-deprecated:
@ -1765,6 +1769,9 @@ Standard Library
(Contributed by Erlend E. Aasland in :issue:`5846`.)
.. _whatsnew311-pending-removal:
.. _whatsnew311-python-api-pending-removal:
.. _whatsnew311-pending-removal:
.. _whatsnew311-python-api-pending-removal:

View File

@ -19,8 +19,8 @@
#define PY_MAJOR_VERSION 3
#define PY_MINOR_VERSION 11
#define PY_MICRO_VERSION 0
#define PY_RELEASE_LEVEL PY_RELEASE_LEVEL_GAMMA
#define PY_RELEASE_SERIAL 2
#define PY_RELEASE_LEVEL PY_RELEASE_LEVEL_FINAL
#define PY_RELEASE_SERIAL 0
/* Version as a string */
#define PY_VERSION "3.11.0rc2+"

View File

@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
# Autogenerated by Sphinx on Sun Sep 11 20:22:13 2022
# Autogenerated by Sphinx on Mon Oct 24 18:35:07 2022
topics = {'assert': 'The "assert" statement\n'
'**********************\n'
'\n'
@ -1671,10 +1671,26 @@
'If the syntax "**expression" appears in the function call,\n'
'"expression" must evaluate to a *mapping*, the contents of which '
'are\n'
'treated as additional keyword arguments. If a keyword is already\n'
'present (as an explicit keyword argument, or from another '
'unpacking),\n'
'a "TypeError" exception is raised.\n'
'treated as additional keyword arguments. If a parameter matching a '
'key\n'
'has already been given a value (by an explicit keyword argument, '
'or\n'
'from another unpacking), a "TypeError" exception is raised.\n'
'\n'
'When "**expression" is used, each key in this mapping must be a\n'
'string. Each value from the mapping is assigned to the first '
'formal\n'
'parameter eligible for keyword assignment whose name is equal to '
'the\n'
'key. A key need not be a Python identifier (e.g. ""max-temp °F"" '
'is\n'
'acceptable, although it will not match any formal parameter that '
'could\n'
'be declared). If there is no match to a formal parameter the '
'key-value\n'
'pair is collected by the "**" parameter, if there is one, or if '
'there\n'
'is not, a "TypeError" exception is raised.\n'
'\n'
'Formal parameters using the syntax "*identifier" or "**identifier"\n'
'cannot be used as positional argument slots or as keyword argument\n'
@ -2022,7 +2038,7 @@
'\n'
'* Mappings (instances of "dict") compare equal if and only if '
'they\n'
' have equal *(key, value)* pairs. Equality comparison of the '
' have equal "(key, value)" pairs. Equality comparison of the '
'keys and\n'
' values enforces reflexivity.\n'
'\n'
@ -2398,35 +2414,43 @@
' try3_stmt ::= "try" ":" suite\n'
' "finally" ":" suite\n'
'\n'
'Additional information on exceptions can be found in section\n'
'Exceptions, and information on using the "raise" statement to '
'generate\n'
'exceptions may be found in section The raise statement.\n'
'\n'
'\n'
'"except" clause\n'
'---------------\n'
'\n'
'The "except" clause(s) specify one or more exception handlers. '
'When no\n'
'exception occurs in the "try" clause, no exception handler is\n'
'executed. When an exception occurs in the "try" suite, a search '
'for an\n'
'exception handler is started. This search inspects the except '
'clauses\n'
'in turn until one is found that matches the exception. An '
'expression-\n'
'less except clause, if present, must be last; it matches any\n'
'exception. For an except clause with an expression, that '
'expression\n'
'is evaluated, and the clause matches the exception if the '
'resulting\n'
'object is “compatible” with the exception. An object is '
'compatible\n'
'with an exception if the object is the class or a *non-virtual '
'base\n'
'class* of the exception object, or a tuple containing an item '
'that is\n'
'the class or a non-virtual base class of the exception object.\n'
'\n'
'If no except clause matches the exception, the search for an '
'exception handler is started. This search inspects the "except"\n'
'clauses in turn until one is found that matches the exception. '
'An\n'
'expression-less "except" clause, if present, must be last; it '
'matches\n'
'any exception. For an "except" clause with an expression, that\n'
'expression is evaluated, and the clause matches the exception if '
'the\n'
'resulting object is “compatible” with the exception. An object '
'is\n'
'compatible with an exception if the object is the class or a '
'*non-\n'
'virtual base class* of the exception object, or a tuple '
'containing an\n'
'item that is the class or a non-virtual base class of the '
'exception\n'
'handler continues in the surrounding code and on the invocation '
'stack.\n'
'[1]\n'
'object.\n'
'\n'
'If the evaluation of an expression in the header of an except '
'If no "except" clause matches the exception, the search for an\n'
'exception handler continues in the surrounding code and on the\n'
'invocation stack. [1]\n'
'\n'
'If the evaluation of an expression in the header of an "except" '
'clause\n'
'raises an exception, the original search for a handler is '
'canceled and\n'
@ -2436,24 +2460,24 @@
'raised\n'
'the exception).\n'
'\n'
'When a matching except clause is found, the exception is '
'When a matching "except" clause is found, the exception is '
'assigned to\n'
'the target specified after the "as" keyword in that except '
'clause, if\n'
'present, and the except clauses suite is executed. All except\n'
'clauses must have an executable block. When the end of this '
'the target specified after the "as" keyword in that "except" '
'clause,\n'
'if present, and the "except" clauses suite is executed. All '
'"except"\n'
'clauses must have an executable block. When the end of this '
'block is\n'
'reached, execution continues normally after the entire try '
'statement.\n'
'(This means that if two nested handlers exist for the same '
'exception,\n'
'and the exception occurs in the try clause of the inner handler, '
'the\n'
'outer handler will not handle the exception.)\n'
'reached, execution continues normally after the entire "try"\n'
'statement. (This means that if two nested handlers exist for the '
'same\n'
'exception, and the exception occurs in the "try" clause of the '
'inner\n'
'handler, the outer handler will not handle the exception.)\n'
'\n'
'When an exception has been assigned using "as target", it is '
'cleared\n'
'at the end of the except clause. This is as if\n'
'at the end of the "except" clause. This is as if\n'
'\n'
' except E as N:\n'
' foo\n'
@ -2468,7 +2492,7 @@
'\n'
'This means the exception must be assigned to a different name to '
'be\n'
'able to refer to it after the except clause. Exceptions are '
'able to refer to it after the "except" clause. Exceptions are '
'cleared\n'
'because with the traceback attached to them, they form a '
'reference\n'
@ -2476,7 +2500,8 @@
'alive\n'
'until the next garbage collection occurs.\n'
'\n'
'Before an except clauses suite is executed, details about the\n'
'Before an "except" clauses suite is executed, details about '
'the\n'
'exception are stored in the "sys" module and can be accessed '
'via\n'
'"sys.exc_info()". "sys.exc_info()" returns a 3-tuple consisting '
@ -2512,6 +2537,10 @@
' >>> print(sys.exc_info())\n'
' (None, None, None)\n'
'\n'
'\n'
'"except*" clause\n'
'----------------\n'
'\n'
'The "except*" clause(s) are used for handling "ExceptionGroup"s. '
'The\n'
'exception type for matching is interpreted as in the case of '
@ -2520,12 +2549,13 @@
'when\n'
'the type matches some of the exceptions in the group. This means '
'that\n'
'multiple except* clauses can execute, each handling part of the\n'
'multiple "except*" clauses can execute, each handling part of '
'the\n'
'exception group. Each clause executes once and handles an '
'exception\n'
'group of all matching exceptions. Each exception in the group '
'is\n'
'handled by at most one except* clause, the first that matches '
'handled by at most one "except*" clause, the first that matches '
'it.\n'
'\n'
' >>> try:\n'
@ -2548,22 +2578,26 @@
' +-+---------------- 1 ----------------\n'
' | ValueError: 1\n'
' +------------------------------------\n'
' >>>\n'
'\n'
' Any remaining exceptions that were not handled by any except* '
'clause\n'
' are re-raised at the end, combined into an exception group '
'along with\n'
' all exceptions that were raised from within except* clauses.\n'
' Any remaining exceptions that were not handled by any '
':keyword:`!except*`\n'
' clause are re-raised at the end, combined into an exception '
'group along with\n'
' all exceptions that were raised from within '
':keyword:`!except*` clauses.\n'
'\n'
' An except* clause must have a matching type, and this type '
'cannot be a\n'
' subclass of :exc:`BaseExceptionGroup`. It is not possible to '
'mix except\n'
' and except* in the same :keyword:`try`. :keyword:`break`,\n'
' :keyword:`continue` and :keyword:`return` cannot appear in an '
'except*\n'
' clause.\n'
' An :keyword:`!except*` clause must have a matching type,\n'
' and this type cannot be a subclass of '
':exc:`BaseExceptionGroup`.\n'
' It is not possible to mix :keyword:`except` and '
':keyword:`!except*`\n'
' in the same :keyword:`try`.\n'
' :keyword:`break`, :keyword:`continue` and :keyword:`return`\n'
' cannot appear in an :keyword:`!except*` clause.\n'
'\n'
'\n'
'"else" clause\n'
'-------------\n'
'\n'
'The optional "else" clause is executed if the control flow '
'leaves the\n'
@ -2573,6 +2607,10 @@
'are\n'
'not handled by the preceding "except" clauses.\n'
'\n'
'\n'
'"finally" clause\n'
'----------------\n'
'\n'
'If "finally" is present, it specifies a cleanup handler. The '
'"try"\n'
'clause is executed, including any "except" and "else" clauses. '
@ -2626,11 +2664,6 @@
' >>> foo()\n'
" 'finally'\n"
'\n'
'Additional information on exceptions can be found in section\n'
'Exceptions, and information on using the "raise" statement to '
'generate\n'
'exceptions may be found in section The raise statement.\n'
'\n'
'Changed in version 3.8: Prior to Python 3.8, a "continue" '
'statement\n'
'was illegal in the "finally" clause due to a problem with the\n'
@ -5540,9 +5573,10 @@
'\n'
' * "for" loop header,\n'
'\n'
' * after "as" in a "with" statement, "except" clause or in the '
'as-\n'
' pattern in structural pattern matching,\n'
' * after "as" in a "with" statement, "except" clause, '
'"except*"\n'
' clause, or in the as-pattern in structural pattern '
'matching,\n'
'\n'
' * in a capture pattern in structural pattern matching\n'
'\n'
@ -7657,9 +7691,8 @@
'\n'
' * "for" loop header,\n'
'\n'
' * after "as" in a "with" statement, "except" clause or in the '
'as-\n'
' pattern in structural pattern matching,\n'
' * after "as" in a "with" statement, "except" clause, "except*"\n'
' clause, or in the as-pattern in structural pattern matching,\n'
'\n'
' * in a capture pattern in structural pattern matching\n'
'\n'
@ -8232,8 +8265,9 @@
'the syntax is explicitly given, operators are binary. '
'Operators in\n'
'the same box group left to right (except for '
'exponentiation, which\n'
'groups from right to left).\n'
'exponentiation and\n'
'conditional expressions, which group from right to '
'left).\n'
'\n'
'Note that comparisons, membership tests, and identity '
'tests, all have\n'
@ -12500,31 +12534,39 @@
' try3_stmt ::= "try" ":" suite\n'
' "finally" ":" suite\n'
'\n'
'Additional information on exceptions can be found in section\n'
'Exceptions, and information on using the "raise" statement to '
'generate\n'
'exceptions may be found in section The raise statement.\n'
'\n'
'\n'
'"except" clause\n'
'===============\n'
'\n'
'The "except" clause(s) specify one or more exception handlers. When '
'no\n'
'exception occurs in the "try" clause, no exception handler is\n'
'executed. When an exception occurs in the "try" suite, a search for '
'an\n'
'exception handler is started. This search inspects the except '
'clauses\n'
'in turn until one is found that matches the exception. An '
'expression-\n'
'less except clause, if present, must be last; it matches any\n'
'exception. For an except clause with an expression, that expression\n'
'is evaluated, and the clause matches the exception if the resulting\n'
'object is “compatible” with the exception. An object is compatible\n'
'with an exception if the object is the class or a *non-virtual base\n'
'class* of the exception object, or a tuple containing an item that '
'is\n'
'the class or a non-virtual base class of the exception object.\n'
'exception handler is started. This search inspects the "except"\n'
'clauses in turn until one is found that matches the exception. An\n'
'expression-less "except" clause, if present, must be last; it '
'matches\n'
'any exception. For an "except" clause with an expression, that\n'
'expression is evaluated, and the clause matches the exception if the\n'
'resulting object is “compatible” with the exception. An object is\n'
'compatible with an exception if the object is the class or a *non-\n'
'virtual base class* of the exception object, or a tuple containing '
'an\n'
'item that is the class or a non-virtual base class of the exception\n'
'object.\n'
'\n'
'If no except clause matches the exception, the search for an '
'exception\n'
'handler continues in the surrounding code and on the invocation '
'stack.\n'
'[1]\n'
'If no "except" clause matches the exception, the search for an\n'
'exception handler continues in the surrounding code and on the\n'
'invocation stack. [1]\n'
'\n'
'If the evaluation of an expression in the header of an except clause\n'
'If the evaluation of an expression in the header of an "except" '
'clause\n'
'raises an exception, the original search for a handler is canceled '
'and\n'
'a search starts for the new exception in the surrounding code and on\n'
@ -12532,21 +12574,20 @@
'raised\n'
'the exception).\n'
'\n'
'When a matching except clause is found, the exception is assigned to\n'
'the target specified after the "as" keyword in that except clause, '
'if\n'
'present, and the except clauses suite is executed. All except\n'
'clauses must have an executable block. When the end of this block '
'is\n'
'reached, execution continues normally after the entire try '
'statement.\n'
'(This means that if two nested handlers exist for the same '
'exception,\n'
'and the exception occurs in the try clause of the inner handler, the\n'
'outer handler will not handle the exception.)\n'
'When a matching "except" clause is found, the exception is assigned '
'to\n'
'the target specified after the "as" keyword in that "except" clause,\n'
'if present, and the "except" clauses suite is executed. All '
'"except"\n'
'clauses must have an executable block. When the end of this block is\n'
'reached, execution continues normally after the entire "try"\n'
'statement. (This means that if two nested handlers exist for the '
'same\n'
'exception, and the exception occurs in the "try" clause of the inner\n'
'handler, the outer handler will not handle the exception.)\n'
'\n'
'When an exception has been assigned using "as target", it is cleared\n'
'at the end of the except clause. This is as if\n'
'at the end of the "except" clause. This is as if\n'
'\n'
' except E as N:\n'
' foo\n'
@ -12560,12 +12601,13 @@
' del N\n'
'\n'
'This means the exception must be assigned to a different name to be\n'
'able to refer to it after the except clause. Exceptions are cleared\n'
'able to refer to it after the "except" clause. Exceptions are '
'cleared\n'
'because with the traceback attached to them, they form a reference\n'
'cycle with the stack frame, keeping all locals in that frame alive\n'
'until the next garbage collection occurs.\n'
'\n'
'Before an except clauses suite is executed, details about the\n'
'Before an "except" clauses suite is executed, details about the\n'
'exception are stored in the "sys" module and can be accessed via\n'
'"sys.exc_info()". "sys.exc_info()" returns a 3-tuple consisting of '
'the\n'
@ -12597,16 +12639,20 @@
' >>> print(sys.exc_info())\n'
' (None, None, None)\n'
'\n'
'\n'
'"except*" clause\n'
'================\n'
'\n'
'The "except*" clause(s) are used for handling "ExceptionGroup"s. The\n'
'exception type for matching is interpreted as in the case of '
'"except",\n'
'but in the case of exception groups we can have partial matches when\n'
'the type matches some of the exceptions in the group. This means '
'that\n'
'multiple except* clauses can execute, each handling part of the\n'
'multiple "except*" clauses can execute, each handling part of the\n'
'exception group. Each clause executes once and handles an exception\n'
'group of all matching exceptions. Each exception in the group is\n'
'handled by at most one except* clause, the first that matches it.\n'
'handled by at most one "except*" clause, the first that matches it.\n'
'\n'
' >>> try:\n'
' ... raise ExceptionGroup("eg",\n'
@ -12626,22 +12672,25 @@
' +-+---------------- 1 ----------------\n'
' | ValueError: 1\n'
' +------------------------------------\n'
' >>>\n'
'\n'
' Any remaining exceptions that were not handled by any except* '
'clause\n'
' are re-raised at the end, combined into an exception group along '
'with\n'
' all exceptions that were raised from within except* clauses.\n'
' Any remaining exceptions that were not handled by any '
':keyword:`!except*`\n'
' clause are re-raised at the end, combined into an exception group '
'along with\n'
' all exceptions that were raised from within :keyword:`!except*` '
'clauses.\n'
'\n'
' An except* clause must have a matching type, and this type cannot '
'be a\n'
' subclass of :exc:`BaseExceptionGroup`. It is not possible to mix '
'except\n'
' and except* in the same :keyword:`try`. :keyword:`break`,\n'
' :keyword:`continue` and :keyword:`return` cannot appear in an '
'except*\n'
' clause.\n'
' An :keyword:`!except*` clause must have a matching type,\n'
' and this type cannot be a subclass of :exc:`BaseExceptionGroup`.\n'
' It is not possible to mix :keyword:`except` and '
':keyword:`!except*`\n'
' in the same :keyword:`try`.\n'
' :keyword:`break`, :keyword:`continue` and :keyword:`return`\n'
' cannot appear in an :keyword:`!except*` clause.\n'
'\n'
'\n'
'"else" clause\n'
'=============\n'
'\n'
'The optional "else" clause is executed if the control flow leaves '
'the\n'
@ -12650,6 +12699,10 @@
'"break" statement was executed. Exceptions in the "else" clause are\n'
'not handled by the preceding "except" clauses.\n'
'\n'
'\n'
'"finally" clause\n'
'================\n'
'\n'
'If "finally" is present, it specifies a cleanup handler. The '
'"try"\n'
'clause is executed, including any "except" and "else" clauses. If '
@ -12697,11 +12750,6 @@
' >>> foo()\n'
" 'finally'\n"
'\n'
'Additional information on exceptions can be found in section\n'
'Exceptions, and information on using the "raise" statement to '
'generate\n'
'exceptions may be found in section The raise statement.\n'
'\n'
'Changed in version 3.8: Prior to Python 3.8, a "continue" statement\n'
'was illegal in the "finally" clause due to a problem with the\n'
'implementation.\n',
@ -12901,7 +12949,7 @@
' points. All the code points in the range "U+0000 - '
'U+10FFFF"\n'
' can be represented in a string. Python doesnt have a '
'*char*\n'
'char\n'
' type; instead, every code point in the string is '
'represented\n'
' as a string object with length "1". The built-in '

View File

@ -326,5 +326,69 @@ def f():
gc.enable()
@support.cpython_only
def test_sneaky_frame_object(self):
def trace(frame, event, arg):
"""
Don't actually do anything, just force a frame object to be created.
"""
def callback(phase, info):
"""
Yo dawg, I heard you like frames, so I'm allocating a frame while
you're allocating a frame, so you can have a frame while you have a
frame!
"""
nonlocal sneaky_frame_object
sneaky_frame_object = sys._getframe().f_back
# We're done here:
gc.callbacks.remove(callback)
def f():
while True:
yield
old_threshold = gc.get_threshold()
old_callbacks = gc.callbacks[:]
old_enabled = gc.isenabled()
old_trace = sys.gettrace()
try:
# Stop the GC for a second while we set things up:
gc.disable()
# Create a paused generator:
g = f()
next(g)
# Move all objects to the oldest generation, and tell the GC to run
# on the *very next* allocation:
gc.collect()
gc.set_threshold(1, 0, 0)
# Okay, so here's the nightmare scenario:
# - We're tracing the resumption of a generator, which creates a new
# frame object.
# - The allocation of this frame object triggers a collection
# *before* the frame object is actually created.
# - During the collection, we request the exact same frame object.
# This test does it with a GC callback, but in real code it would
# likely be a trace function, weakref callback, or finalizer.
# - The collection finishes, and the original frame object is
# created. We now have two frame objects fighting over ownership
# of the same interpreter frame!
sys.settrace(trace)
gc.callbacks.append(callback)
sneaky_frame_object = None
gc.enable()
next(g)
# g.gi_frame should be the the frame object from the callback (the
# one that was *requested* second, but *created* first):
self.assertIs(g.gi_frame, sneaky_frame_object)
finally:
gc.set_threshold(*old_threshold)
gc.callbacks[:] = old_callbacks
sys.settrace(old_trace)
if old_enabled:
gc.enable()
if __name__ == "__main__":
unittest.main()

255
Misc/NEWS.d/3.11.0.rst Normal file
View File

@ -0,0 +1,255 @@
.. date: 2022-09-28-17-09-37
.. gh-issue: 97616
.. nonce: K1e3Xs
.. release date: 2022-10-24
.. section: Security
Fix multiplying a list by an integer (``list *= int``): detect the integer
overflow when the new allocated length is close to the maximum size. Issue
reported by Jordan Limor. Patch by Victor Stinner.
..
.. date: 2022-09-07-10-42-00
.. gh-issue: 97514
.. nonce: Yggdsl
.. section: Security
On Linux the :mod:`multiprocessing` module returns to using filesystem
backed unix domain sockets for communication with the *forkserver* process
instead of the Linux abstract socket namespace. Only code that chooses to
use the :ref:`"forkserver" start method <multiprocessing-start-methods>` is
affected.
Abstract sockets have no permissions and could allow any user on the system
in the same `network namespace
<https://man7.org/linux/man-pages/man7/network_namespaces.7.html>`_ (often
the whole system) to inject code into the multiprocessing *forkserver*
process. This was a potential privilege escalation. Filesystem based socket
permissions restrict this to the *forkserver* process user as was the
default in Python 3.8 and earlier.
This prevents Linux `CVE-2022-42919
<https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2022-42919>`_.
..
.. date: 2022-10-06-02-11-34
.. gh-issue: 97002
.. nonce: Zvsk71
.. section: Core and Builtins
Fix an issue where several frame objects could be backed by the same
interpreter frame, possibly leading to corrupted memory and hard crashes of
the interpreter.
..
.. date: 2022-10-03-13-35-48
.. gh-issue: 97752
.. nonce: 0xTjJY
.. section: Core and Builtins
Fix possible data corruption or crashes when accessing the ``f_back`` member
of newly-created generator or coroutine frames.
..
.. date: 2022-09-21-16-06-37
.. gh-issue: 96975
.. nonce: BmE0XY
.. section: Core and Builtins
Fix a crash occurring when :c:func:`PyEval_GetFrame` is called while the
topmost Python frame is in a partially-initialized state.
..
.. date: 2022-09-21-14-38-31
.. gh-issue: 96848
.. nonce: WuoLzU
.. section: Core and Builtins
Fix command line parsing: reject :option:`-X int_max_str_digits <-X>` option
with no value (invalid) when the :envvar:`PYTHONINTMAXSTRDIGITS` environment
variable is set to a valid limit. Patch by Victor Stinner.
..
.. date: 2022-09-18-08-47-40
.. gh-issue: 96821
.. nonce: Co2iOq
.. section: Core and Builtins
Fix undefined behaviour in ``_testcapimodule.c``.
..
.. date: 2022-09-16-19-02-40
.. gh-issue: 95778
.. nonce: cJmnst
.. section: Core and Builtins
When :exc:`ValueError` is raised if an integer is larger than the limit,
mention the :func:`sys.set_int_max_str_digits` function in the error
message. Patch by Victor Stinner.
..
.. date: 2022-09-05-19-20-44
.. gh-issue: 96587
.. nonce: bVxhX2
.. section: Core and Builtins
Correctly raise ``SyntaxError`` on exception groups (:pep:`654`) on python
versions prior to 3.11
..
.. bpo: 42316
.. date: 2020-11-15-02-08-43
.. nonce: LqdkWK
.. section: Core and Builtins
Document some places where an assignment expression needs parentheses.
..
.. date: 2022-10-16-15-31-50
.. gh-issue: 98331
.. nonce: Y5kPOX
.. section: Library
Update the bundled copies of pip and setuptools to versions 22.3 and 65.5.0
respectively.
..
.. date: 2022-10-06-23-42-00
.. gh-issue: 90985
.. nonce: s280JY
.. section: Library
Earlier in 3.11 we deprecated ``asyncio.Task.cancel("message")``. We
realized we were too harsh, and have undeprecated it.
..
.. date: 2022-09-25-23-24-52
.. gh-issue: 97545
.. nonce: HZLSNt
.. section: Library
Make Semaphore run faster.
..
.. date: 2022-09-24-18-56-23
.. gh-issue: 96865
.. nonce: o9WUkW
.. section: Library
fix Flag to use boundary CONFORM
This restores previous Flag behavior of allowing flags with non-sequential
values to be combined; e.g.
class Skip(Flag): TWO = 2 EIGHT = 8
Skip.TWO | Skip.EIGHT -> <Skip.TWO|EIGHT: 10>
..
.. date: 2022-05-25-15-57-39
.. gh-issue: 90155
.. nonce: YMstB5
.. section: Library
Fix broken :class:`asyncio.Semaphore` when acquire is cancelled.
..
.. date: 2022-10-02-10-58-52
.. gh-issue: 97741
.. nonce: 39l023
.. section: Documentation
Fix ``!`` in c domain ref target syntax via a ``conf.py`` patch, so it works
as intended to disable ref target resolution.
..
.. date: 2022-05-20-18-42-10
.. gh-issue: 93031
.. nonce: c2RdJe
.. section: Documentation
Update tutorial introduction output to use 3.10+ SyntaxError invalid range.
..
.. date: 2022-10-20-17-49-50
.. gh-issue: 95027
.. nonce: viRpJB
.. section: Tests
On Windows, when the Python test suite is run with the ``-jN`` option, the
ANSI code page is now used as the encoding for the stdout temporary file,
rather than using UTF-8 which can lead to decoding errors. Patch by Victor
Stinner.
..
.. date: 2022-09-11-14-23-49
.. gh-issue: 96729
.. nonce: W4uBWL
.. section: Build
Ensure that Windows releases built with ``Tools\msi\buildrelease.bat`` are
upgradable to and from official Python releases.
..
.. date: 2022-10-19-20-00-28
.. gh-issue: 98360
.. nonce: O2m6YG
.. section: Windows
Fixes :mod:`multiprocessing` spawning child processes on Windows from a
virtual environment to ensure that child processes that also use
:mod:`multiprocessing` to spawn more children will recognize that they are
in a virtual environment.
..
.. date: 2022-10-19-19-35-37
.. gh-issue: 98414
.. nonce: FbHZuS
.. section: Windows
Fix :file:`py.exe` launcher handling of ``-V:<company>/`` option when
default preferences have been set in environment variables or configuration
files.
..
.. date: 2022-09-29-23-08-49
.. gh-issue: 90989
.. nonce: no89Q2
.. section: Windows
Clarify some text in the Windows installer.
..
.. date: 2022-10-05-15-26-58
.. gh-issue: 97897
.. nonce: Rf-C6u
.. section: macOS
The macOS 13 SDK includes support for the ``mkfifoat`` and ``mknodat``
system calls. Using the ``dir_fd`` option with either :func:`os.mkfifo` or
:func:`os.mknod` could result in a segfault if cpython is built with the
macOS 13 SDK but run on an earlier version of macOS. Prevent this by adding
runtime support for detection of these system calls ("weaklinking") as is
done for other newer syscalls on macOS.

View File

@ -1,5 +1,5 @@
This is Python version 3.11.0 release candidate 2
=================================================
This is Python version 3.11.0
=============================
.. image:: https://github.com/python/cpython/workflows/Tests/badge.svg
:alt: CPython build status on GitHub Actions