Skip to content

Commit ef53ea0

Browse files
committed
Merge branch 'main' into pythongh-101360-fix-match-partial-anchor
2 parents f7b879e + b5c4d60 commit ef53ea0

Some content is hidden

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

51 files changed

+1574
-531
lines changed

Doc/library/datetime.rst

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -982,12 +982,11 @@ Other constructors, all class methods:
982982
are equal to the given :class:`.time` object's. If the *tzinfo*
983983
argument is provided, its value is used to set the :attr:`.tzinfo` attribute
984984
of the result, otherwise the :attr:`~.time.tzinfo` attribute of the *time* argument
985-
is used.
985+
is used. If the *date* argument is a :class:`.datetime` object, its time components
986+
and :attr:`.tzinfo` attributes are ignored.
986987

987988
For any :class:`.datetime` object *d*,
988-
``d == datetime.combine(d.date(), d.time(), d.tzinfo)``. If date is a
989-
:class:`.datetime` object, its time components and :attr:`.tzinfo` attributes
990-
are ignored.
989+
``d == datetime.combine(d.date(), d.time(), d.tzinfo)``.
991990

992991
.. versionchanged:: 3.6
993992
Added the *tzinfo* argument.

Doc/library/logging.config.rst

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -525,6 +525,11 @@ returned by the call::
525525

526526
my.package.customFormatterFactory(bar='baz', spam=99.9, answer=42)
527527

528+
.. warning:: The values for keys such as ``bar``, ``spam`` and ``answer`` in
529+
the above example should not be configuration dictionaries or references such
530+
as ``cfg://foo`` or ``ext://bar``, because they will not be processed by the
531+
configuration machinery, but passed to the callable as-is.
532+
528533
The key ``'()'`` has been used as the special key because it is not a
529534
valid keyword parameter name, and so will not clash with the names of
530535
the keyword arguments used in the call. The ``'()'`` also serves as a
@@ -553,6 +558,34 @@ following configuration::
553558
the returned formatter will have attribute ``foo`` set to ``'bar'`` and
554559
attribute ``baz`` set to ``'bozz'``.
555560

