8000 Merge branch 'main' of https://github.com/python/cpython into fix-asy… · python/cpython@7c10817 · GitHub
[go: up one dir, main page]

Skip to content

Commit 7c10817

Browse files
Merge branch 'main' of https://github.com/python/cpython into fix-asyncio-subprocess
2 parents 485b26b + 3354245 commit 7c10817

38 files changed

+403
-204
lines changed

.azure-pipelines/windows-release/gpg-sign.yml

Lines changed: 0 additions & 31 deletions
This file was deleted.

.azure-pipelines/windows-release/stage-publish-pythonorg.yml

Lines changed: 26 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -84,16 +84,32 @@ jobs:
8484
condition: and(succeeded(), ne(variables['PublishARM64'], 'true'))
8585

8686

87-
- template: ./gpg-sign.yml
88-
parameters:
89-
GPGKeyFile: 'python-signing.key'
90-
Files: 'msi\*\*, embed\*.zip'
91-
92-
- template: ./gpg-sign.yml
93-
parameters:
94-
GPGKeyFile: 'python-signing.key'
95-
Files: 'doc\htmlhelp\*.chm'
96-
Condition: and(succeeded(), eq(variables['DoCHM'], 'true'))
87+
- task: DownloadSecureFile@1
88+
name: gpgkey
89+
inputs:
90+
secureFile: 'python-signing.key'
91+
displayName: 'Download GPG key'
92+
93+
- powershell: |
94+
git clone https://github.com/python/cpython-bin-deps --branch gpg --single-branch --depth 1 --progress -v "gpg"
95+
gpg/gpg2.exe --import "$(gpgkey.secureFilePath)"
96+
$files = gci -File "msi\*\*", "embed\*.zip"
97+
if ("$(DoCHM)" -ieq "true") {
98+
$files = $files + (gci -File "doc\htmlhelp\*.chm")
99+
}
100+
$files.FullName | %{
101+
gpg/gpg2.exe -ba --batch --passphrase $(GPGPassphrase) $_
102+
"Made signature for $_"
103+
}
104+
displayName: 'Generate GPG signatures'
105+
workingDirectory: $(Build.BinariesDirectory)
106+
107+
- powershell: |
108+
$p = gps "gpg-agent" -EA 0
109+
if ($p) { $p.Kill() }
110+
displayName: 'Kill GPG agent'
111+
condition: true
112+
97113
98114
- powershell: >
99115
$(Build.SourcesDirectory)\Tools\msi\uploadrelease.ps1

Doc/c-api/concrete.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,7 @@ Other Objects
111111
memoryview.rst
112112
weakref.rst
113113
capsule.rst
114+
frame.rst
114115
gen.rst
115116
coro.rst
116117
contextvars.rst

Doc/c-api/frame.rst

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
.. highlight:: c
2+
3+
Frame Objects
4+
-------------
5+
6+
.. c:type:: PyFrameObject
7+
8+
The C structure of the objects used to describe frame objects.
9+
10+
The structure is not part of the C API.
11+
12+
.. versionchanged:: 3.11
13+
The structure moved to the internal C API headers.
14+
15+
The :c:func:`PyEval_GetFrame` and :c:func:`PyThreadState_GetFrame` functions
16+
can be used to get a frame object.
17+
18+
See also :ref:`Reflection <reflection>`.
19+
20+
21+
.. c:function:: PyFrameObject* PyFrame_GetBack(PyFrameObject *frame)
22+
23+
Get the *frame* next outer frame.
24+
25+
Return a :term:`strong reference`, or ``NULL`` if *frame* has no outer
26+
frame.
27+
28+
*frame* must not be ``NULL``.
29+
30+
.. versionadded:: 3.9
31+
32+
33+
.. c:function:: PyCodeObject* PyFrame_GetCode(PyFrameObject *frame)
34+
35+
Get the *frame* code.
36+
37+
Return a :term:`strong reference`.
38+
39+
*frame* must not be ``NULL``. The result (frame code) cannot be ``NULL``.
40+
41+
.. versionadded:: 3.9
42+
43+
44+
.. c:function:: int PyFrame_GetLineNumber(PyFrameObject *frame)
45+
46+
Return the line number that *frame* is currently executing.
47+
48+
*frame* must not be ``NULL``.

