Skip to content

Commit 5ef16ca

Browse files
Merge branch 'main' into df-compile-surrogatedoc
2 parents eeb1ceb + c90863a commit 5ef16ca

File tree

213 files changed

+23964
-4090
lines changed

Some content is hidden

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

213 files changed

+23964
-4090
lines changed

Doc/c-api/import.rst

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -129,8 +129,7 @@ Importing Modules
129129
of :class:`~importlib.machinery.SourceFileLoader` otherwise.
130130
131131
The module's :attr:`~module.__file__` attribute will be set to the code
132-
object's :attr:`~codeobject.co_filename`. If applicable,
133-
:attr:`~module.__cached__` will also be set.
132+
object's :attr:`~codeobject.co_filename`.
134133
135134
This function will reload the module if it was already imported. See
136135
:c:func:`PyImport_ReloadModule` for the intended way to reload a module.
@@ -142,10 +141,13 @@ Importing Modules
142141
:c:func:`PyImport_ExecCodeModuleWithPathnames`.
143142
144143
.. versionchanged:: 3.12
145-
The setting of :attr:`~module.__cached__` and :attr:`~module.__loader__`
144+
The setting of ``__cached__`` and :attr:`~module.__loader__`
146145
is deprecated. See :class:`~importlib.machinery.ModuleSpec` for
147146
alternatives.
148147
148+
.. versionchanged:: 3.15
149+
``__cached__`` is no longer set.
150+
149151
150152
.. c:function:: PyObject* PyImport_ExecCodeModuleEx(const char *name, PyObject *co, const char *pathname)
151153
@@ -157,16 +159,19 @@ Importing Modules
157159
158160
.. c:function:: PyObject* PyImport_ExecCodeModuleObject(PyObject *name, PyObject *co, PyObject *pathname, PyObject *cpathname)
159161
160-
Like :c:func:`PyImport_ExecCodeModuleEx`, but the :attr:`~module.__cached__`
161-
attribute of the module object is set to *cpathname* if it is
162-
non-``NULL``. Of the three functions, this is the preferred one to use.
162+
Like :c:func:`PyImport_ExecCodeModuleEx`, but the path to any compiled file
163+
via *cpathname* is used appropriately when non-``NULL``. Of the three
164+
functions, this is the preferred one to use.
163165
164166
.. versionadded:: 3.3
165167
166168
.. versionchanged:: 3.12
167-
Setting :attr:`~module.__cached__` is deprecated. See
169+
Setting ``__cached__`` is deprecated. See
168170
:class:`~importlib.machinery.ModuleSpec` for alternatives.
169171
172+
.. versionchanged:: 3.15
173+
``__cached__`` no longer set.
174+
170175
171176
.. c:function:: PyObject* PyImport_ExecCodeModuleWithPathnames(const char *name, PyObject *co, const char *pathname, const char *cpathname)
172177

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,13 @@
11
Pending removal in Python 3.20
22
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
33

4+
* :c:func:`!_PyObject_CallMethodId`, :c:func:`!_PyObject_GetAttrId` and
5+
:c:func:`!_PyUnicode_FromId` are deprecated since 3.15 and will be removed in
6+
3.20. Instead, use :c:func:`PyUnicode_FromString()` and cache the result in
7+
the module state, then call :c:func:`PyObject_CallMethod` or
8+
:c:func:`PyObject_GetAttr`.
9+
(Contributed by Victor Stinner in :gh:`141049`.)
10+
411
* The ``cval`` field in :c:type:`PyComplexObject` (:gh:`128813`).
512
Use :c:func:`PyComplex_AsCComplex` and :c:func:`PyComplex_FromCComplex`
613
to convert a Python complex number to/from the C :c:type:`Py_complex`

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@ Pending removal in Python 3.15
33

44
* The import system:
55

6-
* Setting :attr:`~module.__cached__` on a module while
6+
* Setting ``__cached__`` on a module while
77
failing to set :attr:`__spec__.cached <importlib.machinery.ModuleSpec.cached>`
8-
is deprecated. In Python 3.15, :attr:`!__cached__` will cease to be set or
8+
is deprecated. In Python 3.15, ``__cached__`` will cease to be set or
99
take into consideration by the import system or standard library. (:gh:`97879`)
1010

1111
* Setting :attr:`~module.__package__` on a module while

