Skip to content

Commit 8008a58

Browse files
authored
Merge branch 'python:main' into fix_non_string_candidates_exit_repl
2 parents bd8115e + be2d218 commit 8008a58

File tree

238 files changed

+3966
-1878
lines changed

Some content is hidden

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

238 files changed

+3966
-1878
lines changed

.github/workflows/tail-call.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,8 +87,8 @@ jobs:
8787
set PlatformToolset=clangcl
8888
set LLVMToolsVersion=${{ matrix.llvm }}.1.5
8989
set LLVMInstallDir=C:\Program Files\LLVM
90-
./PCbuild/build.bat --tail-call-interp -d -p ${{ matrix.architecture }}
91-
./PCbuild/rt.bat -d -p ${{ matrix.architecture }} -q --multiprocess 0 --timeout 4500 --verbose2 --verbose3
90+
call ./PCbuild/build.bat --tail-call-interp -d -p ${{ matrix.architecture }}
91+
call ./PCbuild/rt.bat -d -p ${{ matrix.architecture }} -q --multiprocess 0 --timeout 4500 --verbose2 --verbose3
9292
9393
# No tests (yet):
9494
- name: Emulated Windows (release)

Doc/library/os.rst

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3693,16 +3693,16 @@ features:
36933693

36943694
This example displays the number of bytes taken by non-directory files in each
36953695
directory under the starting directory, except that it doesn't look under any
3696-
CVS subdirectory::
3696+
``__pycache__`` subdirectory::
36973697

36983698
import os
36993699
from os.path import join, getsize
3700-
for root, dirs, files in os.walk('python/Lib/email'):
3700+
for root, dirs, files in os.walk('python/Lib/xml'):
37013701
print(root, "consumes", end=" ")
37023702
print(sum(getsize(join(root, name)) for name in files), end=" ")
37033703
print("bytes in", len(files), "non-directory files")
3704-
if 'CVS' in dirs:
3705-
dirs.remove('CVS') # don't visit CVS directories
3704+
if '__pycache__' in dirs:
3705+
dirs.remove('__pycache__') # don't visit __pycache__ directories
37063706

37073707
In the next example (simple implementation of :func:`shutil.rmtree`),
37083708
walking the tree bottom-up is essential, :func:`rmdir` doesn't allow
@@ -3755,16 +3755,16 @@ features:
37553755

37563756
This example displays the number of bytes taken by non-directory files in each
37573757
directory under the starting directory, except that it doesn't look under any
3758-
CVS subdirectory::
3758+
``__pycache__`` subdirectory::
37593759

37603760
import os
3761-
for root, dirs, files, rootfd in os.fwalk('python/Lib/email'):
3761+
for root, dirs, files, rootfd in os.fwalk('python/Lib/xml'):
37623762
print(root, "consumes", end="")
37633763
print(sum([os.stat(name, dir_fd=rootfd).st_size for name in files]),
37643764
end="")
37653765
print("bytes in", len(files), "non-directory files")
3766-
if 'CVS' in dirs:
3767-
dirs.remove('CVS') # don't visit CVS directories
3766+
if '__pycache__' in dirs:
3767+
dirs.remove('__pycache__') # don't visit __pycache__ directories
37683768

37693769
In the next example, walking the tree bottom-up is essential:
37703770
:func:`rmdir` doesn't allow deleting a directory before the directory is

Doc/library/sys.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1247,6 +1247,9 @@ always available. Unless explicitly noted otherwise, all variables are read-only
12471247

12481248
.. versionadded:: 3.13
12491249

1250+
.. impl-detail::
1251+
1252+
It is not guaranteed to exist in all implementations of Python.
12501253

12511254
.. function:: is_finalizing()
12521255

Doc/library/uuid.rst

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -377,6 +377,13 @@ The following options are accepted:
377377
The name used as part of generating the uuid. Only required for
378378
:func:`uuid3` / :func:`uuid5` functions.
379379

