Skip to content

Commit

Permalink
Merge branch 'main' into reset-counters
Browse files Browse the repository at this point in the history
  • Loading branch information
brandtbucher authored Nov 20, 2024
2 parents a6e173f + 5b45025 commit 1d8d086
Show file tree
Hide file tree
Showing 252 changed files with 2,871 additions and 2,186 deletions.
13 changes: 12 additions & 1 deletion .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,17 @@ Programs/_bootstrap_python.c @ericsnowcurrently
Programs/python.c @ericsnowcurrently
Tools/build/generate_global_objects.py @ericsnowcurrently

# Initialization
Doc/library/sys_path_init.rst @FFY00
Doc/c-api/init_config.rst @FFY00

# getpath
**/*getpath* @FFY00

# site
**/*site.py @FFY00
Doc/library/site.rst @FFY00

# Exceptions
Lib/test/test_except*.py @iritkatriel
Objects/exceptions.c @iritkatriel
Expand All @@ -97,7 +108,7 @@ Modules/_hacl/** @gpshead
**/*logging* @vsajip

# venv
**/*venv* @vsajip
**/*venv* @vsajip @FFY00

# Launcher
/PC/launcher.c @vsajip
Expand Down
2 changes: 1 addition & 1 deletion Doc/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@ check: _ensure-pre-commit

.PHONY: serve
serve:
@echo "The serve target was removed, use htmlview instead (see bpo-36329)"
@echo "The serve target was removed, use htmllive instead (see gh-80510)"

# Targets for daily automated doc build
# By default, Sphinx only rebuilds pages where the page content has changed.
Expand Down
3 changes: 3 additions & 0 deletions Doc/c-api/init.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1379,6 +1379,9 @@ All of the following functions must be called after :c:func:`Py_Initialize`.
This function now calls the :c:member:`PyThreadState.on_delete` callback.
Previously, that happened in :c:func:`PyThreadState_Delete`.
.. versionchanged:: 3.13
The :c:member:`PyThreadState.on_delete` callback was removed.
.. c:function:: void PyThreadState_Delete(PyThreadState *tstate)
Expand Down
6 changes: 3 additions & 3 deletions Doc/c-api/long.rst
Original file line number Diff line number Diff line change
Expand Up @@ -590,7 +590,7 @@ distinguished from a number. Use :c:func:`PyErr_Occurred` to disambiguate.
return ``1`` when it's positive and ``0`` otherwise. Else set an
exception and return ``-1``.
.. versionadded:: next
.. versionadded:: 3.14
.. c:function:: int PyLong_IsNegative(PyObject *obj)
Expand All @@ -601,7 +601,7 @@ distinguished from a number. Use :c:func:`PyErr_Occurred` to disambiguate.
return ``1`` when it's negative and ``0`` otherwise. Else set an
exception and return ``-1``.
.. versionadded:: next
.. versionadded:: 3.14
.. c:function:: int PyLong_IsZero(PyObject *obj)
Expand All @@ -612,7 +612,7 @@ distinguished from a number. Use :c:func:`PyErr_Occurred` to disambiguate.
return ``1`` when it's zero and ``0`` otherwise. Else set an
exception and return ``-1``.
.. versionadded:: next
.. versionadded:: 3.14
.. c:function:: PyObject* PyLong_GetInfo(void)
Expand Down
2 changes: 1 addition & 1 deletion Doc/c-api/object.rst
Original file line number Diff line number Diff line change
Expand Up @@ -597,5 +597,5 @@ Object Protocol
This function is intended to be used soon after *obj* is created,
by the code that creates it.
.. versionadded:: next
.. versionadded:: 3.14
4 changes: 0 additions & 4 deletions Doc/deprecations/pending-removal-in-future.rst
Original file line number Diff line number Diff line change
Expand Up @@ -145,10 +145,6 @@ although there is currently no date scheduled for their removal.
* ``splitvalue()``
* ``to_bytes()``

