Skip to content

Commit 975f01a

Browse files
committed
Merge branch 'main' into tokenize-thread-safety
2 parents 117d256 + 0335662 commit 975f01a

Some content is hidden

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

63 files changed

+1614
-403
lines changed

.github/CODEOWNERS

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,7 @@ Doc/howto/clinic.rst @erlend-aasland
245245
**/*interpreteridobject.* @ericsnowcurrently
246246
**/*crossinterp* @ericsnowcurrently
247247
Lib/test/support/interpreters/ @ericsnowcurrently
248-
Modules/_xx*interp*module.c @ericsnowcurrently
248+
Modules/_interp*module.c @ericsnowcurrently
249249
Lib/test/test_interpreters/ @ericsnowcurrently
250250

251251
# Android

Doc/library/os.rst

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,10 @@ process and user.
193193
to the environment made after this time are not reflected in :data:`os.environ`,
194194
except for changes made by modifying :data:`os.environ` directly.
195195

196+
The :meth:`!os.environ.refresh()` method updates :data:`os.environ` with
197+
changes to the environment made by :func:`os.putenv`, by
198+
:func:`os.unsetenv`, or made outside Python in the same process.
199+
196200
This mapping may be used to modify the environment as well as query the
197201
environment. :func:`putenv` will be called automatically when the mapping
198202
is modified.
@@ -225,6 +229,9 @@ process and user.
225229
.. versionchanged:: 3.9
226230
Updated to support :pep:`584`'s merge (``|``) and update (``|=``) operators.
227231

232+
.. versionchanged:: 3.14
233+
Added the :meth:`!os.environ.refresh()` method.
234+
228235

229236
.. data:: environb
230237

@@ -561,6 +568,8 @@ process and user.
561568
of :data:`os.environ`. This also applies to :func:`getenv` and :func:`getenvb`, which
562569
respectively use :data:`os.environ` and :data:`os.environb` in their implementations.
563570

571+
See also the :data:`os.environ.refresh() <os.environ>` method.
572+
564573
.. note::
565574

566575
On some platforms, including FreeBSD and macOS, setting ``environ`` may
@@ -809,6 +818,8 @@ process and user.
809818
don't update :data:`os.environ`, so it is actually preferable to delete items of
810819
:data:`os.environ`.
811820

821+
See also the :data:`os.environ.refresh() <os.environ>` method.
822+
812823
.. audit-event:: os.unsetenv key os.unsetenv
813824

814825
.. versionchanged:: 3.9

Doc/library/xml.etree.elementtree.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -508,7 +508,7 @@ Functions
508508
`C14N 2.0 <https://www.w3.org/TR/xml-c14n2/>`_ transformation function.
509509

510510
Canonicalization is a way to normalise XML output in a way that allows
511-
byte-by-byte comparisons and digital signatures. It reduced the freedom
511+
byte-by-byte comparisons and digital signatures. It reduces the freedom
512512
that XML serializers have and instead generates a more constrained XML
513513
representation. The main restrictions regard the placement of namespace
514514
declarations, the ordering of attributes, and ignorable whitespace.

Doc/whatsnew/3.14.rst

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,13 @@ ast
9292
Added :func:`ast.compare` for comparing two ASTs.
9393
(Contributed by Batuhan Taskaya and Jeremy Hylton in :issue:`15987`.)
9494

95+
os
96+
--
97+
98+
* Added the :data:`os.environ.refresh() <os.environ>` method to update
99+
:data:`os.environ` with changes to the environment made by :func:`os.putenv`,
100+
by :func:`os.unsetenv`, or made outside Python in the same process.
101+
(Contributed by Victor Stinner in :gh:`120057`.)
95102

96103

97104
Optimizations

