Skip to content

Commit ecbe497

Browse files
Merge branch 'python:main' into pythongh-87452
2 parents 903ae8d + c278474 commit ecbe497

File tree

107 files changed

+1104
-269
lines changed

Some content is hidden

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

107 files changed

+1104
-269
lines changed

.github/dependabot.yml

+5
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,8 @@ updates:
77
labels:
88
- "skip issue"
99
- "skip news"
10+
ignore:
11+
- dependency-name: "*"
12+
update-types:
13+
- "version-update:semver-minor"
14+
- "version-update:semver-patch"

.github/workflows/build.yml

+3-3
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ jobs:
185185
echo "LD_LIBRARY_PATH=${GITHUB_WORKSPACE}/multissl/openssl/${OPENSSL_VER}/lib" >> $GITHUB_ENV
186186
- name: 'Restore OpenSSL build'
187187
id: cache-openssl
188-
uses: actions/cache@v3.0.2
188+
uses: actions/cache@v3
189189
with:
190190
path: ./multissl/openssl/${{ env.OPENSSL_VER }}
191191
key: ${{ runner.os }}-multissl-openssl-${{ env.OPENSSL_VER }}
@@ -248,7 +248,7 @@ jobs:
248248
echo "LD_LIBRARY_PATH=${GITHUB_WORKSPACE}/multissl/openssl/${OPENSSL_VER}/lib" >> $GITHUB_ENV
249249
- name: 'Restore OpenSSL build'
250250
id: cache-openssl
251-
uses: actions/cache@v3.0.2
251+
uses: actions/cache@v3
252252
with:
253253
path: ./multissl/openssl/${{ env.OPENSSL_VER }}
254254
key: ${{ runner.os }}-multissl-openssl-${{ env.OPENSSL_VER }}
@@ -292,7 +292,7 @@ jobs:
292292
echo "LD_LIBRARY_PATH=${GITHUB_WORKSPACE}/multissl/openssl/${OPENSSL_VER}/lib" >> $GITHUB_ENV
293293
- name: 'Restore OpenSSL build'
294294
id: cache-openssl
295-
uses: actions/cache@v3.0.2
295+
uses: actions/cache@v3
296296
with:
297297
path: ./multissl/openssl/${{ env.OPENSSL_VER }}
298298
key: ${{ runner.os }}-multissl-openssl-${{ env.OPENSSL_VER }}

Doc/README.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ Contributing
130130
============
131131

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

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

Doc/c-api/bytearray.rst

+2-2
Original file line numberDiff line numberDiff line change
@@ -77,9 +77,9 @@ These macros trade safety for speed and they don't check pointers.
7777
7878
.. c:function:: char* PyByteArray_AS_STRING(PyObject *bytearray)
7979
80-
Macro version of :c:func:`PyByteArray_AsString`.
80+
Similar to :c:func:`PyByteArray_AsString`, but without error checking.
8181
8282
8383
.. c:function:: Py_ssize_t PyByteArray_GET_SIZE(PyObject *bytearray)
8484
85-
Macro version of :c:func:`PyByteArray_Size`.
85+
Similar to :c:func:`PyByteArray_Size`, but without error checking.

Doc/c-api/bytes.rst

+2-2
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ called with a non-bytes parameter.
134134
135135
.. c:function:: Py_ssize_t PyBytes_GET_SIZE(PyObject *o)
136136
137-
Macro form of :c:func:`PyBytes_Size` but without error checking.
137+
Similar to :c:func:`PyBytes_Size`, but without error checking.
138138
139139
140140
.. c:function:: char* PyBytes_AsString(PyObject *o)
@@ -151,7 +151,7 @@ called with a non-bytes parameter.
151151
152152
.. c:function:: char* PyBytes_AS_STRING(PyObject *string)
153153
154-
Macro form of :c:func:`PyBytes_AsString` but without error checking.
154+
Similar to :c:func:`PyBytes_AsString`, but without error checking.
155155
156156
157157
.. c:function:: int PyBytes_AsStringAndSize(PyObject *obj, char **buffer, Py_ssize_t *length)

Doc/c-api/code.rst

+14
Original file line numberDiff line numberDiff line change
@@ -76,3 +76,17 @@ bound into a function.
7676
information is not available for any particular element.
7777
7878
Returns ``1`` if the function succeeds and 0 otherwise.
79+
80+
.. c:function:: PyObject* PyCode_GetCode(PyCodeObject *co)
81+
82+
Equivalent to the Python code ``getattr(co, 'co_code')``.
83+
Returns a strong reference to a :c:type:`PyBytesObject` representing the
84+
bytecode in a code object. On error, ``NULL`` is returned and an exception
85+
is raised.
86+
87+
This ``PyBytesObject`` may be created on-demand by the interpreter and does
88+
not necessarily represent the bytecode actually executed by CPython. The
89+
primary use case for this function is debuggers and profilers.
90+
91+
.. versionadded:: 3.11
92+

Doc/faq/general.rst

