Skip to content

Commit d344c73

Browse files
authored
Merge branch 'main' into gh-130794-process-queue
2 parents 4fa53c7 + 80e6d3e commit d344c73

File tree

25 files changed

+763
-97
lines changed

25 files changed

+763
-97
lines changed

Doc/c-api/intro.rst

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,16 @@ familiar with writing an extension before attempting to embed Python in a real
3030
application.
3131

3232

33+
Language version compatibility
34+
==============================
35+
36+
Python's C API is compatible with C11 and C++11 versions of C and C++.
37+
38+
This is a lower limit: the C API does not require features from later
39+
C/C++ versions.
40+
You do *not* need to enable your compiler's "c11 mode".
41+
42+
3343
Coding standards
3444
================
3545

Doc/library/uuid.rst

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,10 @@
1111
--------------
1212

1313
This module provides immutable :class:`UUID` objects (the :class:`UUID` class)
14-
and the functions :func:`uuid1`, :func:`uuid3`, :func:`uuid4`, :func:`uuid5`,
15-
:func:`uuid6`, and :func:`uuid8` for generating version 1, 3, 4, 5, 6,
16-
and 8 UUIDs as specified in :rfc:`9562` (which supersedes :rfc:`4122`).
14+
and :ref:`functions <uuid-factory-functions>` for generating UUIDs corresponding
15+
to a specific UUID version as specified in :rfc:`9562` (which supersedes :rfc:`4122`),
16+
for example, :func:`uuid1` for UUID version 1, :func:`uuid3` for UUID version 3, and so on.
17+
Note that UUID version 2 is deliberately omitted as it is outside the scope of the RFC.
1718

1819
If all you want is a unique ID, you should probably call :func:`uuid1` or
1920
:func:`uuid4`. Note that :func:`uuid1` may compromise privacy since it creates
@@ -154,7 +155,7 @@ which relays any information about the UUID's safety, using this enumeration:
154155
:const:`RFC_4122`).
155156

156157
.. versionchanged:: next
157-
Added UUID versions 6 and 8.
158+
Added UUID versions 6, 7 and 8.
158159

159160

160161
.. attribute:: UUID.is_safe
@@ -185,6 +186,8 @@ The :mod:`uuid` module defines the following functions:
185186
globally unique, while the latter are not.
186187

187188

189+
.. _uuid-factory-functions:
190+
188191
.. function:: uuid1(node=None, clock_seq=None)
189192

190193
Generate a UUID from a host ID, sequence number, and the current time. If *node*
@@ -228,6 +231,18 @@ The :mod:`uuid` module defines the following functions:
228231
.. versionadded:: next
229232

230233

234+
.. function:: uuid7()
235+
236+
Generate a time-based UUID according to
237+
:rfc:`RFC 9562, §5.7 <9562#section-5.7>`.
238+
239+
For portability across platforms lacking sub-millisecond precision, UUIDs
240+
produced by this function embed a 48-bit timestamp and use a 42-bit counter
241+
to guarantee monotonicity within a millisecond.
242+
243+
.. versionadded:: next
244+
245+
231246
.. function:: uuid8(a=None, b=None, c=None)
232247

233248
Generate a pseudo-random UUID according to
@@ -330,7 +345,7 @@ The :mod:`uuid` module can be executed as a script from the command line.
330345

331346
.. code-block:: sh
332347
333-
python -m uuid [-h] [-u {uuid1,uuid3,uuid4,uuid5,uuid6,uuid8}] [-n NAMESPACE] [-N NAME]
348+
python -m uuid [-h] [-u {uuid1,uuid3,uuid4,uuid5,uuid6,uuid7,uuid8}] [-n NAMESPACE] [-N NAME]
334349
335350
The following options are accepted:
336351

@@ -347,7 +362,7 @@ The following options are accepted:
347362
is used.
348363

349364
.. versionchanged:: next
350-
Allow generating UUID versions 6 and 8.
365+
Allow generating UUID versions 6, 7 and 8.
351366

352367
.. option:: -n <namespace>
353368
--namespace <namespace>

Doc/whatsnew/3.14.rst

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -924,8 +924,9 @@ urllib
924924
uuid
925925
----
926926

927-
* Add support for UUID versions 6 and 8 via :func:`uuid.uuid6` and
928-
:func:`uuid.uuid8` respectively, as specified in :rfc:`9562`.
927+
* Add support for UUID versions 6, 7, and 8 via :func:`uuid.uuid6`,
928+
:func:`uuid.uuid7`, and :func:`uuid.uuid8` respectively, as specified
929+
in :rfc:`9562`.
929930
(Contributed by Bénédikt Tran in :gh:`89083`.)
930931

931932
* :const:`uuid.NIL` and :const:`uuid.MAX` are now available to represent the

Include/object.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -683,7 +683,7 @@ PyAPI_DATA(PyObject) _Py_NotImplementedStruct; /* Don't use this directly */
683683
typedef enum {
684684
PYGEN_RETURN = 0,
685685
PYGEN_ERROR = -1,
686-
PYGEN_NEXT = 1,
686+
PYGEN_NEXT = 1
687687
} PySendResult;
688688
#endif
689689

Lib/test/test_asyncio/test_base_events.py

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -233,20 +233,25 @@ def test_set_default_executor_error(self):
233233
self.assertIsNone(self.loop._default_executor)
234234

235235
def test_shutdown_default_executor_timeout(self):
236+
event = threading.Event()
237+
236238
class DummyExecutor(concurrent.futures.ThreadPoolExecutor):
237239
def shutdown(self, wait=True, *, cancel_futures=False):
238240
if wait:
239-
time.sleep(0.1)
241+
event.wait()
240242

