Skip to content

Commit

Permalink
Merge branch 'python:main' into pythongh-87452
Browse files Browse the repository at this point in the history
  • Loading branch information
zitterbewegung authored May 3, 2022
2 parents 903ae8d + c278474 commit ecbe497
Show file tree
Hide file tree
Showing 107 changed files with 1,104 additions and 269 deletions.
5 changes: 5 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,8 @@ updates:
labels:
- "skip issue"
- "skip news"
ignore:
- dependency-name: "*"
update-types:
- "version-update:semver-minor"
- "version-update:semver-patch"
6 changes: 3 additions & 3 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ jobs:
echo "LD_LIBRARY_PATH=${GITHUB_WORKSPACE}/multissl/openssl/${OPENSSL_VER}/lib" >> $GITHUB_ENV
- name: 'Restore OpenSSL build'
id: cache-openssl
uses: actions/cache@v3.0.2
uses: actions/cache@v3
with:
path: ./multissl/openssl/${{ env.OPENSSL_VER }}
key: ${{ runner.os }}-multissl-openssl-${{ env.OPENSSL_VER }}
Expand Down Expand Up @@ -248,7 +248,7 @@ jobs:
echo "LD_LIBRARY_PATH=${GITHUB_WORKSPACE}/multissl/openssl/${OPENSSL_VER}/lib" >> $GITHUB_ENV
- name: 'Restore OpenSSL build'
id: cache-openssl
uses: actions/cache@v3.0.2
uses: actions/cache@v3
with:
path: ./multissl/openssl/${{ env.OPENSSL_VER }}
key: ${{ runner.os }}-multissl-openssl-${{ env.OPENSSL_VER }}
Expand Down Expand Up @@ -292,7 +292,7 @@ jobs:
echo "LD_LIBRARY_PATH=${GITHUB_WORKSPACE}/multissl/openssl/${OPENSSL_VER}/lib" >> $GITHUB_ENV
- name: 'Restore OpenSSL build'
id: cache-openssl
uses: actions/cache@v3.0.2
uses: actions/cache@v3
with:
path: ./multissl/openssl/${{ env.OPENSSL_VER }}
key: ${{ runner.os }}-multissl-openssl-${{ env.OPENSSL_VER }}
Expand Down
2 changes: 1 addition & 1 deletion Doc/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ Contributing
============

Bugs in the content should be reported to the
`Python bug tracker <https://bugs.python.org>`_.
`Python bug tracker <https://github.com/python/cpython/issues>`_.

Bugs in the toolset should be reported to the tools themselves.

Expand Down
4 changes: 2 additions & 2 deletions Doc/c-api/bytearray.rst
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,9 @@ These macros trade safety for speed and they don't check pointers.
.. c:function:: char* PyByteArray_AS_STRING(PyObject *bytearray)
Macro version of :c:func:`PyByteArray_AsString`.
Similar to :c:func:`PyByteArray_AsString`, but without error checking.
.. c:function:: Py_ssize_t PyByteArray_GET_SIZE(PyObject *bytearray)
Macro version of :c:func:`PyByteArray_Size`.
Similar to :c:func:`PyByteArray_Size`, but without error checking.
4 changes: 2 additions & 2 deletions Doc/c-api/bytes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ called with a non-bytes parameter.
.. c:function:: Py_ssize_t PyBytes_GET_SIZE(PyObject *o)
Macro form of :c:func:`PyBytes_Size` but without error checking.
Similar to :c:func:`PyBytes_Size`, but without error checking.
.. c:function:: char* PyBytes_AsString(PyObject *o)
Expand All @@ -151,7 +151,7 @@ called with a non-bytes parameter.
.. c:function:: char* PyBytes_AS_STRING(PyObject *string)
Macro form of :c:func:`PyBytes_AsString` but without error checking.
Similar to :c:func:`PyBytes_AsString`, but without error checking.
.. c:function:: int PyBytes_AsStringAndSize(PyObject *obj, char **buffer, Py_ssize_t *length)
Expand Down
14 changes: 14 additions & 0 deletions Doc/c-api/code.rst
Original file line number Diff line number Diff line change
Expand Up @@ -76,3 +76,17 @@ bound into a function.
information is not available for any particular element.
Returns ``1`` if the function succeeds and 0 otherwise.
.. c:function:: PyObject* PyCode_GetCode(PyCodeObject *co)
Equivalent to the Python code ``getattr(co, 'co_code')``.
Returns a strong reference to a :c:type:`PyBytesObject` representing the
bytecode in a code object. On error, ``NULL`` is returned and an exception
is raised.
This ``PyBytesObject`` may be created on-demand by the interpreter and does
not necessarily represent the bytecode actually executed by CPython. The
primary use case for this function is debuggers and profilers.
.. versionadded:: 3.11
10 changes: 2 additions & 8 deletions Doc/faq/general.rst
Original file line number Diff line number Diff line change
Expand Up @@ -230,14 +230,8 @@ You can also access the development version of Python through Git. See
How do I submit bug reports and patches for Python?
---------------------------------------------------