380+
.. option:: -C <num>
381+
--count <num>
382+
383+
Generate *num* fresh UUIDs.
384+
385+
.. versionadded:: next
386+
380387

381388
.. _uuid-example:
382389

@@ -432,16 +439,18 @@ Here are some examples of typical usage of the :mod:`uuid` module::
432439
Command-Line Example
433440
--------------------
434441

435-
Here are some examples of typical usage of the :mod:`uuid` command line interface:
442+
Here are some examples of typical usage of the :mod:`uuid` command-line interface:
436443

437444
.. code-block:: shell
438445
439-
# generate a random uuid - by default uuid4() is used
446+
# generate a random UUID - by default uuid4() is used
440447
$ python -m uuid
441448
442-
# generate a uuid using uuid1()
449+
# generate a UUID using uuid1()
443450
$ python -m uuid -u uuid1
444451
445-
# generate a uuid using uuid5
452+
# generate a UUID using uuid5
446453
$ python -m uuid -u uuid5 -n @url -N example.com
447454
455+
# generate 42 random UUIDs
456+
$ python -m uuid -C 42

Doc/whatsnew/3.12.rst

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -811,6 +811,14 @@ pathlib
811811
:meth:`pathlib.Path.rglob` and :meth:`pathlib.PurePath.match` for matching
812812
the path's case sensitivity, allowing for more precise control over the matching process.
813813

814+
platform
815+
--------
816+
817+
* Add support for detecting Windows 11 and Windows Server releases past 2012.
818+
Previously, lookups on Windows Server platforms newer than Windows Server 2012
819+
and on Windows 11 would return ``Windows-10``.
820+
(Contributed by Steve Dower in :gh:`89545`.)
821+
814822
pdb
815823
---
816824

Doc/whatsnew/3.14.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1017,6 +1017,9 @@ uuid
10171017
Nil and Max UUID formats as defined by :rfc:`9562`.
10181018
(Contributed by Nick Pope in :gh:`128427`.)
10191019

1020+
* Allow to generate multiple UUIDs at once via :option:`python -m uuid --count <uuid --count>`.
1021+
(Contributed by Simon Legner in :gh:`131236`.)
1022+
10201023

10211024
zipinfo
10221025
-------

Include/cpython/tupleobject.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44

55
typedef struct {
66
PyObject_VAR_HEAD
7+
/* Cached hash. Initially set to -1. */
8+
Py_hash_t ob_hash;
79
/* ob_item contains space for 'ob_size' elements.
810
Items must normally not be NULL, except during construction when
911
the tuple is not yet visible outside the function that builds it. */

Include/internal/pycore_cell.h

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
#define Py_INTERNAL_CELL_H
33

44
#include "pycore_critical_section.h"
5+
#include "pycore_object.h"
6+
#include "pycore_stackref.h"
57

68
#ifdef __cplusplus
79
extern "C" {
@@ -19,7 +21,7 @@ PyCell_SwapTakeRef(PyCellObject *cell, PyObject *value)
1921
PyObject *old_value;
2022
Py_BEGIN_CRITICAL_SECTION(cell);
2123
old_value = cell->ob_ref;
22-
cell->ob_ref = value;
24+
FT_ATOMIC_STORE_PTR_RELEASE(cell->ob_ref, value);
2325
Py_END_CRITICAL_SECTION();
2426
return old_value;
2527
}
@@ -37,11 +39,36 @@ PyCell_GetRef(PyCellObject *cell)
3739
{
3840
PyObject *res;
3941
Py_BEGIN_CRITICAL_SECTION(cell);
42+
#ifdef Py_GIL_DISABLED
43+
res = _Py_XNewRefWithLock(cell->ob_ref);
44+
#else
4045
res = Py_XNewRef(cell->ob_ref);
46+
#endif
4147
Py_END_CRITICAL_SECTION();
4248
return res;
4349
}
4450

51+
static inline _PyStackRef
52+
_PyCell_GetStackRef(PyCellObject *cell)
53+
{
54+
PyObject *value;
55+
#ifdef Py_GIL_DISABLED
56+
value = _Py_atomic_load_ptr(&cell->ob_ref);
57+
if (value == NULL) {
58+
return PyStackRef_NULL;
59+
}
60+
_PyStackRef ref;
61+
if (_Py_TryIncrefCompareStackRef(&cell->ob_ref, value, &ref)) {
62+
return ref;
63+
}
64+
#endif
65+
value = PyCell_GetRef(cell);
66+
if (value == NULL) {
67+
return PyStackRef_NULL;
68+
}
69+
return PyStackRef_FromPyObjectSteal(value);
70+
}
71+
4572
#ifdef __cplusplus
4673
}
4774
#endif

