Skip to content

Commit

Permalink
Merge branch 'python:main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
diegorusso authored Jun 11, 2024
2 parents 68cf344 + 34e4d32 commit 89ef17c
Show file tree
Hide file tree
Showing 74 changed files with 1,747 additions and 417 deletions.
2 changes: 1 addition & 1 deletion .github/CODEOWNERS
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ Doc/howto/clinic.rst @erlend-aasland
**/*interpreteridobject.* @ericsnowcurrently
**/*crossinterp* @ericsnowcurrently
Lib/test/support/interpreters/ @ericsnowcurrently
Modules/_xx*interp*module.c @ericsnowcurrently
Modules/_interp*module.c @ericsnowcurrently
Lib/test/test_interpreters/ @ericsnowcurrently

# Android
Expand Down
11 changes: 11 additions & 0 deletions Doc/library/os.rst
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,10 @@ process and user.
to the environment made after this time are not reflected in :data:`os.environ`,
except for changes made by modifying :data:`os.environ` directly.

The :meth:`!os.environ.refresh()` method updates :data:`os.environ` with
changes to the environment made by :func:`os.putenv`, by
:func:`os.unsetenv`, or made outside Python in the same process.

This mapping may be used to modify the environment as well as query the
environment. :func:`putenv` will be called automatically when the mapping
is modified.
Expand Down Expand Up @@ -225,6 +229,9 @@ process and user.
.. versionchanged:: 3.9
Updated to support :pep:`584`'s merge (``|``) and update (``|=``) operators.

.. versionchanged:: 3.14
Added the :meth:`!os.environ.refresh()` method.


.. data:: environb

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

See also the :data:`os.environ.refresh() <os.environ>` method.

.. note::

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

See also the :data:`os.environ.refresh() <os.environ>` method.

.. audit-event:: os.unsetenv key os.unsetenv

.. versionchanged:: 3.9
Expand Down
2 changes: 1 addition & 1 deletion Doc/library/xml.etree.elementtree.rst
Original file line number Diff line number Diff line change
Expand Up @@ -508,7 +508,7 @@ Functions
`C14N 2.0 <https://www.w3.org/TR/xml-c14n2/>`_ transformation function.

Canonicalization is a way to normalise XML output in a way that allows
byte-by-byte comparisons and digital signatures. It reduced the freedom
byte-by-byte comparisons and digital signatures. It reduces the freedom
that XML serializers have and instead generates a more constrained XML
representation. The main restrictions regard the placement of namespace
declarations, the ordering of attributes, and ignorable whitespace.
Expand Down
7 changes: 7 additions & 0 deletions Doc/whatsnew/3.14.rst
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,13 @@ ast
Added :func:`ast.compare` for comparing two ASTs.
(Contributed by Batuhan Taskaya and Jeremy Hylton in :issue:`15987`.)

os
--

* Added the :data:`os.environ.refresh() <os.environ>` method to update
:data:`os.environ` with changes to the environment made by :func:`os.putenv`,
by :func:`os.unsetenv`, or made outside Python in the same process.
(Contributed by Victor Stinner in :gh:`120057`.)


Optimizations
Expand Down
4 changes: 4 additions & 0 deletions Include/Python.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,10 @@
# error "The limited API is not currently supported in the free-threaded build"
#endif

#if defined(Py_GIL_DISABLED) && defined(_MSC_VER)
# include <intrin.h> // __readgsqword()
#endif

// Include Python header files
#include "pyport.h"
#include "pymacro.h"
Expand Down
2 changes: 1 addition & 1 deletion Include/internal/pycore_global_objects_fini_generated.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Include/internal/pycore_global_strings.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ struct _Py_global_strings {
STRUCT_FOR_STR(dot, ".")
STRUCT_FOR_STR(dot_locals, ".<locals>")
STRUCT_FOR_STR(empty, "")
STRUCT_FOR_STR(format, ".format")
STRUCT_FOR_STR(generic_base, ".generic_base")
STRUCT_FOR_STR(json_decoder, "json.decoder")
STRUCT_FOR_STR(kwdefaults, ".kwdefaults")
Expand Down Expand Up @@ -234,7 +235,6 @@ struct _Py_global_strings {
STRUCT_FOR_ID(_abstract_)
STRUCT_FOR_ID(_active)
STRUCT_FOR_ID(_align_)
STRUCT_FOR_ID(_annotation)
STRUCT_FOR_ID(_anonymous_)
STRUCT_FOR_ID(_argtypes_)
STRUCT_FOR_ID(_as_parameter_)
Expand Down
1 change: 1 addition & 0 deletions Include/internal/pycore_opcode_utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ extern "C" {
#define MAKE_FUNCTION_KWDEFAULTS 0x02
#define MAKE_FUNCTION_ANNOTATIONS 0x04
#define MAKE_FUNCTION_CLOSURE 0x08
#define MAKE_FUNCTION_ANNOTATE 0x10

/* Values used as the oparg for LOAD_COMMON_CONSTANT */
#define CONSTANT_ASSERTIONERROR 0
Expand Down
2 changes: 1 addition & 1 deletion Include/internal/pycore_runtime_init_generated.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 6 additions & 2 deletions Include/internal/pycore_symtable.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,9 @@ struct _mod; // Type defined in pycore_ast.h

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

Expand All @@ -126,6 +129,7 @@ extern struct symtable* _PySymtable_Build(
PyObject *filename,
_PyFutureFeatures *future);
extern PySTEntryObject* _PySymtable_Lookup(struct symtable *, void *);
extern int _PySymtable_LookupOptional(struct symtable *, void *, PySTEntryObject **);

extern void _PySymtable_Free(struct symtable *);

Expand Down
3 changes: 0 additions & 3 deletions Include/internal/pycore_unicodeobject_generated.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions InternalDocs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ it is not, please report that through the
[issue tracker](/~https://github.com/python/cpython/issues).


[Compiler Design](compiler.md)

[Exception Handling](exception_handling.md)

[Adaptive Instruction Families](adaptive.md)
Loading

0 comments on commit 89ef17c

Please sign in to comment.