Skip to content

Commit f27d4a7

Browse files
authored
Merge branch 'main' into warnings-as-error-2
2 parents a656a68 + 151d1bf commit f27d4a7

Some content is hidden

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

45 files changed

+950
-839
lines changed

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/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_global_objects_fini_generated.h

Lines changed: 3 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: 3 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__)

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

Include/internal/pycore_object.h

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -891,6 +891,12 @@ extern bool _PyObject_TryGetInstanceAttribute(PyObject *obj, PyObject *name,
891891
extern PyObject *_PyType_LookupRefAndVersion(PyTypeObject *, PyObject *,
892892
unsigned int *);
893893

894+
// Internal API to look for a name through the MRO.
895+
// This stores a stack reference in out and returns the value of
896+
// type->tp_version or zero if name is missing. It doesn't set an exception!
897+
extern unsigned int
898+
_PyType_LookupStackRefAndVersion(PyTypeObject *type, PyObject *name, _PyStackRef *out);
899+
894900
// Cache the provided init method in the specialization cache of type if the
895901
// provided type version matches the current version of the type.
896902
//
@@ -946,6 +952,14 @@ extern int _PyObject_IsInstanceDictEmpty(PyObject *);
946952
PyAPI_FUNC(PyObject*) _PyObject_LookupSpecial(PyObject *, PyObject *);
947953
PyAPI_FUNC(PyObject*) _PyObject_LookupSpecialMethod(PyObject *self, PyObject *attr, PyObject **self_or_null);
948954

955+
// Calls the method named `attr` on `self`, but does not set an exception if
956+
// the attribute does not exist.
957+
PyAPI_FUNC(PyObject *)
958+
_PyObject_MaybeCallSpecialNoArgs(PyObject *self, PyObject *attr);
959+
960+
PyAPI_FUNC(PyObject *)
961+
_PyObject_MaybeCallSpecialOneArg(PyObject *self, PyObject *attr, PyObject *arg);
962+
949963
extern int _PyObject_IsAbstract(PyObject *);
950964

951965
PyAPI_FUNC(int) _PyObject_GetMethod(PyObject *obj, PyObject *name, PyObject **method);

Include/internal/pycore_opcode_metadata.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_runtime_init_generated.h

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

0 commit comments

Comments
 (0)