To report a bug or submit a patch, please use the Roundup installation at
https://bugs.python.org/.

You must have a Roundup account to report bugs; this makes it possible for us to
contact you if we have follow-up questions. It will also enable Roundup to send
you updates as we act on your bug. If you had previously used SourceForge to
report bugs to Python, you can obtain your Roundup password through Roundup's
`password reset procedure <https://bugs.python.org/user?@template=forgotten>`_.
To report a bug or submit a patch, use the issue tracker at
https://github.com/python/cpython/issues.

For more information on how Python is developed, consult `the Python Developer's
Guide <https://devguide.python.org/>`_.
Expand Down
2 changes: 1 addition & 1 deletion Doc/library/asyncio-runner.rst
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ To mitigate this issue, :mod:`asyncio` handles :const:`signal.SIGINT` as follows
execution.
3. When :const:`signal.SIGINT` is raised by :kbd:`Ctrl-C`, the custom signal handler
cancels the main task by calling :meth:`asyncio.Task.cancel` which raises
:exc:`asyncio.CancelledError` inside the the main task. This causes the Python stack
:exc:`asyncio.CancelledError` inside the main task. This causes the Python stack
to unwind, ``try/except`` and ``try/finally`` blocks can be used for resource
cleanup. After the main task is cancelled, :meth:`asyncio.Runner.run` raises
:exc:`KeyboardInterrupt`.
Expand Down
2 changes: 1 addition & 1 deletion Doc/library/fileinput.rst
Original file line number Diff line number Diff line change
Expand Up @@ -224,5 +224,5 @@ The two following opening hooks are provided by this module:
Added the optional *errors* parameter.

.. deprecated:: 3.10
This function is deprecated since :func:`input` and :class:`FileInput`
This function is deprecated since :func:`fileinput.input` and :class:`FileInput`
now have *encoding* and *errors* parameters.
15 changes: 13 additions & 2 deletions Doc/library/http.server.rst
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,9 @@ provides three different variants:

.. attribute:: protocol_version

This specifies the HTTP protocol version used in responses. If set to
Specifies the HTTP version to which the server is conformant. It is sent
in responses to let the client know the server's communication
capabilities for future requests. If set to
``'HTTP/1.1'``, the server will permit HTTP persistent connections;
however, your server *must* then include an accurate ``Content-Length``
header (using :meth:`send_header`) in all of its responses to clients.
Expand Down Expand Up @@ -193,7 +195,7 @@ provides three different variants:

.. method:: handle_expect_100()

When a HTTP/1.1 compliant server receives an ``Expect: 100-continue``
When an HTTP/1.1 conformant server receives an ``Expect: 100-continue``
request header it responds back with a ``100 Continue`` followed by ``200
OK`` headers.
This method can be overridden to raise an error if the server does not
Expand Down Expand Up @@ -444,6 +446,15 @@ the following command uses a specific directory::
.. versionadded:: 3.7
``--directory`` argument was introduced.

By default, the server is conformant to HTTP/1.0. The option ``-p/--protocol``
specifies the HTTP version to which the server is conformant. For example, the
following command runs an HTTP/1.1 conformant server::

python -m http.server --protocol HTTP/1.1

.. versionadded:: 3.11
``--protocol`` argument was introduced.

.. class:: CGIHTTPRequestHandler(request, client_address, server)

This class is used to serve either files or output of CGI scripts from the
Expand Down
7 changes: 3 additions & 4 deletions Doc/library/importlib.rst
Original file line number Diff line number Diff line change
Expand Up @@ -248,8 +248,8 @@ ABC hierarchy::

object
+-- Finder (deprecated)
| +-- MetaPathFinder
| +-- PathEntryFinder
+-- MetaPathFinder
+-- PathEntryFinder
+-- Loader
+-- ResourceLoader --------+
+-- InspectLoader |
Expand Down Expand Up @@ -282,8 +282,7 @@ ABC hierarchy::

.. class:: MetaPathFinder