+2-8
Original file line numberDiff line numberDiff line change
@@ -230,14 +230,8 @@ You can also access the development version of Python through Git. See
230230
How do I submit bug reports and patches for Python?
231231
---------------------------------------------------
232232

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

242236
For more information on how Python is developed, consult `the Python Developer's
243237
Guide <https://devguide.python.org/>`_.

Doc/library/asyncio-runner.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ To mitigate this issue, :mod:`asyncio` handles :const:`signal.SIGINT` as follows
139139
execution.
140140
3. When :const:`signal.SIGINT` is raised by :kbd:`Ctrl-C`, the custom signal handler
141141
cancels the main task by calling :meth:`asyncio.Task.cancel` which raises
142-
:exc:`asyncio.CancelledError` inside the the main task. This causes the Python stack
142+
:exc:`asyncio.CancelledError` inside the main task. This causes the Python stack
143143
to unwind, ``try/except`` and ``try/finally`` blocks can be used for resource
144144
cleanup. After the main task is cancelled, :meth:`asyncio.Runner.run` raises
145145
:exc:`KeyboardInterrupt`.

Doc/library/fileinput.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -224,5 +224,5 @@ The two following opening hooks are provided by this module:
224224
Added the optional *errors* parameter.
225225

226226
.. deprecated:: 3.10
227-
This function is deprecated since :func:`input` and :class:`FileInput`
227+
This function is deprecated since :func:`fileinput.input` and :class:`FileInput`
228228
now have *encoding* and *errors* parameters.

Doc/library/http.server.rst

+13-2
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,9 @@ provides three different variants:
157157

158158
.. attribute:: protocol_version
159159

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

194196
.. method:: handle_expect_100()
195197

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

449+
By default, the server is conformant to HTTP/1.0. The option ``-p/--protocol``
450+
specifies the HTTP version to which the server is conformant. For example, the
451+
following command runs an HTTP/1.1 conformant server::
452+
453+
python -m http.server --protocol HTTP/1.1
454+
455+
.. versionadded:: 3.11
456+
``--protocol`` argument was introduced.
457+
447458
.. class:: CGIHTTPRequestHandler(request, client_address, server)
448459

449460
This class is used to serve either files or output of CGI scripts from the

Doc/library/importlib.rst

+3-4
Original file line numberDiff line numberDiff line change
@@ -248,8 +248,8 @@ ABC hierarchy::
248248

249249
object
250250
+-- Finder (deprecated)
251-
| +-- MetaPathFinder
252-
| +-- PathEntryFinder
251+
+-- MetaPathFinder
252+
+-- PathEntryFinder
253253
+-- Loader
254254
+-- ResourceLoader --------+
255255
+-- InspectLoader |
@@ -282,8 +282,7 @@ ABC hierarchy::
282282

283283
.. class:: MetaPathFinder
284284

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

288287
.. versionadded:: 3.3
289288

Doc/library/socket.rst

+9
Original file line numberDiff line numberDiff line change
@@ -575,6 +575,15 @@ Constants
575575

576576
.. availability:: FreeBSD.
577577

578+
.. data:: SO_INCOMING_CPU
579+
580+
Constant to optimize CPU locality, to be used in conjunction with
581+
:data:`SO_REUSEPORT`.
582+
583+
.. versionadded:: 3.11
584+
585+
.. availability:: Linux >= 3.9
586+
578587
Functions
579588
^^^^^^^^^
580589

Doc/library/stdtypes.rst

+9
Original file line numberDiff line numberDiff line change
@@ -5055,6 +5055,15 @@ All parameterized generics implement special read-only attributes.
50555055
have correct ``__parameters__`` after substitution because
50565056
:class:`typing.ParamSpec` is intended primarily for static type checking.
50575057

5058+
5059+
.. attribute:: genericalias.__unpacked__
5060+
5061+
A boolean that is true if the alias has been unpacked using the
5062+
``*`` operator (see :data:`~typing.TypeVarTuple`).
5063+
5064+
.. versionadded:: 3.11
5065+
5066+
50585067
.. seealso::
50595068

50605069
:pep:`484` - Type Hints

Doc/library/tempfile.rst

+5
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,11 @@ The module defines the following user-callable items:
123123
.. versionchanged:: 3.8
124124
Added *errors* parameter.
125125

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

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

Doc/library/typing.rst

+19-1
Original file line numberDiff line numberDiff line change
@@ -1615,6 +1615,12 @@ These are not used in annotations. They are building blocks for declaring types.
16151615
def __repr__(self) -> str:
16161616
return f'<Employee {self.name}, id={self.id}>'
16171617

1618+
``NamedTuple`` subclasses can be generic::
1619+
1620+
class Group(NamedTuple, Generic[T]):
1621+
key: T
1622+
group: list[T]
1623+
16181624
Backward-compatible usage::
16191625

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

1642+
.. versionchanged:: 3.11
1643+
Added support for generic namedtuples.
1644+
16361645
.. class:: NewType(name, tp)
16371646

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

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

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

