Skip to content

Commit e275d46

Browse files
resolve merge conflict
2 parents 5aae0a0 + 9ce9020 commit e275d46

Some content is hidden

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

59 files changed

+776
-672
lines changed

Doc/Makefile

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -305,13 +305,15 @@ serve:
305305

306306
# for development releases: always build
307307
.PHONY: autobuild-dev
308+
autobuild-dev: DISTVERSION = $(shell $(PYTHON) tools/extensions/patchlevel.py --short)
308309
autobuild-dev:
309-
$(MAKE) dist-no-html SPHINXOPTS='$(SPHINXOPTS) -Ea -A daily=1'
310+
$(MAKE) dist-no-html SPHINXOPTS='$(SPHINXOPTS) -Ea -A daily=1' DISTVERSION=$(DISTVERSION)
310311

311312
# for HTML-only rebuilds
312313
.PHONY: autobuild-dev-html
314+
autobuild-dev-html: DISTVERSION = $(shell $(PYTHON) tools/extensions/patchlevel.py --short)
313315
autobuild-dev-html:
314-
$(MAKE) dist-html SPHINXOPTS='$(SPHINXOPTS) -Ea -A daily=1'
316+
$(MAKE) dist-html SPHINXOPTS='$(SPHINXOPTS) -Ea -A daily=1' DISTVERSION=$(DISTVERSION)
315317

316318
# for stable releases: only build if not in pre-release stage (alpha, beta)
317319
# release candidate downloads are okay, since the stable tree can be in that stage

Doc/library/argparse.rst

Lines changed: 47 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,32 @@ will figure out how to parse those out of :data:`sys.argv`. The :mod:`argparse`
2525
module also automatically generates help and usage messages. The module
2626
will also issue errors when users give the program invalid arguments.
2727

28+
<<<<<<< HEAD
29+
=======
30+
Quick Links for ArgumentParser
31+
---------------------------------------
32+
========================= =========================================================================================================== ==================================================================================
33+
Name Description Values
34+
========================= =========================================================================================================== ==================================================================================
35+
prog_ The name of the program
36+
usage_ The string describing the program usage
37+
description_ A brief description of what the program does
38+
epilog_ Additional description of the program after the argument help
39+
parents_ A list of :class:`ArgumentParser` objects whose arguments should also be included
40+
formatter_class_ A class for customizing the help output ``argparse.HelpFormatter``
41+
prefix_chars_ The set of characters that prefix optional arguments Defaults to ``'-'``
42+
fromfile_prefix_chars_ The set of characters that prefix files to read additional arguments from Defaults to ``None`` (meaning arguments will never be treated as file references)
43+
argument_default_ The global default value for arguments
44+
allow_abbrev_ Allows long options to be abbreviated if the abbreviation is unambiguous ``True`` or ``False`` (default: ``True``)
45+
conflict_handler_ The strategy for resolving conflicting optionals
46+
add_help_ Add a ``-h/--help`` option to the parser ``True`` or ``False`` (default: ``True``)
47+
exit_on_error_ Determines whether or not to exit with error info when an error occurs ``True`` or ``False`` (default: ``True``)
48+
========================= =========================================================================================================== ==================================================================================
49+
50+
Core Functionality
51+
------------------
52+
53+
>>>>>>> main
2854
The :mod:`argparse` module's support for command-line interfaces is built
2955
around an instance of :class:`argparse.ArgumentParser`. It is a container for
3056
argument specifications and has options that apply to the parser as whole::
@@ -67,8 +93,8 @@ ArgumentParser objects
6793
as keyword arguments. Each parameter has its own more detailed description
6894
below, but in short they are:
6995

70-
* prog_ - The name of the program (default:
71-
``os.path.basename(sys.argv[0])``)
96+
* prog_ - The name of the program (default: generated from the ``__main__``
97+
module attributes and ``sys.argv[0]``)
7298

7399
* usage_ - The string describing the program usage (default: generated from
74100
arguments added to parser)
@@ -121,15 +147,21 @@ The following sections describe how each of these are used.
121147
prog
122148
^^^^
123149

124-
By default, :class:`ArgumentParser` objects use the base name
125-
(see :func:`os.path.basename`) of ``sys.argv[0]`` to determine
126-
how to display the name of the program in help messages. This default is almost
127-
always desirable because it will make the help messages match the name that was
128-
used to invoke the program on the command line. However, to change this default
129-
behavior, another value can be supplied using the ``prog=`` argument to
130-
:class:`ArgumentParser`
131150