241243
self.loop._process_events = mock.Mock()
242244
self.loop._write_to_self = mock.Mock()
243245
executor = DummyExecutor()
244246
self.loop.set_default_executor(executor)
245247

246-
with self.assertWarnsRegex(RuntimeWarning,
247-
"The executor did not finishing joining"):
248-
self.loop.run_until_complete(
249-
self.loop.shutdown_default_executor(timeout=0.01))
248+
try:
249+
with self.assertWarnsRegex(RuntimeWarning,
250+
"The executor did not finishing joining"):
251+
self.loop.run_until_complete(
252+
self.loop.shutdown_default_executor(timeout=0.01))
253+
finally:
254+
event.set()
250255

251256
def test_call_soon(self):
252257
def cb():

Lib/test/test_cext/__init__.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,9 @@ def test_build_c11(self):
3838

3939
@unittest.skipIf(support.MS_WINDOWS, "MSVC doesn't support /std:c99")
4040
def test_build_c99(self):
41+
# In public docs, we say C API is compatible with C11. However,
42+
# in practice we do maintain C99 compatibility in public headers.
43+
# Please ask the C API WG before adding a new C11-only feature.
4144
self.check_build('_test_c99_cext', std='c99')
4245

4346
@support.requires_gil_enabled('incompatible with Free Threading')

Lib/test/test_cext/extension.c

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,11 +58,24 @@ _testcext_exec(
5858
return 0;
5959
}
6060

61+
// Converting from function pointer to void* has undefined behavior, but
62+
// works on all known platforms, and CPython's module and type slots currently
63+
// need it.
64+
// (GCC doesn't have a narrower category for this than -Wpedantic.)
65+
_Py_COMP_DIAG_PUSH
66+
#if defined(__GNUC__)
67+
#pragma GCC diagnostic ignored "-Wpedantic"
68+
#elif defined(__clang__)
69+
#pragma clang diagnostic ignored "-Wpedantic"
70+
#endif
71+
6172
static PyModuleDef_Slot _testcext_slots[] = {
6273
{Py_mod_exec, (void*)_testcext_exec},
6374
{0, NULL}
6475
};
6576

77+
_Py_COMP_DIAG_POP
78+
6679

6780
PyDoc_STRVAR(_testcext_doc, "C test extension.");
6881

Lib/test/test_cext/setup.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@
2121

2222
# gh-120593: Check the 'const' qualifier
2323
'-Wcast-qual',
24+
25+
# Ask for strict(er) compliance with the standard
26+
'-pedantic-errors',
2427
]
2528
if not support.Py_GIL_DISABLED:
2629
CFLAGS.append(

Lib/test/test_cppext/__init__.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,15 @@ def test_build(self):
2929
self.check_build('_testcppext')
3030

3131
def test_build_cpp03(self):
32+
# In public docs, we say C API is compatible with C++11. However,
33+
# in practice we do maintain C++03 compatibility in public headers.
34+
# Please ask the C API WG before adding a new C++11-only feature.
3235
self.check_build('_testcpp03ext', std='c++03')
3336

37+
@support.requires_gil_enabled('incompatible with Free Threading')
38+
def test_build_limited_cpp03(self):
39+
self.check_build('_test_limited_cpp03ext', std='c++03', limited=True)
40+
3441
@unittest.skipIf(support.MS_WINDOWS, "MSVC doesn't support /std:c++11")
3542
def test_build_cpp11(self):
3643
self.check_build('_testcpp11ext', std='c++11')

Lib/test/test_cppext/extension.cpp

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,11 +161,24 @@ class VirtualPyObject : public PyObject {
161161

162162
int VirtualPyObject::instance_count = 0;
163163

164+
// Converting from function pointer to void* has undefined behavior, but
165+
// works on all known platforms, and CPython's module and type slots currently
166+
// need it.
167+
// (GCC doesn't have a narrower category for this than -Wpedantic.)
168+
_Py_COMP_DIAG_PUSH
169+
#if defined(__GNUC__)
170+
#pragma GCC diagnostic ignored "-Wpedantic"
171+
#elif defined(__clang__)
172+
#pragma clang diagnostic ignored "-Wpedantic"
173+
#endif
174+
164175
PyType_Slot VirtualPyObject_Slots[] = {
165176
{Py_tp_free, (void*)VirtualPyObject::dealloc},
166177
{0, _Py_NULL},
167178
};
168179

180+
_Py_COMP_DIAG_POP
181+
169182
PyType_Spec VirtualPyObject_Spec = {
170183
/* .name */ STR(MODULE_NAME) ".VirtualPyObject",
171184
/* .basicsize */ sizeof(VirtualPyObject),
@@ -241,11 +254,20 @@ _testcppext_exec(PyObject *module)
241254
return 0;
242255
}
243256

257+
// Need to ignore "-Wpedantic" warnings; see VirtualPyObject_Slots above
258+
_Py_COMP_DIAG_PUSH
259+
#if defined(__GNUC__)
260+
#pragma GCC diagnostic ignored "-Wpedantic"
261+
#elif defined(__clang__)
262+
#pragma clang diagnostic ignored "-Wpedantic"
263+
#endif
264+
244265
static PyModuleDef_Slot _testcppext_slots[] = {
245266
{Py_mod_exec, reinterpret_cast<void*>(_testcppext_exec)},
246267
{0, _Py_NULL}
247268
};
248269

270+
_Py_COMP_DIAG_POP
249271

250272
PyDoc_STRVAR(_testcppext_doc, "C++ test extension.");
251273

0 commit comments

Comments
 (0)