An abstract base class representing a :term:`meta path finder`. For
compatibility, this is a subclass of :class:`Finder`.
An abstract base class representing a :term:`meta path finder`.

.. versionadded:: 3.3

Expand Down
9 changes: 9 additions & 0 deletions Doc/library/socket.rst
Original file line number Diff line number Diff line change
Expand Up @@ -575,6 +575,15 @@ Constants

.. availability:: FreeBSD.

.. data:: SO_INCOMING_CPU

Constant to optimize CPU locality, to be used in conjunction with
:data:`SO_REUSEPORT`.

.. versionadded:: 3.11

.. availability:: Linux >= 3.9

Functions
^^^^^^^^^

Expand Down
9 changes: 9 additions & 0 deletions Doc/library/stdtypes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5055,6 +5055,15 @@ All parameterized generics implement special read-only attributes.
have correct ``__parameters__`` after substitution because
:class:`typing.ParamSpec` is intended primarily for static type checking.


.. attribute:: genericalias.__unpacked__

A boolean that is true if the alias has been unpacked using the
``*`` operator (see :data:`~typing.TypeVarTuple`).

.. versionadded:: 3.11


.. seealso::

:pep:`484` - Type Hints
Expand Down
5 changes: 5 additions & 0 deletions Doc/library/tempfile.rst
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,11 @@ The module defines the following user-callable items:
.. versionchanged:: 3.8
Added *errors* parameter.

.. versionchanged:: 3.11
Fully implements the :class:`io.BufferedIOBase` and
:class:`io.TextIOBase` abstract base classes (depending on whether binary
or text *mode* was specified).


.. class:: TemporaryDirectory(suffix=None, prefix=None, dir=None, ignore_cleanup_errors=False)

Expand Down
20 changes: 19 additions & 1 deletion Doc/library/typing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1615,6 +1615,12 @@ These are not used in annotations. They are building blocks for declaring types.
def __repr__(self) -> str:
return f'<Employee {self.name}, id={self.id}>'

``NamedTuple`` subclasses can be generic::

class Group(NamedTuple, Generic[T]):
key: T
group: list[T]

Backward-compatible usage::

Employee = NamedTuple('Employee', [('name', str), ('id', int)])
Expand All @@ -1633,6 +1639,9 @@ These are not used in annotations. They are building blocks for declaring types.
Removed the ``_field_types`` attribute in favor of the more
standard ``__annotations__`` attribute which has the same information.

.. versionchanged:: 3.11
Added support for generic namedtuples.

.. class:: NewType(name, tp)

A helper class to indicate a distinct type to a typechecker,
Expand Down Expand Up @@ -1729,7 +1738,7 @@ These are not used in annotations. They are building blocks for declaring types.
z: int

A ``TypedDict`` cannot inherit from a non-TypedDict class,
notably including :class:`Generic`. For example::
except for :class:`Generic`. For example::

class X(TypedDict):
x: int
Expand All @@ -1746,6 +1755,12 @@ These are not used in annotations. They are building blocks for declaring types.
T = TypeVar('T')
class XT(X, Generic[T]): pass # raises TypeError

A ``TypedDict`` can be generic::

class Group(TypedDict, Generic[T]):
key: T
group: list[T]

A ``TypedDict`` can be introspected via annotations dicts
(see :ref:`annotations-howto` for more information on annotations best practices),
:attr:`__total__`, :attr:`__required_keys__`, and :attr:`__optional_keys__`.
Expand Down Expand Up @@ -1793,6 +1808,9 @@ These are not used in annotations. They are building blocks for declaring types.

.. versionadded:: 3.8

.. versionchanged:: 3.11
Added support for generic ``TypedDict``\ s.

Generic concrete collections
----------------------------

Expand Down
2 changes: 1 addition & 1 deletion Doc/library/urllib.request.rst
Original file line number Diff line number Diff line change
Expand Up @@ -739,7 +739,7 @@ The following attribute and methods should only be used by classes derived from

This method, if implemented, will be called by the parent
:class:`OpenerDirector`. It should return a file-like object as described in
the return value of the :meth:`open` of :class:`OpenerDirector`, or ``None``.
the return value of the :meth:`~OpenerDirector.open` method of :class:`OpenerDirector`, or ``None``.
It should raise :exc:`~urllib.error.URLError`, unless a truly exceptional
thing happens (for example, :exc:`MemoryError` should not be mapped to
:exc:`URLError`).
Expand Down
2 changes: 1 addition & 1 deletion Doc/library/xml.sax.handler.rst
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ for the feature and property names.
.. data:: property_xml_string