132-
::
151+
By default, :class:`ArgumentParser` calculates the name of the program
152+
to display in help messages depending on the way the Python interpreter was run:
153+
154+
* The :func:`base name <os.path.basename>` of ``sys.argv[0]`` if a file was
155+
passed as argument.
156+
* The Python interpreter name followed by ``sys.argv[0]`` if a directory or
157+
a zipfile was passed as argument.
158+
* The Python interpreter name followed by ``-m`` followed by the
159+
module or package name if the :option:`-m` option was used.
160+
161+
This default is almost always desirable because it will make the help messages
162+
match the string that was used to invoke the program on the command line.
163+
However, to change this default behavior, another value can be supplied using
164+
the ``prog=`` argument to :class:`ArgumentParser`::
133165

134166
>>> parser = argparse.ArgumentParser(prog='myprogram')
135167
>>> parser.print_help()
@@ -138,7 +170,8 @@ behavior, another value can be supplied using the ``prog=`` argument to
138170
options:
139171
-h, --help show this help message and exit
140172

141-
Note that the program name, whether determined from ``sys.argv[0]`` or from the
173+
Note that the program name, whether determined from ``sys.argv[0]``,
174+
from the ``__main__`` module attributes or from the
142175
``prog=`` argument, is available to help messages using the ``%(prog)s`` format
143176
specifier.
144177

@@ -153,6 +186,9 @@ specifier.
153186
-h, --help show this help message and exit
154187
--foo FOO foo of the myprogram program
155188

189+
.. versionchanged:: 3.14
190+
The default ``prog`` value now reflects how ``__main__`` was actually executed,
191+
rather than always being ``os.path.basename(sys.argv[0])``.
156192

157193
usage
158194
^^^^^

Doc/library/dataclasses.rst

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -399,7 +399,7 @@ Module contents
399399
:func:`!astuple` raises :exc:`TypeError` if *obj* is not a dataclass
400400
instance.
401401

402-
.. function:: make_dataclass(cls_name, fields, *, bases=(), namespace=None, init=True, repr=True, eq=True, order=False, unsafe_hash=False, frozen=False, match_args=True, kw_only=False, slots=False, weakref_slot=False, module=None)
402+
.. function:: make_dataclass(cls_name, fields, *, bases=(), namespace=None, init=True, repr=True, eq=True, order=False, unsafe_hash=False, frozen=False, match_args=True, kw_only=False, slots=False, weakref_slot=False, module=None, decorator=dataclass)
403403

404404
Creates a new dataclass with name *cls_name*, fields as defined
405405
in *fields*, base classes as given in *bases*, and initialized
@@ -415,6 +415,11 @@ Module contents
415415
of the dataclass is set to that value.
416416
By default, it is set to the module name of the caller.
417417

418+
The *decorator* parameter is a callable that will be used to create the dataclass.
419+
It should take the class object as a first argument and the same keyword arguments
420+
as :func:`@dataclass <dataclass>`. By default, the :func:`@dataclass <dataclass>`
421+
function is used.
422+
418423
This function is not strictly required, because any Python
419424
mechanism for creating a new class with :attr:`!__annotations__` can
420425
then apply the :func:`@dataclass <dataclass>` function to convert that class to
@@ -438,6 +443,9 @@ Module contents
438443
def add_one(self):
439444
return self.x + 1
440445

446+
.. versionadded:: 3.14
447+
Added the *decorator* parameter.
448+
441449
.. function:: replace(obj, /, **changes)
442450

443451
Creates a new object of the same type as *obj*, replacing

Doc/library/datetime.rst

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -295,6 +295,20 @@ Instance attributes (read-only):
295295

296296
Between 0 and 86,399 inclusive.
297297

298+
.. caution::
299+
300+
It is a somewhat common bug for code to unintentionally use this attribute
301+
when it is actually intended to get a :meth:`~timedelta.total_seconds`
302+
value instead:
303+
304+
.. doctest::
305+
306+
>>> from datetime import timedelta
307+
>>> duration = timedelta(seconds=11235813)
308+
>>> duration.days, duration.seconds
309+
(130, 3813)
310+
>>> duration.total_seconds()
311+
11235813.0
298312

299313
.. attribute:: timedelta.microseconds
300314

@@ -351,7 +365,7 @@ Supported operations:
351365
| | same value. (2) |
352366
+--------------------------------+-----------------------------------------------+
353367
| ``-t1`` | Equivalent to ``timedelta(-t1.days, |
354-
| | -t1.seconds*, -t1.microseconds)``, |
368+
| | -t1.seconds, -t1.microseconds)``, |
355369
| | and to ``t1 * -1``. (1)(4) |
356370
+--------------------------------+-----------------------------------------------+
357371
| ``abs(t)`` | Equivalent to ``+t`` when ``t.days >= 0``, |