Doc/howto/gdb_helpers.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ enabled::
136136
at Objects/unicodeobject.c:551
137137
#7 0x0000000000440d94 in PyUnicodeUCS2_FromString (u=0x5c2b8d "__lltrace__") at Objects/unicodeobject.c:569
138138
#8 0x0000000000584abd in PyDict_GetItemString (v=
139-
{'Yuck': <type at remote 0xad4730>, '__builtins__': <module at remote 0x7ffff7fd5ee8>, '__file__': 'Lib/test/crashers/nasty_eq_vs_dict.py', '__package__': None, 'y': <Yuck(i=0) at remote 0xaacd80>, 'dict': {0: 0, 1: 1, 2: 2, 3: 3}, '__cached__': None, '__name__': '__main__', 'z': <Yuck(i=0) at remote 0xaace60>, '__doc__': None}, key=
139+
{'Yuck': <type at remote 0xad4730>, '__builtins__': <module at remote 0x7ffff7fd5ee8>, '__file__': 'Lib/test/crashers/nasty_eq_vs_dict.py', '__package__': None, 'y': <Yuck(i=0) at remote 0xaacd80>, 'dict': {0: 0, 1: 1, 2: 2, 3: 3}, '__name__': '__main__', 'z': <Yuck(i=0) at remote 0xaace60>, '__doc__': None}, key=
140140
0x5c2b8d "__lltrace__") at Objects/dictobject.c:2171
141141

142142
Notice how the dictionary argument to ``PyDict_GetItemString`` is displayed

Doc/library/argparse.rst

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -645,6 +645,27 @@ are set.
645645

646646
.. versionadded:: 3.14
647647

648+
To highlight inline code in your description or epilog text, you can use
649+
backticks::
650+
651+
>>> parser = argparse.ArgumentParser(
652+
... formatter_class=argparse.RawDescriptionHelpFormatter,
653+
... epilog='''Examples:
654+
... `python -m myapp --verbose`
655+
... `python -m myapp --config settings.json`
656+
... ''')
657+
658+
When colors are enabled, the text inside backticks will be displayed in a
659+
distinct color to help examples stand out. When colors are disabled, backticks
660+
are preserved as-is, which is readable in plain text.
661+
662+
.. note::
663+
664+
Backtick markup only applies to description and epilog text. It does not
665+
apply to individual argument ``help`` strings.
666+
667+
.. versionadded:: 3.15
668+
648669

649670
The add_argument() method
650671
-------------------------
@@ -1679,7 +1700,7 @@ The Namespace object
16791700
Other utilities
16801701
---------------
16811702

1682-
Sub-commands
1703+
Subcommands
16831704
^^^^^^^^^^^^
16841705