* :mod:`urllib.request`: :class:`~urllib.request.URLopener` and
:class:`~urllib.request.FancyURLopener` style of invoking requests is
deprecated. Use newer :func:`~urllib.request.urlopen` functions and methods.

* :mod:`wsgiref`: ``SimpleHandler.stdout.write()`` should not do partial
writes.

Expand Down
4 changes: 2 additions & 2 deletions Doc/library/concurrent.futures.rst
Original file line number Diff line number Diff line change
Expand Up @@ -690,7 +690,7 @@ Exception classes
of a :class:`~concurrent.futures.InterpreterPoolExecutor`
has failed initializing.

.. versionadded:: next
.. versionadded:: 3.14

.. exception:: ExecutionFailed

Expand All @@ -699,7 +699,7 @@ Exception classes
:meth:`~concurrent.futures.Executor.submit` when there's an uncaught
exception from the submitted task.

.. versionadded:: next
.. versionadded:: 3.14

.. currentmodule:: concurrent.futures.process

Expand Down
47 changes: 41 additions & 6 deletions Doc/library/ctypes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1707,12 +1707,6 @@ in :mod:`!ctypes`) which inherits from the private :class:`_CFuncPtr` class:
and raise an exception if the foreign function call failed.


.. exception:: ArgumentError

This exception is raised when a foreign function call cannot convert one of the
passed arguments.


.. audit-event:: ctypes.set_exception code foreign-functions

