Skip to content

Commit 94c4734

Browse files
authored
Merge branch 'main' into doc-py314-unpicklable
2 parents d435207 + 6f26d49 commit 94c4734

File tree

104 files changed

+2216
-933
lines changed

Some content is hidden

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

104 files changed

+2216
-933
lines changed

.github/workflows/build.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -536,6 +536,7 @@ jobs:
536536
needs:
537537
- check_source # Transitive dependency, needed to access `run_tests` value
538538
- check-docs
539+
- check_autoconf_regen
539540
- check_generated_files
540541
- build_macos
541542
- build_ubuntu
@@ -571,6 +572,7 @@ jobs:
571572
${{
572573
needs.check_source.outputs.run_tests != 'true'
573574
&& '
575+
check_autoconf_regen,
574576
check_generated_files,
575577
build_macos,
576578
build_ubuntu,

.github/workflows/posix-deps-apt.sh

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
11
#!/bin/sh
22
apt-get update
33

4-
# autoconf-archive is needed by autoreconf (check_generated_files job)
54
apt-get -yq install \
65
build-essential \
76
pkg-config \
8-
autoconf-archive \
97
ccache \
108
gdb \
119
lcov \

Doc/c-api/init.rst

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -625,7 +625,7 @@ Process-wide parameters
625625
returned string points into static storage; the caller should not modify its
626626
value. This corresponds to the :makevar:`prefix` variable in the top-level
627627
:file:`Makefile` and the :option:`--prefix` argument to the :program:`configure`
628-
script at build time. The value is available to Python code as ``sys.prefix``.
628+
script at build time. The value is available to Python code as ``sys.base_prefix``.
629629
It is only useful on Unix. See also the next function.
630630
631631
This function should not be called before :c:func:`Py_Initialize`, otherwise
@@ -635,7 +635,8 @@ Process-wide parameters
635635
It now returns ``NULL`` if called before :c:func:`Py_Initialize`.
636636
637637
.. deprecated-removed:: 3.13 3.15
638-
Get :data:`sys.prefix` instead.
638+
Get :data:`sys.base_prefix` instead, or :data:`sys.prefix` if
639+
:ref:`virtual environments <venv-def>` need to be handled.
639640
640641
641642
.. c:function:: wchar_t* Py_GetExecPrefix()
@@ -648,7 +649,8 @@ Process-wide parameters
648649
should not modify its value. This corresponds to the :makevar:`exec_prefix`
649650
variable in the top-level :file:`Makefile` and the ``--exec-prefix``
650651
argument to the :program:`configure` script at build time. The value is
651-
available to Python code as ``sys.exec_prefix``. It is only useful on Unix.
652+
available to Python code as ``sys.base_exec_prefix``. It is only useful on
653+
Unix.
652654
653655
Background: The exec-prefix differs from the prefix when platform dependent
654656
files (such as executables and shared libraries) are installed in a different
@@ -679,7 +681,8 @@ Process-wide parameters
679681
It now returns ``NULL`` if called before :c:func:`Py_Initialize`.
680682
681683
.. deprecated-removed:: 3.13 3.15
682-
Get :data:`sys.exec_prefix` instead.
684+
Get :data:`sys.base_exec_prefix` instead, or :data:`sys.exec_prefix` if
685+
:ref:`virtual environments <venv-def>` need to be handled.
683686
684687
685688
.. c:function:: wchar_t* Py_GetProgramFullPath()
@@ -2418,7 +2421,7 @@ Example usage::
24182421
24192422
In the above example, :c:macro:`Py_SETREF` calls :c:macro:`Py_DECREF`, which
24202423
can call arbitrary code through an object's deallocation function. The critical
2421-
section API avoids potentital deadlocks due to reentrancy and lock ordering
2424+
section API avoids potential deadlocks due to reentrancy and lock ordering
24222425
by allowing the runtime to temporarily suspend the critical section if the
24232426
code triggered by the finalizer blocks and calls :c:func:`PyEval_SaveThread`.
24242427

Doc/c-api/long.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -511,7 +511,7 @@ distinguished from a number. Use :c:func:`PyErr_Occurred` to disambiguate.
511511
free(bignum);
512512
513513
*flags* is either ``-1`` (``Py_ASNATIVEBYTES_DEFAULTS``) to select defaults
514-
that behave most like a C cast, or a combintation of the other flags in
514+
that behave most like a C cast, or a combination of the other flags in
515515
the table below.
516516
Note that ``-1`` cannot be combined with other flags.
517517

Doc/c-api/monitoring.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ would typically correspond to a python function.
147147
148148
The ``version`` argument is a pointer to a value which should be allocated
149149
by the user together with ``state_array`` and initialized to 0,
150-
and then set only by :c:func:`!PyMonitoring_EnterScope` itelf. It allows this
150+
and then set only by :c:func:`!PyMonitoring_EnterScope` itself. It allows this
151151
function to determine whether event states have changed since the previous call,
152152
and to return quickly if they have not.
153153

Doc/c-api/typeobj.rst

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -682,6 +682,19 @@ and :c:data:`PyType_Type` effectively act as defaults.)
682682
Py_DECREF(tp);
683683
}
684684
685+
.. warning::
686+
687+
In a garbage collected Python, :c:member:`!tp_dealloc` may be called from
688+
any Python thread, not just the thread which created the object (if the
689+
object becomes part of a refcount cycle, that cycle might be collected by
690+
a garbage collection on any thread). This is not a problem for Python
691+
API calls, since the thread on which :c:member:`!tp_dealloc` is called
692+
will own the Global Interpreter Lock (GIL). However, if the object being
693+
destroyed in turn destroys objects from some other C or C++ library, care
694+
should be taken to ensure that destroying those objects on the thread
695+
which called :c:member:`!tp_dealloc` will not violate any assumptions of
696+
the library.
697+
685698