561+
.. warning:: The values for attributes such as ``foo`` and ``baz`` in
562+
the above example should not be configuration dictionaries or references such
563+
as ``cfg://foo`` or ``ext://bar``, because they will not be processed by the
564+
configuration machinery, but set as attribute values as-is.
565+
566+
567+
.. _handler-config-dict-order:
568+
569+
Handler configuration order
570+
"""""""""""""""""""""""""""
571+
572+
Handlers are configured in alphabetical order of their keys, and a configured
573+
handler replaces the configuration dictionary in (a working copy of) the
574+
``handlers`` dictionary in the schema. If you use a construct such as
575+
``cfg://handlers.foo``, then initially ``handlers['foo']`` points to the
576+
configuration dictionary for the handler named ``foo``, and later (once that
577+
handler has been configured) it points to the configured handler instance.
578+
Thus, ``cfg://handlers.foo`` could resolve to either a dictionary or a handler
579+
instance. In general, it is wise to name handlers in a way such that dependent
580+
handlers are configured _after_ any handlers they depend on; that allows
581+
something like ``cfg://handlers.foo`` to be used in configuring a handler that
582+
depends on handler ``foo``. If that dependent handler were named ``bar``,
583+
problems would result, because the configuration of ``bar`` would be attempted
584+
before that of ``foo``, and ``foo`` would not yet have been configured.
585+
However, if the dependent handler were named ``foobar``, it would be configured
586+
after ``foo``, with the result that ``cfg://handlers.foo`` would resolve to
587+
configured handler ``foo``, and not its configuration dictionary.
588+
556589

557590
.. _logging-config-dict-externalobj:
558591

Doc/library/os.path.rst

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -488,6 +488,39 @@ the :mod:`glob` module.)
488488
Accepts a :term:`path-like object`.
489489

490490

491+
.. function:: splitroot(path)
492+
493+
Split the pathname *path* into a 3-item tuple ``(drive, root, tail)`` where
494+
*drive* is a device name or mount point, *root* is a string of separators
495+
after the drive, and *tail* is everything after the root. Any of these
496+
items may be the empty string. In all cases, ``drive + root + tail`` will
497+
be the same as *path*.
498+
499+
On POSIX systems, *drive* is always empty. The *root* may be empty (if *path* is
500+
relative), a single forward slash (if *path* is absolute), or two forward slashes
501+
(implementation-defined per `IEEE Std 1003.1-2017; 4.13 Pathname Resolution
502+
<https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap04.html#tag_04_13>`_.)
503+
For example::
504+
505+
>>> splitroot('/home/sam')
506+
('', '/', 'home/sam')
507+
>>> splitroot('//home/sam')
508+
('', '//', 'home/sam')
509+
>>> splitroot('///home/sam')
510+
('', '/', '//home/sam')
511+
512+
On Windows, *drive* may be empty, a drive-letter name, a UNC share, or a device
513+
name. The *root* may be empty, a forward slash, or a backward slash. For
514+
example::
515+
516+
>>> splitroot('C:/Users/Sam')
517+
('C:', '/', 'Users/Sam')
518+
>>> splitroot('//Server/Share/Users/Sam')
519+
('//Server/Share', '/', 'Users/Sam')
520+
521+
.. versionadded:: 3.12
522+
523+
491524
.. function:: splitext(path)
492525

493526
Split the pathname *path* into a pair ``(root, ext)`` such that ``root + ext ==

Doc/library/uuid.rst

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,7 @@ The :mod:`uuid` module can be executed as a script from the command line.
272272

273273
.. code-block:: sh
274274
275-
python -m uuid [-h] [-u {uuid1,uuid3,uuid4,uuid5}] [-ns NAMESPACE] [-n NAME]
275+
python -m uuid [-h] [-u {uuid1,uuid3,uuid4,uuid5}] [-n NAMESPACE] [-N NAME]
276276
277277
The following options are accepted:
278278

@@ -288,13 +288,14 @@ The following options are accepted:
288288
Specify the function name to use to generate the uuid. By default :func:`uuid4`
289289
is used.
290290

291-
.. cmdoption:: -ns <namespace>
291+
.. cmdoption:: -n <namespace>
292292
--namespace <namespace>
293293

294-
The namespace used as part of generating the uuid. Only required for
295-
:func:`uuid3` / :func:`uuid5` functions.
294+
The namespace is a ``UUID``, or ``@ns`` where ``ns`` is a well-known predefined UUID
295+
addressed by namespace name. Such as ``@dns``, ``@url``, ``@oid``, and ``@x500``.
296+
Only required for :func:`uuid3` / :func:`uuid5` functions.
296297

297-
.. cmdoption:: -n <name>
298+
.. cmdoption:: -N <name>
298299
--name <name>
299300

300301
The name used as part of generating the uuid. Only required for
@@ -351,12 +352,12 @@ Here are some examples of typical usage of the :mod:`uuid` command line interfac
351352

352353
.. code-block:: shell
353354
354-
# generate a random uuid - by default uuid4() is used
355-
$ python -m uuid
355+
# generate a random uuid - by default uuid4() is used
356+
$ python -m uuid
356357
357-
# generate a uuid using uuid1()
358-
$ python -m uuid -u uuid1
358+
# generate a uuid using uuid1()
359+
$ python -m uuid -u uuid1
359360
360-
# generate a uuid using uuid5
361-
$ python -m uuid -u uuid5 -ns NAMESPACE_URL -n example.com
361+
# generate a uuid using uuid5
362+
$ python -m uuid -u uuid5 -n @url -N example.com
362363

Doc/whatsnew/3.12.rst

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -288,13 +288,18 @@ os
288288
for a process with :func:`os.pidfd_open` in non-blocking mode.
289289
(Contributed by Kumar Aditya in :gh:`93312`.)
290290

291-
* Add :func:`os.path.isjunction` to check if a given path is a junction.
292-
(Contributed by Charles Machalow in :gh:`99547`.)
293-
294291
* :class:`os.DirEntry` now includes an :meth:`os.DirEntry.is_junction`
295292
method to check if the entry is a junction.
296293
(Contributed by Charles Machalow in :gh:`99547`.)
297294

295+
os.path
296+
-------
297+
298+
* Add :func:`os.path.isjunction` to check if a given path is a junction.
299+
(Contributed by Charles Machalow in :gh:`99547`.)
300+
301+
* Add :func:`os.path.splitroot` to split a path into a triad
302+
``(drive, root, tail)``. (Contributed by Barney Gale in :gh:`101000`.)
298303

299304
shutil
300305
------

Include/cpython/pytime.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,10 @@ functions and constants
5353
extern "C" {
5454
#endif
5555

56+
#ifdef __clang__
57+
struct timeval;
58+
#endif
59+
5660
/* _PyTime_t: Python timestamp with subsecond precision. It can be used to
5761
store a duration, and so indirectly a date (related to another date, like
5862
UNIX epoch). */

Include/internal/pycore_tracemalloc.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,13 @@ struct _PyTraceMalloc_Config {
3636

3737
/* Pack the frame_t structure to reduce the memory footprint on 64-bit
3838
architectures: 12 bytes instead of 16. */
39+
#if defined(_MSC_VER)
40+
#pragma pack(push, 4)
41+
#endif
42+
3943
struct
4044
#ifdef __GNUC__
4145
__attribute__((packed))
42-
#elif defined(_MSC_VER)
43-
#pragma pack(push, 4)
4446
#endif
4547
tracemalloc_frame {
4648
/* filename cannot be NULL: "<unknown>" is used if the Python frame

Lib/ctypes/wintypes.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# The most useful windows datatypes
22
import ctypes
33

4-
BYTE = ctypes.c_byte
4+
BYTE = ctypes.c_ubyte
55
WORD = ctypes.c_ushort
66
DWORD = ctypes.c_ulong
77

Lib/importlib/_bootstrap_external.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -423,14 +423,14 @@ def _write_atomic(path, data, mode=0o666):
423423
# Python 3.12a1 3507 (Set lineno of module's RESUME to 0)
424424
# Python 3.12a1 3508 (Add CLEANUP_THROW)
425425
# Python 3.12a1 3509 (Conditional jumps only jump forward)
426-
# Python 3.12a1 3510 (FOR_ITER leaves iterator on the stack)
427-
# Python 3.12a1 3511 (Add STOPITERATION_ERROR instruction)
428-
# Python 3.12a1 3512 (Remove all unused consts from code objects)
429-
# Python 3.12a1 3513 (Add CALL_INTRINSIC_1 instruction, removed STOPITERATION_ERROR, PRINT_EXPR, IMPORT_STAR)
430-
# Python 3.12a1 3514 (Remove ASYNC_GEN_WRAP, LIST_TO_TUPLE, and UNARY_POSITIVE)
431-
# Python 3.12a1 3515 (Embed jump mask in COMPARE_OP oparg)
432-
# Python 3.12a1 3516 (Add COMPARE_AND_BRANCH instruction)
433-
# Python 3.12a1 3517 (Change YIELD_VALUE oparg to exception block depth)
426+
# Python 3.12a2 3510 (FOR_ITER leaves iterator on the stack)
427+
# Python 3.12a2 3511 (Add STOPITERATION_ERROR instruction)
428+
# Python 3.12a2 3512 (Remove all unused consts from code objects)
429+
# Python 3.12a4 3513 (Add CALL_INTRINSIC_1 instruction, removed STOPITERATION_ERROR, PRINT_EXPR, IMPORT_STAR)
430+
# Python 3.12a4 3514 (Remove ASYNC_GEN_WRAP, LIST_TO_TUPLE, and UNARY_POSITIVE)
431+
# Python 3.12a5 3515 (Embed jump mask in COMPARE_OP oparg)
432+
# Python 3.12a5 3516 (Add COMPARE_AND_BRANCH instruction)
433+
# Python 3.12a5 3517 (Change YIELD_VALUE oparg to exception block depth)
434434

435435
# Python 3.13 will start with 3550
436436

0 commit comments

Comments
 (0)