| value: ``"http://xml.org/sax/properties/xml-string"``
| data type: String
| data type: Bytes
| description: The literal string of characters that was the source for the
current event.
| access: read-only
Expand Down
2 changes: 1 addition & 1 deletion Doc/library/zipfile.rst
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,7 @@ ZipFile Objects
compressed text files in :term:`universal newlines` mode.

.. versionchanged:: 3.6
:meth:`open` can now be used to write files into the archive with the
:meth:`ZipFile.open` can now be used to write files into the archive with the
``mode='w'`` option.

.. versionchanged:: 3.6
Expand Down
14 changes: 13 additions & 1 deletion Doc/whatsnew/3.11.rst
Original file line number Diff line number Diff line change
Expand Up @@ -715,6 +715,13 @@ For major changes, see :ref:`new-feat-related-type-hints-311`.
to clear all registered overloads of a function.
(Contributed by Jelle Zijlstra in :gh:`89263`.)

* :data:`typing.TypedDict` subclasses can now be generic. (Contributed by
Samodya Abey in :gh:`89026`.)

* :class:`~typing.NamedTuple` subclasses can now be generic.
(Contributed by Serhiy Storchaka in :issue:`43923`.)


unicodedata
-----------

Expand Down Expand Up @@ -1392,7 +1399,7 @@ C API Changes
fields of the result from the exception instance (the ``value`` field).
(Contributed by Irit Katriel in :issue:`45711`.)

* :c:struct:`_frozen` has a new ``is_package`` field to indicate whether
* :c:type:`_frozen` has a new ``is_package`` field to indicate whether
or not the frozen module is a package. Previously, a negative value
in the ``size`` field was the indicator. Now only non-negative values
be used for ``size``.
Expand All @@ -1408,6 +1415,11 @@ C API Changes
To get a custom code object: create a code object using the compiler,
then get a modified version with the ``replace`` method.

* :c:type:`PyCodeObject` no longer has a ``co_code`` field. Instead,
use ``PyObject_GetAttrString(code_object, "co_code")`` or
:c:func:`PyCode_GetCode` to get the underlying bytes object.
(Contributed by Brandt Bucher in :issue:`46841` and Ken Jin in :gh:`92154`.)

New Features
------------

Expand Down
2 changes: 1 addition & 1 deletion Include/cpython/abstract.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ PyAPI_FUNC(PyObject *) _PyObject_MakeTpCall(
PyObject *keywords);

#define PY_VECTORCALL_ARGUMENTS_OFFSET \
(_Py_static_cast(size_t, 1) << (8 * sizeof(size_t) - 1))
(_Py_STATIC_CAST(size_t, 1) << (8 * sizeof(size_t) - 1))

static inline Py_ssize_t
PyVectorcall_NARGS(size_t n)
Expand Down
30 changes: 24 additions & 6 deletions Include/cpython/bytearrayobject.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,28 @@ typedef struct {
Py_ssize_t ob_exports; /* How many buffer exports */
} PyByteArrayObject;

/* Macros, trading safety for speed */
#define PyByteArray_AS_STRING(self) \
(assert(PyByteArray_Check(self)), \
Py_SIZE(self) ? ((PyByteArrayObject *)(self))->ob_start : _PyByteArray_empty_string)
#define PyByteArray_GET_SIZE(self) (assert(PyByteArray_Check(self)), Py_SIZE(self))

PyAPI_DATA(char) _PyByteArray_empty_string[];

/* Macros and static inline functions, trading safety for speed */
#define _PyByteArray_CAST(op) \
(assert(PyByteArray_Check(op)), _Py_CAST(PyByteArrayObject*, op))

static inline char* PyByteArray_AS_STRING(PyObject *op)
{
PyByteArrayObject *self = _PyByteArray_CAST(op);
if (Py_SIZE(self)) {
return self->ob_start;
}
return _PyByteArray_empty_string;
}
#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 < 0x030b0000
# define PyByteArray_AS_STRING(self) PyByteArray_AS_STRING(_PyObject_CAST(self))
#endif

static inline Py_ssize_t PyByteArray_GET_SIZE(PyObject *op) {
PyByteArrayObject *self = _PyByteArray_CAST(op);
return Py_SIZE(self);
}
#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 < 0x030b0000
# define PyByteArray_GET_SIZE(self) PyByteArray_GET_SIZE(_PyObject_CAST(self))
#endif
Loading

0 comments on commit ecbe497

Please sign in to comment.