Include/internal/pycore_compile.h

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,9 @@ void _PyCompile_ExitScope(struct _PyCompiler *c);
134134
Py_ssize_t _PyCompile_AddConst(struct _PyCompiler *c, PyObject *o);
135135
_PyInstructionSequence *_PyCompile_InstrSequence(struct _PyCompiler *c);
136136
int _PyCompile_FutureFeatures(struct _PyCompiler *c);
137-
PyObject *_PyCompile_DeferredAnnotations(struct _PyCompiler *c);
137+
void _PyCompile_DeferredAnnotations(
138+
struct _PyCompiler *c, PyObject **deferred_annotations,
139+
PyObject **conditional_annotation_indices);
138140
PyObject *_PyCompile_Mangle(struct _PyCompiler *c, PyObject *name);
139141
PyObject *_PyCompile_MaybeMangle(struct _PyCompiler *c, PyObject *name);
140142
int _PyCompile_MaybeAddStaticAttributeToClass(struct _PyCompiler *c, expr_ty e);
@@ -178,13 +180,16 @@ int _PyCompile_TweakInlinedComprehensionScopes(struct _PyCompiler *c, _Py_Source
178180
_PyCompile_InlinedComprehensionState *state);
179181
int _PyCompile_RevertInlinedComprehensionScopes(struct _PyCompiler *c, _Py_SourceLocation loc,
180182
_PyCompile_InlinedComprehensionState *state);
181-
int _PyCompile_AddDeferredAnnotaion(struct _PyCompiler *c, stmt_ty s);
183+
int _PyCompile_AddDeferredAnnotation(struct _PyCompiler *c, stmt_ty s,
184+
PyObject **conditional_annotation_index);
185+
void _PyCompile_EnterConditionalBlock(struct _PyCompiler *c);
186+
void _PyCompile_LeaveConditionalBlock(struct _PyCompiler *c);
182187

183188
int _PyCodegen_AddReturnAtEnd(struct _PyCompiler *c, int addNone);
184189
int _PyCodegen_EnterAnonymousScope(struct _PyCompiler* c, mod_ty mod);
185190
int _PyCodegen_Expression(struct _PyCompiler *c, expr_ty e);
186-
int _PyCodegen_Body(struct _PyCompiler *c, _Py_SourceLocation loc, asdl_stmt_seq *stmts,
187-
bool is_interactive);
191+
int _PyCodegen_Module(struct _PyCompiler *c, _Py_SourceLocation loc, asdl_stmt_seq *stmts,
192+
bool is_interactive);
188193

189194
int _PyCompile_ConstCacheMergeOne(PyObject *const_cache, PyObject **obj);
190195

Include/internal/pycore_dict.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,10 @@ extern int _PyDict_Pop_KnownHash(
150150
Py_hash_t hash,
151151
PyObject **result);
152152

153+
#ifdef Py_GIL_DISABLED
154+
PyAPI_FUNC(void) _PyDict_EnsureSharedOnRead(PyDictObject *mp);
155+
#endif
156+
153157
#define DKIX_EMPTY (-1)
154158
#define DKIX_DUMMY (-2) /* Used internally */
155159
#define DKIX_ERROR (-3)

0 commit comments

Comments
 (0)