Skip to content

Commit b8ff991

Browse files
authored
Merge branch 'main' into patch-1
2 parents d0b2411 + bd13cc0 commit b8ff991

File tree

86 files changed

+2891
-1308
lines changed

Some content is hidden

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

86 files changed

+2891
-1308
lines changed

.github/CODEOWNERS

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -260,33 +260,33 @@ Include/pyhash.h @gpshead @picnixz
260260
Python/pyhash.c @gpshead @picnixz
261261

262262
# The import system (including importlib)
263-
**/*import* @brettcannon @ericsnowcurrently @ncoghlan @warsaw
264-
Python/import.c @brettcannon @ericsnowcurrently @ncoghlan @warsaw @kumaraditya303
263+
**/*import* @brettcannon @ericsnowcurrently @ncoghlan @warsaw @FFY00
264+
Python/import.c @brettcannon @ericsnowcurrently @ncoghlan @warsaw @FFY00 @kumaraditya303
265265
**/*freeze* @ericsnowcurrently
266266
**/*frozen* @ericsnowcurrently
267267
**/*modsupport* @ericsnowcurrently
268-
**/*modulefinder* @ericsnowcurrently
268+
**/*modulefinder* @ericsnowcurrently @FFY00
269269
**/*moduleobject* @ericsnowcurrently
270270
**/*multiphase* @ericsnowcurrently
271-
**/*pkgutil* @ericsnowcurrently
271+
**/*pkgutil* @ericsnowcurrently @FFY00
272272
**/*pythonrun* @ericsnowcurrently
273-
**/*runpy* @ericsnowcurrently
273+
**/*runpy* @ericsnowcurrently @FFY00
274274
**/*singlephase* @ericsnowcurrently
275275
Doc/c-api/module.rst @ericsnowcurrently
276276
Lib/test/test_module/ @ericsnowcurrently
277-
Python/dynload_*.c @ericsnowcurrently
277+
Python/dynload_*.c @ericsnowcurrently @FFY00
278278

279279
# Initialisation
280-
**/*initconfig* @ericsnowcurrently
281-
**/*pathconfig* @ericsnowcurrently
282-
**/*preconfig* @ericsnowcurrently
280+
**/*initconfig* @ericsnowcurrently @FFY00
281+
**/*pathconfig* @ericsnowcurrently @FFY00
282+
**/*preconfig* @ericsnowcurrently @FFY00
283283
Doc/library/sys_path_init.rst @FFY00
284284
Doc/c-api/init_config.rst @FFY00
285285

286286
# Interpreter main program
287-
Modules/main.c @ericsnowcurrently
288-
Programs/_bootstrap_python.c @ericsnowcurrently
289-
Programs/python.c @ericsnowcurrently
287+
Modules/main.c @ericsnowcurrently @FFY00
288+
Programs/_bootstrap_python.c @ericsnowcurrently @FFY00
289+
Programs/python.c @ericsnowcurrently @FFY00
290290

291291
# JIT
292292
.github/workflows/jit.yml @savannahostrowski
@@ -316,8 +316,8 @@ Tools/peg_generator/ @pablogsal @lysnikolaou
316316

317317
# Runtime state/lifecycle
318318
**/*gil* @ericsnowcurrently
319-
**/*pylifecycle* @ericsnowcurrently @ZeroIntensity
320-
**/*pystate* @ericsnowcurrently @ZeroIntensity
319+
**/*pylifecycle* @ericsnowcurrently @ZeroIntensity @FFY00
320+
**/*pystate* @ericsnowcurrently @ZeroIntensity @FFY00
321321
Include/internal/pycore_*_init.h @ericsnowcurrently
322322
Include/internal/pycore_*_state.h @ericsnowcurrently
323323
Include/internal/pycore_atexit.h @ericsnowcurrently
@@ -505,13 +505,13 @@ Lib/idlelib/ @terryjreedy
505505
Lib/turtledemo/ @terryjreedy
506506

507507
# importlib.metadata
508-
Doc/library/importlib.metadata.rst @jaraco @warsaw
509-
Lib/importlib/metadata/ @jaraco @warsaw
510-
Lib/test/test_importlib/metadata/ @jaraco @warsaw
508+
Doc/library/importlib.metadata.rst @jaraco @warsaw @FFY00
509+
Lib/importlib/metadata/ @jaraco @warsaw @FFY00
510+
Lib/test/test_importlib/metadata/ @jaraco @warsaw @FFY00
511511