Doc/library/sys.monitoring.rst

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -50,16 +50,14 @@ Registering and using tools
5050
*tool_id* must be in the range 0 to 5 inclusive.
5151
Raises a :exc:`ValueError` if *tool_id* is in use.
5252

53-
.. function:: free_tool_id(tool_id: int, /) -> None
53+
.. function:: clear_tool_id(tool_id: int, /) -> None
5454

55-
Should be called once a tool no longer requires *tool_id*.
55+
Unregister all events and callback functions associated with *tool_id*.
5656

57-
.. note::
57+
.. function:: free_tool_id(tool_id: int, /) -> None
5858

59-
:func:`free_tool_id` will not disable global or local events associated
60-
with *tool_id*, nor will it unregister any callback functions. This
61-
function is only intended to be used to notify the VM that the
62-
particular *tool_id* is no longer in use.
59+
Should be called once a tool no longer requires *tool_id*.
60+
Will call :func:`clear_tool_id` before releasing *tool_id*.
6361

6462
.. function:: get_tool(tool_id: int, /) -> str | None
6563

Doc/tools/extensions/patchlevel.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,4 +74,8 @@ def get_version_info():
7474

7575

7676
if __name__ == "__main__":
77-
print(format_version_info(get_header_version_info())[0])
77+
short_ver, full_ver = format_version_info(get_header_version_info())
78+
if sys.argv[1:2] == ["--short"]:
79+
print(short_ver)
80+
else:
81+
print(full_ver)

Doc/using/windows.rst

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,9 @@ available for application-local distributions.
2323

2424
As specified in :pep:`11`, a Python release only supports a Windows platform
2525
while Microsoft considers the platform under extended support. This means that
26-
Python |version| supports Windows 8.1 and newer. If you require Windows 7
27-
support, please install Python 3.8.
26+
Python |version| supports Windows 10 and newer. If you require Windows 7
27+
support, please install Python 3.8. If you require Windows 8.1 support,
28+
please install Python 3.12.
2829

2930
There are a number of different installers available for Windows, each with
3031
certain benefits and downsides.

Doc/whatsnew/3.13.rst

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@
4646
when researching a change.
4747
4848
This article explains the new features in Python 3.13, compared to 3.12.
49-
Python 3.13 will be released on October 1, 2024.
49+
Python 3.13 will be released on October 7, 2024.
5050
For full details, see the :ref:`changelog <changelog>`.
5151

5252
.. seealso::
@@ -320,12 +320,9 @@ The free-threaded mode requires a different executable,
320320
usually called ``python3.13t`` or ``python3.13t.exe``.
321321
Pre-built binaries marked as *free-threaded* can be installed as part of
322322
the official :ref:`Windows <install-freethreaded-windows>`
323-
and :ref:`macOS <getting-and-installing-macpython>` installers,
323+
and :ref:`macOS <install-freethreaded-macos>` installers,
324324
or CPython can be built from source with the :option:`--disable-gil` option.
325325

326-
.. better macOS link pending
327-
https://github.com/python/cpython/issues/109975#issuecomment-2286391179
328-
329326
Free-threaded execution allows for full utilization of the available
330327
processing power by running threads in parallel on available CPU cores.
331328
While not all software will benefit from this automatically, programs

Doc/whatsnew/3.14.rst

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,13 @@ New Modules
202202
Improved Modules
203203
================
204204

205+
argparse
206+
--------
207+
208+
* The default value of the :ref:`program name <prog>` for
209+
:class:`argparse.ArgumentParser` now reflects the way the Python
210+
interpreter was instructed to find the ``__main__`` module code.
211+
(Contributed by Serhiy Storchaka and Alyssa Coghlan in :gh:`66436`.)
205212

206213
ast
207214
---

Include/cpython/code.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
extern "C" {
99
#endif
1010

11+
/* Total tool ids available */
12+
#define _PY_MONITORING_TOOL_IDS 8
1113
/* Count of all local monitoring events */
1214
#define _PY_MONITORING_LOCAL_EVENTS 10
1315
/* Count of all "real" monitoring events (not derived from other events) */
@@ -57,6 +59,8 @@ typedef struct {
5759
_Py_LocalMonitors active_monitors;
5860
/* The tools that are to be notified for events for the matching code unit */
5961
uint8_t *tools;
62+
/* The version of tools when they instrument the code */
63+
uintptr_t tool_versions[_PY_MONITORING_TOOL_IDS];
6064
/* Information to support line events */
6165
_PyCoLineInstrumentationData *lines;
6266
/* The tools that are to be notified for line events for the matching code unit */

0 commit comments

Comments
 (0)