1758+
A ``TypedDict`` can be generic::
1759+
1760+
class Group(TypedDict, Generic[T]):
1761+
key: T
1762+
group: list[T]
1763+
17491764
A ``TypedDict`` can be introspected via annotations dicts
17501765
(see :ref:`annotations-howto` for more information on annotations best practices),
17511766
:attr:`__total__`, :attr:`__required_keys__`, and :attr:`__optional_keys__`.
@@ -1793,6 +1808,9 @@ These are not used in annotations. They are building blocks for declaring types.
17931808

17941809
.. versionadded:: 3.8
17951810

1811+
.. versionchanged:: 3.11
1812+
Added support for generic ``TypedDict``\ s.
1813+
17961814
Generic concrete collections
17971815
----------------------------
17981816

Doc/library/urllib.request.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -739,7 +739,7 @@ The following attribute and methods should only be used by classes derived from
739739

740740
This method, if implemented, will be called by the parent
741741
:class:`OpenerDirector`. It should return a file-like object as described in
742-
the return value of the :meth:`open` of :class:`OpenerDirector`, or ``None``.
742+
the return value of the :meth:`~OpenerDirector.open` method of :class:`OpenerDirector`, or ``None``.
743743
It should raise :exc:`~urllib.error.URLError`, unless a truly exceptional
744744
thing happens (for example, :exc:`MemoryError` should not be mapped to
745745
:exc:`URLError`).

Doc/library/xml.sax.handler.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ for the feature and property names.
147147
.. data:: property_xml_string
148148

149149
| value: ``"http://xml.org/sax/properties/xml-string"``
150-
| data type: String
150+
| data type: Bytes
151151
| description: The literal string of characters that was the source for the
152152
current event.
153153
| access: read-only

Doc/library/zipfile.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -311,7 +311,7 @@ ZipFile Objects
311311
compressed text files in :term:`universal newlines` mode.
312312

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

317317
.. versionchanged:: 3.6

Doc/whatsnew/3.11.rst

+13-1
Original file line numberDiff line numberDiff line change
@@ -715,6 +715,13 @@ For major changes, see :ref:`new-feat-related-type-hints-311`.
715715
to clear all registered overloads of a function.
716716
(Contributed by Jelle Zijlstra in :gh:`89263`.)
717717

718+
* :data:`typing.TypedDict` subclasses can now be generic. (Contributed by
719+
Samodya Abey in :gh:`89026`.)
720+
721+
* :class:`~typing.NamedTuple` subclasses can now be generic.
722+
(Contributed by Serhiy Storchaka in :issue:`43923`.)
723+
724+
718725
unicodedata
719726
-----------
720727

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

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

1418+
* :c:type:`PyCodeObject` no longer has a ``co_code`` field. Instead,
1419+
use ``PyObject_GetAttrString(code_object, "co_code")`` or
1420+
:c:func:`PyCode_GetCode` to get the underlying bytes object.
1421+
(Contributed by Brandt Bucher in :issue:`46841` and Ken Jin in :gh:`92154`.)
1422+
14111423
New Features
14121424
------------
14131425

Include/cpython/abstract.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ PyAPI_FUNC(PyObject *) _PyObject_MakeTpCall(
5151
PyObject *keywords);
5252

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

5656
static inline Py_ssize_t
5757
PyVectorcall_NARGS(size_t n)

Include/cpython/bytearrayobject.h

+24-6
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,28 @@ typedef struct {
1111
Py_ssize_t ob_exports; /* How many buffer exports */
1212
} PyByteArrayObject;
1313

14-
/* Macros, trading safety for speed */
15-
#define PyByteArray_AS_STRING(self) \
16-
(assert(PyByteArray_Check(self)), \
17-
Py_SIZE(self) ? ((PyByteArrayObject *)(self))->ob_start : _PyByteArray_empty_string)
18-
#define PyByteArray_GET_SIZE(self) (assert(PyByteArray_Check(self)), Py_SIZE(self))
19-
2014
PyAPI_DATA(char) _PyByteArray_empty_string[];
15+
16+
/* Macros and static inline functions, trading safety for speed */
17+
#define _PyByteArray_CAST(op) \
18+
(assert(PyByteArray_Check(op)), _Py_CAST(PyByteArrayObject*, op))
19+
20+
static inline char* PyByteArray_AS_STRING(PyObject *op)
21+
{
22+
PyByteArrayObject *self = _PyByteArray_CAST(op);
23+
if (Py_SIZE(self)) {
24+
return self->ob_start;
25+
}
26+
return _PyByteArray_empty_string;
27+
}
28+
#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 < 0x030b0000
29+
# define PyByteArray_AS_STRING(self) PyByteArray_AS_STRING(_PyObject_CAST(self))
30+
#endif
31+
32+
static inline Py_ssize_t PyByteArray_GET_SIZE(PyObject *op) {
33+
PyByteArrayObject *self = _PyByteArray_CAST(op);
34+
return Py_SIZE(self);
35+
}
36+
#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 < 0x030b0000
37+
# define PyByteArray_GET_SIZE(self) PyByteArray_GET_SIZE(_PyObject_CAST(self))
38+
#endif

0 commit comments

Comments
 (0)