686699
**Inheritance:**
687700

@@ -2109,17 +2122,6 @@ and :c:data:`PyType_Type` effectively act as defaults.)
21092122
PyErr_Restore(error_type, error_value, error_traceback);
21102123
}
21112124

2112-
Also, note that, in a garbage collected Python,
2113-
:c:member:`~PyTypeObject.tp_dealloc` may be called from
2114-
any Python thread, not just the thread which created the object (if the object
2115-
becomes part of a refcount cycle, that cycle might be collected by a garbage
2116-
collection on any thread). This is not a problem for Python API calls, since
2117-
the thread on which tp_dealloc is called will own the Global Interpreter Lock
2118-
(GIL). However, if the object being destroyed in turn destroys objects from some
2119-
other C or C++ library, care should be taken to ensure that destroying those
2120-
objects on the thread which called tp_dealloc will not violate any assumptions
2121-
of the library.
2122-
21232125
**Inheritance:**
21242126

21252127
This field is inherited by subtypes.

Doc/conf.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,8 @@
9494

9595
# Create table of contents entries for domain objects (e.g. functions, classes,
9696
# attributes, etc.). Default is True.
97-
toc_object_entries = False
97+
toc_object_entries = True
98+
toc_object_entries_show_parents = 'hide'
9899

99100
# Ignore any .rst files in the includes/ directory;
100101
# they're embedded in pages but not rendered individually.

Doc/deprecations/c-api-pending-removal-in-3.15.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,11 @@ Pending removal in Python 3.15
1313
* :c:func:`PySys_ResetWarnOptions`:
1414
Clear :data:`sys.warnoptions` and :data:`!warnings.filters` instead.
1515
* :c:func:`Py_GetExecPrefix`:
16-
Get :data:`sys.exec_prefix` instead.
16+
Get :data:`sys.base_exec_prefix` and :data:`sys.exec_prefix` instead.
1717
* :c:func:`Py_GetPath`:
1818
Get :data:`sys.path` instead.
1919
* :c:func:`Py_GetPrefix`:
20-
Get :data:`sys.prefix` instead.
20+
Get :data:`sys.base_prefix` and :data:`sys.prefix` instead.
2121
* :c:func:`Py_GetProgramFullPath`:
2222
Get :data:`sys.executable` instead.
2323
* :c:func:`Py_GetProgramName`:

Doc/deprecations/pending-removal-in-future.rst

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,6 @@ Pending removal in future versions
44
The following APIs will be removed in the future,
55
although there is currently no date scheduled for their removal.
66