512512
# importlib.resources
513-
Doc/library/importlib.resources.abc.rst @jaraco @warsaw
514-
Doc/library/importlib.resources.rst @jaraco @warsaw
513+
Doc/library/importlib.resources.abc.rst @jaraco @warsaw @FFY00
514+
Doc/library/importlib.resources.rst @jaraco @warsaw @FFY00
515515
Lib/importlib/resources/ @jaraco @warsaw @FFY00
516516
Lib/test/test_importlib/resources/ @jaraco @warsaw @FFY00
517517

Doc/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ build:
5858
@if [ -f ../Misc/NEWS ] ; then \
5959
echo "Using existing Misc/NEWS file"; \
6060
cp ../Misc/NEWS build/NEWS; \
61-
elif $(BLURB) help >/dev/null 2>&1 && $(SPHINXBUILD) --version >/dev/null 2>&1; then \
61+
elif $(BLURB) --version && $(SPHINXBUILD) --version ; then \
6262
if [ -d ../Misc/NEWS.d ]; then \
6363
echo "Building NEWS from Misc/NEWS.d with blurb"; \
6464
$(BLURB) merge -f build/NEWS; \

Doc/c-api/exceptions.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -699,6 +699,8 @@ Signal Handling
699699
700700
- Executing a pending :ref:`remote debugger <remote-debugging>` script.
701701
702+
- Raise the exception set by :c:func:`PyThreadState_SetAsyncExc`.
703+
702704
If any handler raises an exception, immediately return ``-1`` with that
703705
exception set.
704706
Any remaining interruptions are left to be processed on the next
@@ -714,6 +716,9 @@ Signal Handling
714716
This function may now execute a remote debugger script, if remote
715717
debugging is enabled.
716718
719+
.. versionchanged:: next
720+
The exception set by :c:func:`PyThreadState_SetAsyncExc` is now raised.
721+
717722
718723
.. c:function:: void PyErr_SetInterrupt()
719724

Doc/c-api/threads.rst

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -699,13 +699,25 @@ pointer and a void pointer argument.
699699
700700
.. c:function:: int PyThreadState_SetAsyncExc(unsigned long id, PyObject *exc)
701701
702-
Asynchronously raise an exception in a thread. The *id* argument is the thread
703-
id of the target thread; *exc* is the exception object to be raised. This
704-
function does not steal any references to *exc*. To prevent naive misuse, you
705-
must write your own C extension to call this. Must be called with an :term:`attached thread state`.
706-
Returns the number of thread states modified; this is normally one, but will be
707-
zero if the thread id isn't found. If *exc* is ``NULL``, the pending
708-
exception (if any) for the thread is cleared. This raises no exceptions.
702+
Schedule an exception to be raised asynchronously in a thread.
703+
If the thread has a previously scheduled exception, it is overwritten.
704+
705+
The *id* argument is the thread id of the target thread, as returned by
706+
:c:func:`PyThread_get_thread_ident`.
707+
*exc* is the class of the exception to be raised, or ``NULL`` to clear
708+
the pending exception (if any).
709+
710+
Return the number of affected thread states.
711+
This is normally ``1`` if *id* is found, even when no change was
712+
made (the given *exc* was already pending, or *exc* is ``NULL`` but
713+
no exception is pending).
714+
If the thread id isn't found, return ``0``. This raises no exceptions.
715+
716+
To prevent naive misuse, you must write your own C extension to call this.
717+
This function must be called with an :term:`attached thread state`.
718+
This function does not steal any references to *exc*.
719+
This function does not necessarily interrupt system calls such as
720+
:py:func:`~time.sleep`.
709721
710722
.. versionchanged:: 3.7
711723
The type of the *id* parameter changed from :c:expr:`long` to
@@ -743,7 +755,8 @@ Operating system thread APIs
743755
:term:`attached thread state`.
744756
745757
.. seealso::
746-
:py:func:`threading.get_ident`
758+
:py:func:`threading.get_ident` and :py:attr:`threading.Thread.ident`
759+
expose this identifier to Python.
747760
748761
749762
.. c:function:: PyObject *PyThread_GetInfo(void)

Doc/library/contextlib.rst

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@ Functions and classes provided:
2121
.. class:: AbstractContextManager
2222

2323
An :term:`abstract base class` for classes that implement
24-
:meth:`object.__enter__` and :meth:`object.__exit__`. A default
25-
implementation for :meth:`object.__enter__` is provided which returns
26-
``self`` while :meth:`object.__exit__` is an abstract method which by default
24+
:meth:`~object.__enter__` and :meth:`~object.__exit__`. A default
25+
implementation for :meth:`~object.__enter__` is provided which returns
26+
``self`` while :meth:`~object.__exit__` is an abstract method which by default
2727
returns ``None``. See also the definition of :ref:`typecontextmanager`.
2828