On Windows, when a foreign function call raises a system exception (for
Expand Down Expand Up @@ -1799,10 +1793,15 @@ different ways, depending on the type and number of the parameters in the call:
integer. *name* is name of the COM method. *iid* is an optional pointer to
the interface identifier which is used in extended error reporting.

If *iid* is not specified, an :exc:`OSError` is raised if the COM method
call fails. If *iid* is specified, a :exc:`~ctypes.COMError` is raised
instead.

COM methods use a special calling convention: They require a pointer to
the COM interface as first argument, in addition to those parameters that
are specified in the :attr:`!argtypes` tuple.


The optional *paramflags* parameter creates foreign function wrappers with much
more functionality than the features described above.

Expand Down Expand Up @@ -2741,3 +2740,39 @@ Arrays and pointers

Returns the object to which to pointer points. Assigning to this
attribute changes the pointer to point to the assigned object.


.. _ctypes-exceptions:

Exceptions
^^^^^^^^^^

.. exception:: ArgumentError

This exception is raised when a foreign function call cannot convert one of the
passed arguments.


.. exception:: COMError(hresult, text, details)

Windows only: This exception is raised when a COM method call failed.

.. attribute:: hresult

The integer value representing the error code.

.. attribute:: text

The error message.

.. attribute:: details

The 5-tuple ``(descr, source, helpfile, helpcontext, progid)``.

*descr* is the textual description. *source* is the language-dependent
``ProgID`` for the class or application that raised the error. *helpfile*
is the path of the help file. *helpcontext* is the help context
identifier. *progid* is the ``ProgID`` of the interface that defined the
error.

.. versionadded:: next
2 changes: 1 addition & 1 deletion Doc/library/functools.rst
Original file line number Diff line number Diff line change
Expand Up @@ -481,7 +481,7 @@ The :mod:`functools` module defines the following functions:
See :func:`itertools.accumulate` for an iterator that yields all intermediate
values.

.. versionchanged:: next
.. versionchanged:: 3.14
*initial* is now supported as a keyword argument.

.. decorator:: singledispatch
Expand Down
2 changes: 1 addition & 1 deletion Doc/library/marshal.rst
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ this module. The following types are supported:
* Added format version 4, which supports efficient representations
of short strings.

.. versionchanged:: next
.. versionchanged:: 3.14

Added format version 5, which allows marshalling slices.

Expand Down
2 changes: 1 addition & 1 deletion Doc/library/os.rst
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ process and user.
:data:`os.environ` or :data:`os.environb`, or calling :func:`os.getenv`
while reloading, may return an empty result.

.. versionadded:: next
.. versionadded:: 3.14


.. function:: chdir(path)
Expand Down
2 changes: 1 addition & 1 deletion Doc/library/stdtypes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3889,7 +3889,7 @@ copying.
.. versionchanged:: 3.5
memoryviews can now be indexed with tuple of integers.

.. versionchanged:: next
.. versionchanged:: 3.14
memoryview is now a :term:`generic type`.

:class:`memoryview` has several methods:
Expand Down
2 changes: 1 addition & 1 deletion Doc/library/sys.rst
Original file line number Diff line number Diff line change
Expand Up @@ -944,7 +944,7 @@ always available.
This function should be used for specialized purposes only.
It is not guaranteed to exist in all implementations of Python.

.. versionchanged:: next
.. versionchanged:: 3.14

The result may include objects from other interpreters.

Expand Down
4 changes: 2 additions & 2 deletions Doc/library/tomllib.rst
Original file line number Diff line number Diff line change
Expand Up @@ -84,11 +84,11 @@ The following exceptions are available:

The column corresponding to *pos*.

.. versionchanged:: next
.. versionchanged:: 3.14
Added the *msg*, *doc* and *pos* parameters.
Added the :attr:`msg`, :attr:`doc`, :attr:`pos`, :attr:`lineno` and :attr:`colno` attributes.

.. deprecated:: next
.. deprecated:: 3.14
Passing free-form positional arguments is deprecated.


Expand Down
125 changes: 4 additions & 121 deletions Doc/library/urllib.request.rst
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,7 @@ The :mod:`urllib.request` module defines the following functions:
the response headers as it is specified in the documentation for
:class:`~http.client.HTTPResponse`.

For FTP, file, and data URLs and requests explicitly handled by legacy
:class:`URLopener` and :class:`FancyURLopener` classes, this function
For FTP, file, and data URLs, this function
returns a :class:`urllib.response.addinfourl` object.

Raises :exc:`~urllib.error.URLError` on protocol errors.
Expand Down Expand Up @@ -1339,15 +1338,15 @@ environment settings::

>>> import urllib.request
>>> proxies = {'http': 'http://proxy.example.com:8080/'}
>>> opener = urllib.request.FancyURLopener(proxies)
>>> opener = urllib.request.build_opener(urllib.request.ProxyHandler(proxies))
>>> with opener.open("http://www.python.org") as f:
... f.read().decode('utf-8')
...

The following example uses no proxies at all, overriding environment settings::

>>> import urllib.request
>>> opener = urllib.request.FancyURLopener({})
>>> opener = urllib.request.build_opener(urllib.request.ProxyHandler({}}))
>>> with opener.open("http://www.python.org/") as f:
... f.read().decode('utf-8')
...
Expand Down Expand Up @@ -1412,121 +1411,6 @@ some point in the future.
Cleans up temporary files that may have been left behind by previous
calls to :func:`urlretrieve`.

.. class:: URLopener(proxies=None, **x509)

.. deprecated:: 3.3

Base class for opening and reading URLs. Unless you need to support opening
objects using schemes other than :file:`http:`, :file:`ftp:`, or :file:`file:`,
you probably want to use :class:`FancyURLopener`.

By default, the :class:`URLopener` class sends a :mailheader:`User-Agent` header
of ``urllib/VVV``, where *VVV* is the :mod:`urllib` version number.
Applications can define their own :mailheader:`User-Agent` header by subclassing
:class:`URLopener` or :class:`FancyURLopener` and setting the class attribute
:attr:`version` to an appropriate string value in the subclass definition.

The optional *proxies* parameter should be a dictionary mapping scheme names to
proxy URLs, where an empty dictionary turns proxies off completely. Its default
value is ``None``, in which case environmental proxy settings will be used if
present, as discussed in the definition of :func:`urlopen`, above.

Additional keyword parameters, collected in *x509*, may be used for
authentication of the client when using the :file:`https:` scheme. The keywords
*key_file* and *cert_file* are supported to provide an SSL key and certificate;
both are needed to support client authentication.

:class:`URLopener` objects will raise an :exc:`OSError` exception if the server
returns an error code.