Doc/c-api/reflection.rst

Lines changed: 0 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -31,35 +31,6 @@ Reflection
3131
See also :c:func:`PyThreadState_GetFrame`.
3232
3333
34-
.. c:function:: PyFrameObject* PyFrame_GetBack(PyFrameObject *frame)
35-
36-
Get the *frame* next outer frame.
37-
38-
Return a :term:`strong reference`, or ``NULL`` if *frame* has no outer frame.
39-
40-
*frame* must not be ``NULL``.
41-
42-
.. versionadded:: 3.9
43-
44-
45-
.. c:function:: PyCodeObject* PyFrame_GetCode(PyFrameObject *frame)
46-
47-
Get the *frame* code.
48-
49-
Return a :term:`strong reference`.
50-
51-
*frame* must not be ``NULL``. The result (frame code) cannot be ``NULL``.
52-
53-
.. versionadded:: 3.9
54-
55-
56-
.. c:function:: int PyFrame_GetLineNumber(PyFrameObject *frame)
57-
58-
Return the line number that *frame* is currently executing.
59-
60-
*frame* must not be ``NULL``.
61-
62-
6334
.. c:function:: const char* PyEval_GetFuncName(PyObject *func)
6435
6536
Return the name of *func* if it is a function, class or instance object, else the