2929
.. versionadded:: 3.6
@@ -32,9 +32,9 @@ Functions and classes provided:
3232
.. class:: AbstractAsyncContextManager
3333

3434
An :term:`abstract base class` for classes that implement
35-
:meth:`object.__aenter__` and :meth:`object.__aexit__`. A default
36-
implementation for :meth:`object.__aenter__` is provided which returns
37-
``self`` while :meth:`object.__aexit__` is an abstract method which by default
35+
:meth:`~object.__aenter__` and :meth:`~object.__aexit__`. A default
36+
implementation for :meth:`~object.__aenter__` is provided which returns
37+
``self`` while :meth:`~object.__aexit__` is an abstract method which by default
3838
returns ``None``. See also the definition of
3939
:ref:`async-context-managers`.
4040

@@ -228,7 +228,7 @@ Functions and classes provided:
228228

229229
.. function:: nullcontext(enter_result=None)
230230

231-
Return a context manager that returns *enter_result* from ``__enter__``, but
231+
Return a context manager that returns *enter_result* from :meth:`~object.__enter__`, but
232232
otherwise does nothing. It is intended to be used as a stand-in for an
233233
optional context manager, for example::
234234

@@ -335,7 +335,7 @@ Functions and classes provided:
335335
For example, the output of :func:`help` normally is sent to *sys.stdout*.
336336
You can capture that output in a string by redirecting the output to an
337337
:class:`io.StringIO` object. The replacement stream is returned from the
338-
``__enter__`` method and so is available as the target of the
338+
:meth:`~object.__enter__` method and so is available as the target of the
339339
:keyword:`with` statement::
340340

341341
with redirect_stdout(io.StringIO()) as f:
@@ -396,7 +396,8 @@ Functions and classes provided:
396396
A base class that enables a context manager to also be used as a decorator.
397397

398398
Context managers inheriting from ``ContextDecorator`` have to implement
399-
``__enter__`` and ``__exit__`` as normal. ``__exit__`` retains its optional
399+
:meth:`~object.__enter__` and :meth:`~object.__exit__` as normal.
400+
``__exit__`` retains its optional
400401
exception handling even when used as a decorator.
401402

402403
``ContextDecorator`` is used by :func:`contextmanager`, so you get this
@@ -710,9 +711,9 @@ context management protocol.
710711
Catching exceptions from ``__enter__`` methods
711712
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
712713

713-
It is occasionally desirable to catch exceptions from an ``__enter__``
714+
It is occasionally desirable to catch exceptions from an :meth:`~object.__enter__`
714715
method implementation, *without* inadvertently catching exceptions from
715-
the :keyword:`with` statement body or the context manager's ``__exit__``
716+
the :keyword:`with` statement body or the context manager's :meth:`~object.__exit__`
716717
method. By using :class:`ExitStack` the steps in the context management
717718
protocol can be separated slightly in order to allow this::
718719

Doc/library/os.rst

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2409,6 +2409,10 @@ features:
24092409
.. versionchanged:: 3.6
24102410
Accepts a :term:`path-like object`.
24112411

2412+
.. versionchanged:: next
2413+
``os.listdir(-1)`` now fails with ``OSError(errno.EBADF)`` rather than
2414+
listing the current directory.
2415+
24122416

24132417
.. function:: listdrives()
24142418

@@ -2939,6 +2943,10 @@ features:
29392943
.. versionchanged:: 3.7
29402944
Added support for :ref:`file descriptors <path_fd>` on Unix.
29412945

2946+
.. versionchanged:: next
2947+
``os.scandir(-1)`` now fails with ``OSError(errno.EBADF)`` rather than
2948+
listing the current directory.
2949+
29422950

29432951
.. class:: DirEntry
29442952

@@ -4574,6 +4582,10 @@ These functions are all available on Linux only.
45744582
.. versionchanged:: 3.6
45754583
Accepts a :term:`path-like object`.
45764584

4585+
.. versionchanged:: next
4586+
``os.listxattr(-1)`` now fails with ``OSError(errno.EBADF)`` rather than
4587+
listing extended attributes of the current directory.
4588+
45774589

45784590
.. function:: removexattr(path, attribute, *, follow_symlinks=True)
45794591