16851706
.. method:: ArgumentParser.add_subparsers(*, [title], [description], [prog], \
@@ -1708,7 +1729,7 @@ Sub-commands
17081729
* *description* - description for the sub-parser group in help output, by
17091730
default ``None``
17101731

1711-
* *prog* - usage information that will be displayed with sub-command help,
1732+
* *prog* - usage information that will be displayed with subcommand help,
17121733
by default the name of the program and any positional arguments before the
17131734
subparser argument
17141735

@@ -1718,7 +1739,7 @@ Sub-commands
17181739
* action_ - the basic type of action to be taken when this argument is
17191740
encountered at the command line
17201741

1721-
* dest_ - name of the attribute under which sub-command name will be
1742+
* dest_ - name of the attribute under which subcommand name will be
17221743
stored; by default ``None`` and no value is stored
17231744

17241745
* required_ - Whether or not a subcommand must be provided, by default

Doc/library/functions.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -526,7 +526,7 @@ are always available. They are listed here in alphabetical order.
526526
>>> dir() # show the names in the module namespace # doctest: +SKIP
527527
['__builtins__', '__name__', 'struct']
528528
>>> dir(struct) # show the names in the struct module # doctest: +SKIP
529-
['Struct', '__all__', '__builtins__', '__cached__', '__doc__', '__file__',
529+
['Struct', '__all__', '__builtins__', '__doc__', '__file__',
530530
'__initializing__', '__loader__', '__name__', '__package__',
531531
'_clearcache', 'calcsize', 'error', 'pack', 'pack_into',
532532
'unpack', 'unpack_from']

Doc/library/importlib.rst

Lines changed: 26 additions & 89 deletions
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,12 @@ Functions
210210
:exc:`ModuleNotFoundError` is raised when the module being reloaded lacks
211211
a :class:`~importlib.machinery.ModuleSpec`.
212212

213+
.. versionchanged:: next
214+
If *module* is a lazy module that has not yet been materialized (i.e.,
215+
loaded via :class:`importlib.util.LazyLoader` and not yet accessed),
216+
calling :func:`reload` is a no-op and returns the module unchanged.
217+
This prevents the reload from unintentionally triggering the lazy load.
218+
213219
.. warning::
214220
This function is not thread-safe. Calling it from multiple threads can result
215221
in unexpected behavior. It's recommended to use the :class:`threading.Lock`
@@ -320,6 +326,9 @@ ABC hierarchy::
320326
.. versionchanged:: 3.7
321327
Introduced the optional :meth:`get_resource_reader` method.
322328

329+
.. versionchanged:: 3.15
330+
Removed the ``load_module()`` method.
331+
323332
.. method:: create_module(spec)
324333

325334
A method that returns the module object to use when
@@ -344,47 +353,6 @@ ABC hierarchy::
344353
.. versionchanged:: 3.6
345354
:meth:`create_module` must also be defined.
346355

347-
.. method:: load_module(fullname)
348-
349-
A legacy method for loading a module. If the module cannot be
350-
loaded, :exc:`ImportError` is raised, otherwise the loaded module is
351-
returned.
352-
353-
If the requested module already exists in :data:`sys.modules`, that
354-
module should be used and reloaded.
355-
Otherwise the loader should create a new module and insert it into
356-
:data:`sys.modules` before any loading begins, to prevent recursion
357-
from the import. If the loader inserted a module and the load fails, it
358-
must be removed by the loader from :data:`sys.modules`; modules already
359-
in :data:`sys.modules` before the loader began execution should be left
360-
alone.
361-
362-
The loader should set several attributes on the module
363-
(note that some of these attributes can change when a module is
364-
reloaded):
365-
366-
- :attr:`module.__name__`
367-
- :attr:`module.__file__`
368-
- :attr:`module.__cached__` *(deprecated)*
369-
- :attr:`module.__path__`
370-
- :attr:`module.__package__` *(deprecated)*
371-
- :attr:`module.__loader__` *(deprecated)*
372-
373-
When :meth:`exec_module` is available then backwards-compatible
374-
functionality is provided.
375-
376-
.. versionchanged:: 3.4
377-
Raise :exc:`ImportError` when called instead of
378-
:exc:`NotImplementedError`. Functionality provided when
379-
:meth:`exec_module` is available.
380-
381-
.. deprecated-removed:: 3.4 3.15
382-
The recommended API for loading a module is :meth:`exec_module`
383-
(and :meth:`create_module`). Loaders should implement it instead of
384-
:meth:`load_module`. The import machinery takes care of all the
385-
other responsibilities of :meth:`load_module` when
386-
:meth:`exec_module` is implemented.
387-
388356

389357
.. class:: ResourceLoader
390358

@@ -490,13 +458,6 @@ ABC hierarchy::
490458

491459
.. versionadded:: 3.4
492460

493-
.. method:: load_module(fullname)
494-
495-
Implementation of :meth:`Loader.load_module`.
496-
497-
.. deprecated-removed:: 3.4 3.15
498-
use :meth:`exec_module` instead.
499-
500461

501462
.. class:: ExecutionLoader
502463

@@ -530,6 +491,9 @@ ABC hierarchy::
530491

531492
.. versionadded:: 3.3
532493

494+
.. versionchanged:: 3.15
495+
Removed the ``load_module()`` method.
496+
533497
.. attribute:: name
534498

535499
The name of the module the loader can handle.
@@ -538,13 +502,6 @@ ABC hierarchy::
538502

539503
Path to the file of the module.
540504

541-
.. method:: load_module(fullname)
542-
543-
Calls super's ``load_module()``.
544-
545-
.. deprecated-removed:: 3.4 3.15
546-
Use :meth:`Loader.exec_module` instead.
547-
548505
.. method:: get_filename(fullname)
549506
:abstractmethod:
550507

@@ -576,6 +533,9 @@ ABC hierarchy::
576533
optimization to speed up loading by removing the parsing step of Python's
577534
compiler, and so no bytecode-specific API is exposed.
578535

536+
.. versionchanged:: 3.15
537+
Removed the ``load_module()`` method.
538+
579539
.. method:: path_stats(path)
580540

581541
Optional abstract method which returns a :class:`dict` containing
@@ -629,13 +589,6 @@ ABC hierarchy::
629589

630590
.. versionadded:: 3.4
631591

632-
.. method:: load_module(fullname)
633-
634-
Concrete implementation of :meth:`Loader.load_module`.
635-
636-
.. deprecated-removed:: 3.4 3.15
637-
Use :meth:`exec_module` instead.
638-
639592
.. method:: get_source(fullname)
640593

641594
Concrete implementation of :meth:`InspectLoader.get_source`.
@@ -1059,6 +1012,9 @@ find and load modules.
10591012

10601013
.. versionadded:: 3.3
10611014

1015+
.. versionchanged:: 3.15
1016+
Removed the ``load_module()`` method.
1017+
10621018
.. attribute:: name
10631019

10641020
The name of the module that this loader will handle.
@@ -1079,15 +1035,6 @@ find and load modules.
10791035

10801036
Concrete implementation of :meth:`importlib.abc.SourceLoader.set_data`.
10811037

1082-
.. method:: load_module(name=None)
1083-
1084-
Concrete implementation of :meth:`importlib.abc.Loader.load_module` where
1085-
specifying the name of the module to load is optional.
1086-
1087-
.. deprecated-removed:: 3.6 3.15
1088-
1089-
Use :meth:`importlib.abc.Loader.exec_module` instead.
1090-
10911038

10921039
.. class:: SourcelessFileLoader(fullname, path)
10931040

@@ -1101,6 +1048,9 @@ find and load modules.
11011048

11021049
.. versionadded:: 3.3
11031050

1051+
.. versionchanged:: 3.15
1052+
Removed the ``load_module()`` method.
1053+
11041054
.. attribute:: name
11051055

11061056
The name of the module the loader will handle.
@@ -1122,15 +1072,6 @@ find and load modules.
11221072
Returns ``None`` as bytecode files have no source when this loader is
11231073
used.
11241074

1125-
.. method:: load_module(name=None)
1126-
1127-
Concrete implementation of :meth:`importlib.abc.Loader.load_module` where
1128-
specifying the name of the module to load is optional.
1129-
1130-
.. deprecated-removed:: 3.6 3.15
1131-
1132-
Use :meth:`importlib.abc.Loader.exec_module` instead.
1133-
11341075

11351076
.. class:: ExtensionFileLoader(fullname, path)
11361077

@@ -1262,8 +1203,7 @@ find and load modules.
12621203

12631204
.. attribute:: cached
12641205

1265-
The filename of a compiled version of the module's code
1266-
(see :attr:`module.__cached__`).
1206+
The filename of a compiled version of the module's code.
12671207
The :term:`finder` should always set this attribute but it may be ``None``
12681208
for modules that do not need compiled code stored.
12691209

@@ -1365,7 +1305,7 @@ an :term:`importer`.
13651305

13661306
.. versionadded:: 3.4
13671307

1368-
.. function:: cache_from_source(path, debug_override=None, *, optimization=None)
1308+
.. function:: cache_from_source(path, *, optimization=None)
13691309

13701310
Return the :pep:`3147`/:pep:`488` path to the byte-compiled file associated
13711311
with the source *path*. For example, if *path* is ``/foo/bar/baz.py`` the return
@@ -1384,12 +1324,6 @@ an :term:`importer`.
13841324
``/foo/bar/__pycache__/baz.cpython-32.opt-2.pyc``. The string representation
13851325
of *optimization* can only be alphanumeric, else :exc:`ValueError` is raised.
13861326

1387-
The *debug_override* parameter is deprecated and can be used to override
1388-
the system's value for ``__debug__``. A ``True`` value is the equivalent of
1389-
setting *optimization* to the empty string. A ``False`` value is the same as
1390-
setting *optimization* to ``1``. If both *debug_override* an *optimization*
1391-
are not ``None`` then :exc:`TypeError` is raised.
1392-
13931327
.. versionadded:: 3.4
13941328

13951329
.. versionchanged:: 3.5
@@ -1399,6 +1333,9 @@ an :term:`importer`.
13991333
.. versionchanged:: 3.6
14001334
Accepts a :term:`path-like object`.
14011335

1336+
.. versionchanged:: 3.15
1337+
The *debug_override* parameter was removed.
1338+
14021339

14031340
.. function:: source_from_cache(path)
14041341

0 commit comments

Comments
 (0)