Doc/c-api/veryhigh.rst

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -286,20 +286,6 @@ the same library that the Python runtime is using.
286286
<keyword-only_parameter>` arguments and a closure tuple of cells.
287287
288288
289-
.. c:type:: PyFrameObject
290-
291-
The C structure of the objects used to describe frame objects.
292-
293-
The structure is only part of the internal C API: fields should not be
294-
access directly. Use getter functions like :c:func:`PyFrame_GetCode` and
295-
:c:func:`PyFrame_GetBack`.
296-
297-
Debuggers and profilers can use the limited C API to access this structure.
298-
299-
.. versionchanged:: 3.11
300-
The structure moved to the internal C API headers.
301-
302-
303289
.. c:function:: PyObject* PyEval_EvalFrame(PyFrameObject *f)
304290
305291
Evaluate an execution frame. This is a simplified interface to

Doc/library/asyncio-future.rst

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,11 @@ Future Object
196196
.. versionchanged:: 3.9
197197
Added the *msg* parameter.
198198

199+
.. deprecated-removed:: 3.11 3.14
200+
*msg* parameter is ambiguous when multiple :meth:`cancel`
201+
are called with different cancellation messages.
202+
The argument will be removed.
203+
199204
.. method:: exception()
200205

201206
Return the exception that was set on this Future.
@@ -276,3 +281,8 @@ the Future has a result::
276281

277282
- :meth:`asyncio.Future.cancel` accepts an optional ``msg`` argument,
278283
but :func:`concurrent.futures.cancel` does not.
284+
285+
.. deprecated-removed:: 3.11 3.14
286+
*msg* parameter is ambiguous when multiple :meth:`cancel`
287+
are called with different cancellation messages.
288+
The argument will be removed.

Doc/library/asyncio-task.rst

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -810,8 +810,10 @@ Task Object
810810
.. versionchanged:: 3.9
811811
Added the *msg* parameter.
812812

813-
.. versionchanged:: 3.11
814-
The ``msg`` parameter is propagated from cancelled task to its awaiter.
813+
.. deprecated-removed:: 3.11 3.14
814+
*msg* parameter is ambiguous when multiple :meth:`cancel`
815+
are called with different cancellation messages.
816+
The argument will be removed.
815817

816818
.. _asyncio_example_task_cancel:
817819

Doc/library/importlib.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,9 @@ managing aspects of Python packages:
5151
The :func:`.__import__` function
5252
The :keyword:`import` statement is syntactic sugar for this function.
5353

54+
:ref:`sys-path-init`
55+
The initialization of :data:`sys.path`.
56+
5457
:pep:`235`
5558
Import on Case-Insensitive Platforms
5659

Doc/library/modules.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,4 @@ The full list of modules described in this chapter is:
1919
importlib.rst
2020
importlib.resources.rst
2121
importlib.metadata.rst
22+
sys_path_init.rst

Doc/library/site.rst

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -276,4 +276,6 @@ value greater than 2 if there is an error.
276276

277277
.. seealso::
278278

279-
:pep:`370` -- Per user site-packages directory
279+
* :pep:`370` -- Per user site-packages directory
280+
* :ref:`sys-path-init` -- The initialization of :data:`sys.path`.
281+

Doc/library/sys.rst

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1124,15 +1124,16 @@ always available.
11241124
current directory first. Notice that the script directory is inserted *before*
11251125
the entries inserted as a result of :envvar:`PYTHONPATH`.
11261126

1127+
The initialization of :data:`sys.path` is documented at :ref:`sys-path-init`.
1128+
11271129
A program is free to modify this list for its own purposes. Only strings
11281130
and bytes should be added to :data:`sys.path`; all other data types are
11291131
ignored during import.
11301132

11311133

11321134
.. seealso::
1133-
Module :mod:`site` This describes how to use .pth files to extend
1134-
:data:`sys.path`.
1135-
1135+
* Module :mod:`site` This describes how to use .pth files to
1136+
extend :data:`sys.path`.
11361137

11371138
.. data:: path_hooks
11381139

Doc/library/sys_path_init.rst

Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
.. _sys-path-init:
2+
3+
The initialization of the :data:`sys.path` module search path
4+
=============================================================
5+
6+
A module search path is initialized when Python starts. This module search path
7+
may be accessed at :data:`sys.path`.
8+
9+
The first entry in the module search path is the directory that contains the
10+
input script, if there is one. Otherwise, the first entry is the current
11+
directory, which is the case when executing the interactive shell, a :option:`-c`
12+
command, or :option:`-m` module.
13+
14+
The :envvar:`PYTHONPATH` environment variable is often used to add directories
15+
to the search path. If this environment variable is found then the contents are
16+
added to the module search path.
17+
18+
.. note::
19+
20+
:envvar:`PYTHONPATH` will affect all installed Python versions/environments.
21+
Be wary of setting this in your shell profile or global environment variables.
22+
The :mod:`site` module offers more nuanced techniques as mentioned below.
23+
24+
The next items added are the directories containing standard Python modules as
25+
well as any :term:`extension module`\s that these modules depend on. Extension
26+
modules are ``.pyd`` files on Windows and ``.so`` files on other platforms. The
27+
directory with the platform-independent Python modules is called ``prefix``.
28+
The directory with the extension modules is called ``exec_prefix``.
29+
30+
The :envvar:`PYTHONHOME` environment variable may be used to set the ``prefix``
31+
and ``exec_prefix`` locations. Otherwise these directories are found by using
32+
the Python executable as a starting point and then looking for various 'landmark'
33+
files and directories. Note that any symbolic links are followed so the real
34+
Python executable location is used as the search starting point. The Python
35+
executable location is called ``home``.
36+
37+
Once ``home`` is determined, the ``prefix`` directory is found by first looking
38+
for :file:`python{majorversion}{minorversion}.zip` (``python311.zip``). On Windows
39+
the zip archive is searched for in ``home`` and on Unix the archive is expected
40+
to be in :file:`lib`. Note that the expected zip archive location is added to the
41+
module search path even if the archive does not exist. If no archive was found,
42+
Python on Windows will continue the search for ``prefix`` by looking for :file:`Lib\\os.py`.
43+
Python on Unix will look for :file:`lib/python{majorversion}.{minorversion}/os.py`
44+
(``lib/python3.11/os.py``). On Windows ``prefix`` and ``exec_prefix`` are the same,
45+
however on other platforms :file:`lib/python{majorversion}.{minorversion}/lib-dynload`
46+
(``lib/python3.11/lib-dynload``) is searched for and used as an anchor for
47+
``exec_prefix``. On some platforms :file:`lib` may be :file:`lib64` or another value,
48+
see :data:`sys.platlibdir` and :envvar:`PYTHONPLATLIBDIR`.
49+
50+
Once found, ``prefix`` and ``exec_prefix`` are available at :data:`sys.prefix` and
51+
:data:`sys.exec_prefix` respectively.
52+
53+
Finally, the :mod:`site` module is processed and :file:`site-packages` directories
54+
are added to the module search path. A common way to customize the search path is
55+
to create :mod:`sitecustomize` or :mod:`usercustomize` modules as described in
56+
the :mod:`site` module documentation.
57+
58+
.. note::
59+
60+
Certain command line options may further affect path calculations.
61+
See :option:`-E`, :option:`-I`, :option:`-s` and :option:`-S` for further details.
62+
63+
Virtual environments
64+
--------------------
65+
66+
If Python is run in a virtual environment (as described at :ref:`tut-venv`)
67+
then ``prefix`` and ``exec_prefix`` are specific to the virtual environment.
68+
69+
If a ``pyvenv.cfg`` file is found alongside the main executable, or in the
70+
directory one level above the executable, the following variations apply:
71+
72+
* If ``home`` is an absolute path and :envvar:`PYTHONHOME` is not set, this
73+
path is used instead of the path to the main executable when deducing ``prefix``
74+
and ``exec_prefix``.
75+
76+
_pth files
77+
----------
78+
79+
To completely override :data:`sys.path` create a ``._pth`` file with the same
80+
name as the shared library or executable (``python._pth`` or ``python311._pth``).
81+
The shared library path is always known on Windows, however it may not be
82+
available on other platforms. In the ``._pth`` file specify one line for each path
83+
to add to :data:`sys.path`. The file based on the shared library name overrides
84+
the one based on the executable, which allows paths to be restricted for any
85+
program loading the runtime if desired.
86+
87+
When the file exists, all registry and environment variables are ignored,
88+
isolated mode is enabled, and :mod:`site` is not imported unless one line in the
89+
file specifies ``import site``. Blank paths and lines starting with ``#`` are
90+
ignored. Each path may be absolute or relative to the location of the file.
91+
Import statements other than to ``site`` are not permitted, and arbitrary code
92+
cannot be specified.
93+
94+
Note that ``.pth`` files (without leading underscore) will be processed normally
95+
by the :mod:`site` module when ``import site`` has been specified.
96+
97+
Embedded Python
98+
---------------
99+
100+
If Python is embedded within another application :c:func:`Py_InitializeFromConfig` and
101+
the :c:type:`PyConfig` structure can be used to initialize Python. The path specific
102+
details are described at :ref:`init-path-config`. Alternatively the older :c:func:`Py_SetPath`
103+
can be used to bypass the initialization of the module search path.
104+
105+
.. seealso::
106+
107+
* :ref:`windows_finding_modules` for detailed Windows notes.
108+
* :ref:`using-on-unix` for Unix details.

Doc/library/tempfile.rst

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -99,9 +99,9 @@ The module defines the following user-callable items:
9999
Added *errors* parameter.
100100

101101

102-
.. function:: SpooledTemporaryFile(max_size=0, mode='w+b', buffering=-1, encoding=None, newline=None, suffix=None, prefix=None, dir=None, *, errors=None)
102+
.. class:: SpooledTemporaryFile(max_size=0, mode='w+b', buffering=-1, encoding=None, newline=None, suffix=None, prefix=None, dir=None, *, errors=None)
103103

104-
This function operates exactly as :func:`TemporaryFile` does, except that
104+
This class operates exactly as :func:`TemporaryFile` does, except that
105105
data is spooled in memory until the file size exceeds *max_size*, or
106106
until the file's :func:`fileno` method is called, at which point the
107107
contents are written to disk and operation proceeds as with
@@ -124,9 +124,9 @@ The module defines the following user-callable items:
124124
Added *errors* parameter.
125125

126126

127-
.. function:: TemporaryDirectory(suffix=None, prefix=None, dir=None, ignore_cleanup_errors=False)
127+
.. class:: TemporaryDirectory(suffix=None, prefix=None, dir=None, ignore_cleanup_errors=False)
128128

129-
This function securely creates a temporary directory using the same rules as :func:`mkdtemp`.
129+
This class securely creates a temporary directory using the same rules as :func:`mkdtemp`.
130130
The resulting object can be used as a context manager (see
131131
:ref:`tempfile-examples`). On completion of the context or destruction
132132
of the temporary directory object, the newly created temporary directory

0 commit comments

Comments
 (0)
0