Skip to content

Commit 09e834c

Browse files
committed
Merge branch 'main' into gh-133371-handle-del-fast
2 parents 193c16c + 2bbcaed commit 09e834c

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+1494
-458
lines changed

.github/CODEOWNERS

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ Include/internal/pycore_time.h @pganssle @abalkin
188188

189189
# AST
190190
Python/ast.c @isidentical @JelleZijlstra @eclips4
191-
Python/ast_opt.c @isidentical @eclips4
191+
Python/ast_preprocess.c @isidentical @eclips4
192192
Parser/asdl.py @isidentical @JelleZijlstra @eclips4
193193
Parser/asdl_c.py @isidentical @JelleZijlstra @eclips4
194194
Lib/ast.py @isidentical @JelleZijlstra @eclips4

Doc/library/annotationlib.rst

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ Classes
132132

133133
Values are real annotation values (as per :attr:`Format.VALUE` format)
134134
for defined values, and :class:`ForwardRef` proxies for undefined
135-
values. Real objects may contain references to, :class:`ForwardRef`
135+
values. Real objects may contain references to :class:`ForwardRef`
136136
proxy objects.
137137

138138
.. attribute:: STRING
@@ -172,14 +172,21 @@ Classes
172172
:class:`~ForwardRef`. The string may not be exactly equivalent
173173
to the original source.
174174

175-
.. method:: evaluate(*, owner=None, globals=None, locals=None, type_params=None)
175+
.. method:: evaluate(*, owner=None, globals=None, locals=None, type_params=None, format=Format.VALUE)
176176

177177
Evaluate the forward reference, returning its value.
178178

179-
This may throw an exception, such as :exc:`NameError`, if the forward
179+
If the *format* argument is :attr:`~Format.VALUE` (the default),
180+
this method may throw an exception, such as :exc:`NameError`, if the forward
180181
reference refers to a name that cannot be resolved. The arguments to this
181182
method can be used to provide bindings for names that would otherwise
182-
be undefined.
183+
be undefined. If the *format* argument is :attr:`~Format.FORWARDREF`,
184+
the method will never throw an exception, but may return a :class:`~ForwardRef`
185+
instance. For example, if the forward reference object contains the code
186+
``list[undefined]``, where ``undefined`` is a name that is not defined,
187+
evaluating it with the :attr:`~Format.FORWARDREF` format will return
188+
``list[ForwardRef('undefined')]``. If the *format* argument is
189+
:attr:`~Format.STRING`, the method will return :attr:`~ForwardRef.__forward_arg__`.
183190

184191
The *owner* parameter provides the preferred mechanism for passing scope
185192
information to this method. The owner of a :class:`~ForwardRef` is the

Doc/library/subprocess.rst

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1525,6 +1525,24 @@ handling consistency are valid for these functions.
15251525
Notes
15261526
-----
15271527

1528+
.. _subprocess-timeout-behavior:
1529+
1530+
Timeout Behavior
1531+
^^^^^^^^^^^^^^^^
1532+
1533+
When using the ``timeout`` parameter in functions like :func:`run`,
1534+
:meth:`Popen.wait`, or :meth:`Popen.communicate`,
1535+
users should be aware of the following behaviors:
1536+
1537+
1. **Process Creation Delay**: The initial process creation itself cannot be interrupted
1538+
on many platform APIs. This means that even when specifying a timeout, you are not
1539+
guaranteed to see a timeout exception until at least after however long process
1540+
creation takes.
1541+
1542+
2. **Extremely Small Timeout Values**: Setting very small timeout values (such as a few
1543+
milliseconds) may result in almost immediate :exc:`TimeoutExpired` exceptions because
1544+
process creation and system scheduling inherently require time.
1545+
15281546
.. _converting-argument-sequence:
15291547

15301548
Converting an argument sequence to a string on Windows

Include/internal/pycore_compile.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,16 +34,16 @@ PyAPI_FUNC(PyCodeObject*) _PyAST_Compile(
3434
int optimize,
3535
struct _arena *arena);
3636

37-
/* AST optimizations */
38-
extern int _PyCompile_AstOptimize(
37+
/* AST preprocessing */
38+
extern int _PyCompile_AstPreprocess(
3939
struct _mod *mod,
4040
PyObject *filename,
4141
PyCompilerFlags *flags,
4242
int optimize,
4343
struct _arena *arena,
4444
int syntax_check_only);
4545

46-
extern int _PyAST_Optimize(
46+
extern int _PyAST_Preprocess(
4747
struct _mod *,
4848
struct _arena *arena,
4949
PyObject *filename,

InternalDocs/compiler.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -505,8 +505,8 @@ Important files
505505
* [Python/ast.c](../Python/ast.c):
506506
Used for validating the AST.
507507

508-
* [Python/ast_opt.c](../Python/ast_opt.c):
509-
Optimizes the AST.
508+
* [Python/ast_preprocess.c](../Python/ast_preprocess.c):
509+
Preprocesses the AST before compiling.
510510

511511
* [Python/ast_unparse.c](../Python/ast_unparse.c):
512512
Converts the AST expression node back into a string (for string annotations).

0 commit comments

Comments
 (0)