Doc/library/site.rst

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,8 @@ When running under a :ref:`virtual environment <sys-path-init-virtual-environmen
6464
the ``pyvenv.cfg`` file in :data:`sys.prefix` is checked for site-specific
6565
configurations. If the ``include-system-site-packages`` key exists and is set to
6666
``true`` (case-insensitive), the system-level prefixes will be searched for
67-
site-packages, otherwise they won't.
67+
site-packages, otherwise they won't. If the system-level prefixes are not searched then
68+
the user site prefixes are also implicitly not searched for site-packages.
6869

6970
.. index::
7071
single: # (hash); comment

Doc/library/sys_path_init.rst

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -57,15 +57,19 @@ otherwise they are set to the same value as :data:`sys.base_prefix` and
5757
:data:`sys.base_exec_prefix`, respectively.
5858
This is used by :ref:`sys-path-init-virtual-environments`.
5959

60-
Finally, the :mod:`site` module is processed and :file:`site-packages` directories
61-
are added to the module search path. A common way to customize the search path is
62-
to create :mod:`sitecustomize` or :mod:`usercustomize` modules as described in
63-
the :mod:`site` module documentation.
60+
Finally, the :mod:`site` module is processed and :file:`site-packages`
61+
directories are added to the module search path. The :envvar:`PYTHONUSERBASE`
62+
environment variable controls where is searched for user site-packages and the
63+
:envvar:`PYTHONNOUSERSITE` environment variable prevents searching for user
64+
site-packages all together. A common way to customize the search path is to
65+
create :mod:`sitecustomize` or :mod:`usercustomize` modules as described in the
66+
:mod:`site` module documentation.
6467

6568
.. note::
6669

67-
Certain command line options may further affect path calculations.
68-
See :option:`-E`, :option:`-I`, :option:`-s` and :option:`-S` for further details.
70+
The command line options :option:`-E`, :option:`-P`, :option:`-I`,
71+
:option:`-S` and :option:`-s` further affect path calculations, see their
72+
documentation for details.
6973

7074
.. versionchanged:: 3.14
7175

@@ -96,11 +100,10 @@ Please refer to :mod:`site`'s
96100

97101
.. note::
98102

99-
There are other ways how "virtual environments" could be implemented, this
100-
documentation refers implementations based on the ``pyvenv.cfg`` mechanism,
101-
such as :mod:`venv`. Most virtual environment implementations follow the
102-
model set by :mod:`venv`, but there may be exotic implementations that
103-
diverge from it.
103+
There are other ways "virtual environments" could be implemented.
104+
This documentation refers to implementations based on the ``pyvenv.cfg``
105+
mechanism, such as :mod:`venv`, that many virtual environment implementations
106+
follow.
104107

105108
_pth files
106109
----------

Doc/library/wave.rst

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,11 +181,21 @@ Wave_write Objects
181181
Set the number of channels.
182182

183183

184+
.. method:: getnchannels()
185+
186+
Return the number of channels.
187+
188+
184189
.. method:: setsampwidth(n)
185190

186191
Set the sample width to *n* bytes.
187192

188193

194+
.. method:: getsampwidth()
195+
196+
Return the sample width in bytes.
197+
198+
189199
.. method:: setframerate(n)
190200

191201
Set the frame rate to *n*.
@@ -195,26 +205,53 @@ Wave_write Objects
195205
integer.
196206

197207

208+
.. method:: getframerate()
209+
210+
Return the frame rate.
211+
212+
198213
.. method:: setnframes(n)
199214

200215
Set the number of frames to *n*. This will be changed later if the number
201216
of frames actually written is different (this update attempt will
202217
raise an error if the output stream is not seekable).
203218

204219

220+
.. method:: getnframes()
221+
222+
Return the number of audio frames written so far.
223+
224+
205225
.. method:: setcomptype(type, name)
206226

207227
Set the compression type and description. At the moment, only compression type
208228
``NONE`` is supported, meaning no compression.
209229

210230

231+
.. method:: getcomptype()
232+
233+
Return the compression type (``'NONE'``).
234+
235+
236+
.. method:: getcompname()
237+
238+
Return the human-readable compression type name.
239+
240+
211241
.. method:: setparams(tuple)
212242

213243
The *tuple* should be ``(nchannels, sampwidth, framerate, nframes, comptype,
214244
compname)``, with values valid for the ``set*()`` methods. Sets all
215245
parameters.
216246

217247

248+
.. method:: getparams()
249+
250+
Return a :func:`~collections.namedtuple`
251+
``(nchannels, sampwidth, framerate, nframes, comptype, compname)``
252+
containing the current output parameters.
253+
254+
218255
.. method:: tell()
219256

220257
Return current position in the file, with the same disclaimer for the

0 commit comments

Comments
 (0)