7-
* :mod:`argparse`:
8-
9-
* Nesting argument groups and nesting mutually exclusive
10-
groups are deprecated.
11-
* Passing the undocumented keyword argument *prefix_chars* to
12-
:meth:`~argparse.ArgumentParser.add_argument_group` is now
13-
deprecated.
14-
15-
* :mod:`array`'s ``'u'`` format code (:gh:`57281`)
16-
177
* :mod:`builtins`:
188

199
* ``bool(NotImplemented)``.
@@ -43,6 +33,17 @@ although there is currently no date scheduled for their removal.
4333
as a single positional argument.
4434
(Contributed by Serhiy Storchaka in :gh:`109218`.)
4535

36+
* :mod:`argparse`:
37+
38+
* Nesting argument groups and nesting mutually exclusive
39+
groups are deprecated.
40+
* Passing the undocumented keyword argument *prefix_chars* to
41+
:meth:`~argparse.ArgumentParser.add_argument_group` is now
42+
deprecated.
43+
* The :class:`argparse.FileType` type converter is deprecated.
44+
45+
* :mod:`array`'s ``'u'`` format code (:gh:`57281`)
46+
4647
* :mod:`calendar`: ``calendar.January`` and ``calendar.February`` constants are
4748
deprecated and replaced by :data:`calendar.JANUARY` and
4849
:data:`calendar.FEBRUARY`.

Doc/library/argparse.rst

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -865,16 +865,14 @@ See also :ref:`specifying-ambiguous-arguments`. The supported values are:
865865
output files::
866866

867867
>>> parser = argparse.ArgumentParser()
868-
>>> parser.add_argument('infile', nargs='?', type=argparse.FileType('r'),
869-
... default=sys.stdin)
870-
>>> parser.add_argument('outfile', nargs='?', type=argparse.FileType('w'),
871-
... default=sys.stdout)
868+
>>> parser.add_argument('infile', nargs='?')
869+
>>> parser.add_argument('outfile', nargs='?')
872870
>>> parser.parse_args(['input.txt', 'output.txt'])
873-
Namespace(infile=<_io.TextIOWrapper name='input.txt' encoding='UTF-8'>,
874-
outfile=<_io.TextIOWrapper name='output.txt' encoding='UTF-8'>)
871+
Namespace(infile='input.txt', outfile='output.txt')
872+
>>> parser.parse_args(['input.txt'])
873+
Namespace(infile='input.txt', outfile=None)
875874
>>> parser.parse_args([])
876-
Namespace(infile=<_io.TextIOWrapper name='<stdin>' encoding='UTF-8'>,
877-
outfile=<_io.TextIOWrapper name='<stdout>' encoding='UTF-8'>)
875+
Namespace(infile=None, outfile=None)
878876

879877
.. index:: single: * (asterisk); in argparse module
880878

@@ -1033,7 +1031,6 @@ Common built-in types and functions can be used as type converters:
10331031
parser.add_argument('distance', type=float)
10341032
parser.add_argument('street', type=ascii)
10351033
parser.add_argument('code_point', type=ord)
1036-
parser.add_argument('dest_file', type=argparse.FileType('w', encoding='latin-1'))
10371034
parser.add_argument('datapath', type=pathlib.Path)
10381035

10391036
User defined functions can be used as well:
@@ -1827,9 +1824,19 @@ FileType objects
18271824
>>> parser.parse_args(['-'])
18281825
Namespace(infile=<_io.TextIOWrapper name='<stdin>' encoding='UTF-8'>)
18291826

1827+
.. note::
1828+
1829+
If one argument uses *FileType* and then a subsequent argument fails,
1830+
an error is reported but the file is not automatically closed.
1831+
This can also clobber the output files.
1832+
In this case, it would be better to wait until after the parser has
1833+
run and then use the :keyword:`with`-statement to manage the files.
1834+
18301835
.. versionchanged:: 3.4
18311836
Added the *encodings* and *errors* parameters.
18321837

1838+
.. deprecated:: 3.14
1839+
18331840

18341841
Argument groups
18351842
^^^^^^^^^^^^^^^

0 commit comments

Comments
 (0)