Skip to content

Commit ea0bf20

Browse files
Merge branch 'main' into gh-100926-ctypes-pointers-cache
2 parents c1bf7cc + 425f60b commit ea0bf20

File tree

193 files changed

+2874
-1310
lines changed

Some content is hidden

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

193 files changed

+2874
-1310
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/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.14.rst

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

1026+
* Allow to generate multiple UUIDs at once via :option:`python -m uuid --count <uuid --count>`.
1027+
(Contributed by Simon Legner in :gh:`131236`.)
1028+
10261029

10271030
zipinfo
10281031
-------

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_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)

Include/internal/pycore_global_objects_fini_generated.h

Lines changed: 5 additions & 0 deletions
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: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ struct _Py_global_strings {
8989
STRUCT_FOR_ID(__bytes__)
9090
STRUCT_FOR_ID(__call__)
9191
STRUCT_FOR_ID(__cantrace__)
92+
STRUCT_FOR_ID(__ceil__)
9293
STRUCT_FOR_ID(__class__)
9394
STRUCT_FOR_ID(__class_getitem__)
9495
STRUCT_FOR_ID(__classcell__)
@@ -113,6 +114,7 @@ struct _Py_global_strings {
113114
STRUCT_FOR_ID(__file__)
114115
STRUCT_FOR_ID(__firstlineno__)
115116
STRUCT_FOR_ID(__float__)
117+
STRUCT_FOR_ID(__floor__)
116118
STRUCT_FOR_ID(__floordiv__)
117119
STRUCT_FOR_ID(__format__)
118120
STRUCT_FOR_ID(__fspath__)
@@ -218,6 +220,7 @@ struct _Py_global_strings {
218220
STRUCT_FOR_ID(__subclasscheck__)
219221
STRUCT_FOR_ID(__subclasshook__)
220222
STRUCT_FOR_ID(__truediv__)
223+
STRUCT_FOR_ID(__trunc__)
221224
STRUCT_FOR_ID(__type_params__)
222225
STRUCT_FOR_ID(__typing_is_unpacked_typevartuple__)
223226
STRUCT_FOR_ID(__typing_prepare_subst__)
@@ -280,7 +283,9 @@ struct _Py_global_strings {
280283
STRUCT_FOR_ID(aggregate_class)
281284
STRUCT_FOR_ID(alias)
282285
STRUCT_FOR_ID(align)
286+
STRUCT_FOR_ID(all)
283287
STRUCT_FOR_ID(allow_code)
288+
STRUCT_FOR_ID(any)
284289
STRUCT_FOR_ID(append)
285290
STRUCT_FOR_ID(arg)
286291
STRUCT_FOR_ID(argdefs)

Include/internal/pycore_interp_structs.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ extern "C" {
99

1010
#include "pycore_ast_state.h" // struct ast_state
1111
#include "pycore_llist.h" // struct llist_node
12+
#include "pycore_opcode_utils.h" // NUM_COMMON_CONSTANTS
1213
#include "pycore_pymath.h" // _PY_SHORT_FLOAT_REPR
1314
#include "pycore_structs.h" // PyHamtObject
1415
#include "pycore_tstate.h" // _PyThreadStateImpl
@@ -912,6 +913,7 @@ struct _is {
912913
struct ast_state ast;
913914
struct types_state types;
914915
struct callable_cache callable_cache;
916+
PyObject *common_consts[NUM_COMMON_CONSTANTS];
915917
bool jit;
916918
struct _PyExecutorObject *executor_list_head;
917919
size_t trace_run_counter;

Include/internal/pycore_interpframe.h

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -163,15 +163,17 @@ _PyFrame_GetLocalsArray(_PyInterpreterFrame *frame)
163163
return frame->localsplus;
164164
}
165165

166-
/* Fetches the stack pointer, and sets stackpointer to NULL.
167-
Having stackpointer == NULL ensures that invalid
168-
values are not visible to the cycle GC. */
166+
// Fetches the stack pointer, and (on debug builds) sets stackpointer to NULL.
167+
// Having stackpointer == NULL makes it easier to catch missing stack pointer
168+
// spills/restores (which could expose invalid values to the GC) using asserts.
169169
static inline _PyStackRef*
170170
_PyFrame_GetStackPointer(_PyInterpreterFrame *frame)
171171
{
172172
assert(frame->stackpointer != NULL);
173173
_PyStackRef *sp = frame->stackpointer;
174+
#ifndef NDEBUG
174175
frame->stackpointer = NULL;
176+
#endif
175177
return sp;
176178
}
177179

0 commit comments

Comments
 (0)