.. method:: open(fullurl, data=None)

Open *fullurl* using the appropriate protocol. This method sets up cache and
proxy information, then calls the appropriate open method with its input
arguments. If the scheme is not recognized, :meth:`open_unknown` is called.
The *data* argument has the same meaning as the *data* argument of
:func:`urlopen`.

This method always quotes *fullurl* using :func:`~urllib.parse.quote`.

.. method:: open_unknown(fullurl, data=None)

Overridable interface to open unknown URL types.


.. method:: retrieve(url, filename=None, reporthook=None, data=None)

Retrieves the contents of *url* and places it in *filename*. The return value
is a tuple consisting of a local filename and either an
:class:`email.message.Message` object containing the response headers (for remote
URLs) or ``None`` (for local URLs). The caller must then open and read the
contents of *filename*. If *filename* is not given and the URL refers to a
local file, the input filename is returned. If the URL is non-local and
*filename* is not given, the filename is the output of :func:`tempfile.mktemp`
with a suffix that matches the suffix of the last path component of the input
URL. If *reporthook* is given, it must be a function accepting three numeric
parameters: A chunk number, the maximum size chunks are read in and the total size of the download
(-1 if unknown). It will be called once at the start and after each chunk of data is read from the
network. *reporthook* is ignored for local URLs.

If the *url* uses the :file:`http:` scheme identifier, the optional *data*
argument may be given to specify a ``POST`` request (normally the request type
is ``GET``). The *data* argument must in standard
:mimetype:`application/x-www-form-urlencoded` format; see the
:func:`urllib.parse.urlencode` function.


.. attribute:: version

Variable that specifies the user agent of the opener object. To get
:mod:`urllib` to tell servers that it is a particular user agent, set this in a
subclass as a class variable or in the constructor before calling the base
constructor.


.. class:: FancyURLopener(...)

.. deprecated:: 3.3

:class:`FancyURLopener` subclasses :class:`URLopener` providing default handling
for the following HTTP response codes: 301, 302, 303, 307 and 401. For the 30x
response codes listed above, the :mailheader:`Location` header is used to fetch
the actual URL. For 401 response codes (authentication required), basic HTTP
authentication is performed. For the 30x response codes, recursion is bounded
by the value of the *maxtries* attribute, which defaults to 10.

For all other response codes, the method :meth:`~BaseHandler.http_error_default` is called
which you can override in subclasses to handle the error appropriately.

.. note::

According to the letter of :rfc:`2616`, 301 and 302 responses to POST requests
must not be automatically redirected without confirmation by the user. In
reality, browsers do allow automatic redirection of these responses, changing
the POST to a GET, and :mod:`urllib` reproduces this behaviour.

The parameters to the constructor are the same as those for :class:`URLopener`.

.. note::

When performing basic authentication, a :class:`FancyURLopener` instance calls
its :meth:`prompt_user_passwd` method. The default implementation asks the
users for the required information on the controlling terminal. A subclass may
override this method to support more appropriate behavior if needed.

The :class:`FancyURLopener` class offers one additional method that should be
overloaded to provide the appropriate behavior:

.. method:: prompt_user_passwd(host, realm)

Return information needed to authenticate the user at the given host in the
specified security realm. The return value should be a tuple, ``(user,
password)``, which can be used for basic authentication.

The implementation prompts for this information on the terminal; an application
should override this method to use an appropriate interaction model in the local
environment.


:mod:`urllib.request` Restrictions
----------------------------------
Expand Down Expand Up @@ -1578,8 +1462,7 @@ some point in the future.
you try to fetch a file whose read permissions make it inaccessible; the FTP
code will try to read it, fail with a 550 error, and then perform a directory
listing for the unreadable file. If fine-grained control is needed, consider
using the :mod:`ftplib` module, subclassing :class:`FancyURLopener`, or changing
*_urlopener* to meet your needs.
using the :mod:`ftplib` module.



Expand Down
Loading

0 comments on commit 1d8d086

Please sign in to comment.