Include/internal/pycore_global_objects_fini_generated.h

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Include/internal/pycore_global_strings.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ struct _Py_global_strings {
4545
STRUCT_FOR_STR(dot, ".")
4646
STRUCT_FOR_STR(dot_locals, ".<locals>")
4747
STRUCT_FOR_STR(empty, "")
48+
STRUCT_FOR_STR(format, ".format")
4849
STRUCT_FOR_STR(generic_base, ".generic_base")
4950
STRUCT_FOR_STR(json_decoder, "json.decoder")
5051
STRUCT_FOR_STR(kwdefaults, ".kwdefaults")
@@ -234,7 +235,6 @@ struct _Py_global_strings {
234235
STRUCT_FOR_ID(_abstract_)
235236
STRUCT_FOR_ID(_active)
236237
STRUCT_FOR_ID(_align_)
237-
STRUCT_FOR_ID(_annotation)
238238
STRUCT_FOR_ID(_anonymous_)
239239
STRUCT_FOR_ID(_argtypes_)
240240
STRUCT_FOR_ID(_as_parameter_)

Include/internal/pycore_opcode_utils.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ extern "C" {
5757
#define MAKE_FUNCTION_KWDEFAULTS 0x02
5858
#define MAKE_FUNCTION_ANNOTATIONS 0x04
5959
#define MAKE_FUNCTION_CLOSURE 0x08
60+
#define MAKE_FUNCTION_ANNOTATE 0x10
6061

6162
/* Values used as the oparg for LOAD_COMMON_CONSTANT */
6263
#define CONSTANT_ASSERTIONERROR 0

Include/internal/pycore_runtime_init_generated.h

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Include/internal/pycore_symtable.h

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,9 @@ struct _mod; // Type defined in pycore_ast.h
1212

1313
typedef enum _block_type {
1414
FunctionBlock, ClassBlock, ModuleBlock,
15-
// Used for annotations if 'from __future__ import annotations' is active.
16-
// Annotation blocks cannot bind names and are not evaluated.
15+
// Used for annotations. If 'from __future__ import annotations' is active,
16+
// annotation blocks cannot bind names and are not evaluated. Otherwise, they
17+
// are lazily evaluated (see PEP 649).
1718
AnnotationBlock,
1819
// Used for generics and type aliases. These work mostly like functions
1920
// (see PEP 695 for details). The three different blocks function identically;
@@ -89,6 +90,7 @@ typedef struct _symtable_entry {
8990
including free refs to globals */
9091
unsigned ste_generator : 1; /* true if namespace is a generator */
9192
unsigned ste_coroutine : 1; /* true if namespace is a coroutine */
93+
unsigned ste_annotations_used : 1; /* true if there are any annotations in this scope */
9294
_Py_comprehension_ty ste_comprehension; /* Kind of comprehension (if any) */
9395
unsigned ste_varargs : 1; /* true if block has varargs */
9496
unsigned ste_varkeywords : 1; /* true if block has varkeywords */
@@ -110,6 +112,7 @@ typedef struct _symtable_entry {
110112
int ste_end_col_offset; /* end offset of first line of block */
111113
int ste_opt_lineno; /* lineno of last exec or import * */
112114
int ste_opt_col_offset; /* offset of last exec or import * */
115+
struct _symtable_entry *ste_annotation_block; /* symbol table entry for this entry's annotations */
113116
struct symtable *ste_table;
114117
} PySTEntryObject;
115118

@@ -126,6 +129,7 @@ extern struct symtable* _PySymtable_Build(
126129
PyObject *filename,
127130
_PyFutureFeatures *future);
128131
extern PySTEntryObject* _PySymtable_Lookup(struct symtable *, void *);
132+
extern int _PySymtable_LookupOptional(struct symtable *, void *, PySTEntryObject **);
129133

130134
extern void _PySymtable_Free(struct symtable *);
131135

Include/internal/pycore_unicodeobject_generated.h

Lines changed: 0 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

InternalDocs/README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ it is not, please report that through the
1212
[issue tracker](https://github.com/python/cpython/issues).
1313

1414

15+
[Compiler Design](compiler.md)
16+
1517
[Exception Handling](exception_handling.md)
1618

1719
[Adaptive Instruction Families](adaptive.md)

0 commit comments

Comments
 (0)