Skip to content

Commit

Permalink
Merge branch '3.12' into wasmtime18-3.12
Browse files Browse the repository at this point in the history
  • Loading branch information
brettcannon authored Mar 5, 2024
2 parents ee445f8 + 55faaa5 commit dcc07d3
Show file tree
Hide file tree
Showing 24 changed files with 325 additions and 188 deletions.
6 changes: 3 additions & 3 deletions Doc/c-api/structures.rst
Original file line number Diff line number Diff line change
Expand Up @@ -702,20 +702,20 @@ Defining Getters and Setters
.. c:member:: void* closure
Optional function pointer, providing additional data for getter and setter.
Optional user data pointer, providing additional data for getter and setter.
.. c:type:: PyObject *(*getter)(PyObject *, void *)
The ``get`` function takes one :c:expr:`PyObject*` parameter (the
instance) and a function pointer (the associated ``closure``):
instance) and a user data pointer (the associated ``closure``):
It should return a new reference on success or ``NULL`` with a set exception
on failure.
.. c:type:: int (*setter)(PyObject *, PyObject *, void *)
``set`` functions take two :c:expr:`PyObject*` parameters (the instance and
the value to be set) and a function pointer (the associated ``closure``):
the value to be set) and a user data pointer (the associated ``closure``):
In case the attribute should be deleted the second parameter is ``NULL``.
Should return ``0`` on success or ``-1`` with a set exception on failure.
2 changes: 1 addition & 1 deletion Doc/library/asyncio-eventloop.rst
Original file line number Diff line number Diff line change
Expand Up @@ -626,7 +626,7 @@ Opening network connections
Added support for Windows.

.. versionchanged:: 3.11
The *reuse_address* parameter, disabled since Python 3.9.0, 3.8.1,
The *reuse_address* parameter, disabled since Python 3.8.1,
3.7.6 and 3.6.10, has been entirely removed.

.. coroutinemethod:: loop.create_unix_connection(protocol_factory, \
Expand Down
2 changes: 1 addition & 1 deletion Doc/library/audit_events.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Audit events table

This table contains all events raised by :func:`sys.audit` or
:c:func:`PySys_Audit` calls throughout the CPython runtime and the
standard library. These calls were added in 3.8.0 or later (see :pep:`578`).
standard library. These calls were added in 3.8 or later (see :pep:`578`).

See :func:`sys.addaudithook` and :c:func:`PySys_AddAuditHook` for
information on handling these events.
Expand Down
2 changes: 1 addition & 1 deletion Doc/library/decimal.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1517,7 +1517,7 @@ are also included in the pure Python version for compatibility.
the C version uses a thread-local rather than a coroutine-local context and the value
is ``False``. This is slightly faster in some nested context scenarios.

.. versionadded:: 3.9 backported to 3.7 and 3.8.
.. versionadded:: 3.8.3


Rounding modes
Expand Down
12 changes: 1 addition & 11 deletions Doc/library/ipaddress.rst
Original file line number Diff line number Diff line change
Expand Up @@ -121,22 +121,12 @@ write code that handles both IP versions correctly. Address objects are
Leading zeros are tolerated, even in ambiguous cases that look like
octal notation.

.. versionchanged:: 3.10
.. versionchanged:: 3.9.5

Leading zeros are no longer tolerated and are treated as an error.
IPv4 address strings are now parsed as strict as glibc
:func:`~socket.inet_pton`.

.. versionchanged:: 3.9.5

The above change was also included in Python 3.9 starting with
version 3.9.5.

.. versionchanged:: 3.8.12

The above change was also included in Python 3.8 starting with
version 3.8.12.

.. attribute:: version

The appropriate version number: ``4`` for IPv4, ``6`` for IPv6.
Expand Down
6 changes: 3 additions & 3 deletions Doc/library/ssl.rst
Original file line number Diff line number Diff line change
Expand Up @@ -735,11 +735,11 @@ Constants
When Python has been compiled against an older version of OpenSSL, the
flag defaults to *0*.

.. versionadded:: 3.7
.. versionadded:: 3.6.3

.. deprecated:: 3.7
The option is deprecated since OpenSSL 1.1.0. It was added to 2.7.15,
3.6.3 and 3.7.0 for backwards compatibility with OpenSSL 1.0.2.
The option is deprecated since OpenSSL 1.1.0. It was added to 2.7.15 and
3.6.3 for backwards compatibility with OpenSSL 1.0.2.

.. data:: OP_NO_RENEGOTIATION

Expand Down
8 changes: 1 addition & 7 deletions Doc/library/typing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -944,7 +944,6 @@ using ``[]``.
be used for this concept instead. Type checkers should treat the two
equivalently.

.. versionadded:: 3.5.4
.. versionadded:: 3.6.2

.. data:: Self
Expand Down Expand Up @@ -3234,7 +3233,6 @@ Aliases to types in :mod:`collections`

Deprecated alias to :class:`collections.ChainMap`.

.. versionadded:: 3.5.4
.. versionadded:: 3.6.1

.. deprecated:: 3.9
Expand All @@ -3245,7 +3243,6 @@ Aliases to types in :mod:`collections`

Deprecated alias to :class:`collections.Counter`.

.. versionadded:: 3.5.4
.. versionadded:: 3.6.1

.. deprecated:: 3.9
Expand All @@ -3256,7 +3253,6 @@ Aliases to types in :mod:`collections`

Deprecated alias to :class:`collections.deque`.

.. versionadded:: 3.5.4
.. versionadded:: 3.6.1

.. deprecated:: 3.9
Expand Down Expand Up @@ -3339,7 +3335,7 @@ Aliases to container ABCs in :mod:`collections.abc`

Deprecated alias to :class:`collections.abc.Collection`.

.. versionadded:: 3.6.0
.. versionadded:: 3.6

.. deprecated:: 3.9
:class:`collections.abc.Collection` now supports subscripting (``[]``).
Expand Down Expand Up @@ -3631,7 +3627,6 @@ Aliases to :mod:`contextlib` ABCs
Deprecated alias to :class:`contextlib.AbstractContextManager`.

.. versionadded:: 3.5.4
.. versionadded:: 3.6.0

.. deprecated:: 3.9
:class:`contextlib.AbstractContextManager`
Expand All @@ -3642,7 +3637,6 @@ Aliases to :mod:`contextlib` ABCs

Deprecated alias to :class:`contextlib.AbstractAsyncContextManager`.

.. versionadded:: 3.5.4
.. versionadded:: 3.6.2

.. deprecated:: 3.9
Expand Down
34 changes: 21 additions & 13 deletions Doc/using/configure.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
Configure Python
****************

.. highlight:: sh

Build Requirements
==================

Expand All @@ -22,22 +24,22 @@ Features required to build CPython:

* On Windows, Microsoft Visual Studio 2017 or later is required.

.. versionchanged:: 3.11
C11 compiler, IEEE 754 and NaN support are now required.
On Windows, Visual Studio 2017 or later is required.
.. versionchanged:: 3.5
On Windows, Visual Studio 2015 or later is required.

.. versionchanged:: 3.10
OpenSSL 1.1.1 is now required.
.. versionchanged:: 3.6
Selected C99 features are now required, like ``<stdint.h>`` and ``static
inline`` functions.

.. versionchanged:: 3.7
Thread support and OpenSSL 1.0.2 are now required.

.. versionchanged:: 3.6
Selected C99 features are now required, like ``<stdint.h>`` and ``static
inline`` functions.
.. versionchanged:: 3.10
OpenSSL 1.1.1 is now required.

.. versionchanged:: 3.5
On Windows, Visual Studio 2015 or later is required.
.. versionchanged:: 3.11
C11 compiler, IEEE 754 and NaN support are now required.
On Windows, Visual Studio 2017 or later is required.

See also :pep:`7` "Style Guide for C Code" and :pep:`11` "CPython platform
support".
Expand Down Expand Up @@ -689,7 +691,9 @@ the version of the cross compiled host Python.

An environment variable that points to a file with configure overrides.

Example *config.site* file::
Example *config.site* file:

.. code-block:: ini
# config.site-aarch64
ac_cv_buggy_getaddrinfo=no
Expand Down Expand Up @@ -752,7 +756,9 @@ C extensions

Some C extensions are built as built-in modules, like the ``sys`` module.
They are built with the ``Py_BUILD_CORE_BUILTIN`` macro defined.
Built-in modules have no ``__file__`` attribute::
Built-in modules have no ``__file__`` attribute:

.. code-block:: pycon
>>> import sys
>>> sys
Expand All @@ -764,7 +770,9 @@ Built-in modules have no ``__file__`` attribute::
Other C extensions are built as dynamic libraries, like the ``_asyncio`` module.
They are built with the ``Py_BUILD_CORE_MODULE`` macro defined.
Example on Linux x86-64::
Example on Linux x86-64:

.. code-block:: pycon
>>> import _asyncio
>>> _asyncio
Expand Down
2 changes: 1 addition & 1 deletion Lib/email/generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ def _handle_text(self, msg):
# existing message.
msg = deepcopy(msg)
del msg['content-transfer-encoding']
msg.set_payload(payload, charset)
msg.set_payload(msg._payload, charset)
payload = msg.get_payload()
self._munge_cte = (msg['content-transfer-encoding'],
msg['content-type'])
Expand Down
2 changes: 1 addition & 1 deletion Lib/email/message.py
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,7 @@ def set_payload(self, payload, charset=None):
return
if not isinstance(charset, Charset):
charset = Charset(charset)
payload = payload.encode(charset.output_charset)
payload = payload.encode(charset.output_charset, 'surrogateescape')
if hasattr(payload, 'decode'):
self._payload = payload.decode('ascii', 'surrogateescape')
else:
Expand Down
15 changes: 15 additions & 0 deletions Lib/test/test_email/test_email.py
Original file line number Diff line number Diff line change
Expand Up @@ -336,6 +336,21 @@ def test_nonascii_as_string_without_cte(self):
msg = email.message_from_bytes(source)
self.assertEqual(msg.as_string(), expected)

def test_nonascii_as_string_with_ascii_charset(self):
m = textwrap.dedent("""\
MIME-Version: 1.0
Content-type: text/plain; charset="us-ascii"
Content-Transfer-Encoding: 8bit
Test if non-ascii messages with no Content-Transfer-Encoding set
can be as_string'd:
Föö bär
""")
source = m.encode('iso-8859-1')
expected = source.decode('ascii', 'replace')
msg = email.message_from_bytes(source)
self.assertEqual(msg.as_string(), expected)

def test_nonascii_as_string_without_content_type_and_cte(self):
m = textwrap.dedent("""\
MIME-Version: 1.0
Expand Down
6 changes: 6 additions & 0 deletions Lib/test/test_typing.py
Original file line number Diff line number Diff line change
Expand Up @@ -5655,6 +5655,12 @@ def foo(a: 'Node[T'):
with self.assertRaises(SyntaxError):
get_type_hints(foo)

def test_syntax_error_empty_string(self):
for form in [typing.List, typing.Set, typing.Type, typing.Deque]:
with self.subTest(form=form):
with self.assertRaises(SyntaxError):
form['']

def test_name_error(self):

def foo(a: 'Noode[T]'):
Expand Down
37 changes: 35 additions & 2 deletions Lib/test/test_urlparse.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@
("=a", [('', 'a')]),
("a", [('a', '')]),
("a=", [('a', '')]),
("a=b=c", [('a', 'b=c')]),
("a%3Db=c", [('a=b', 'c')]),
("a=b&c=d", [('a', 'b'), ('c', 'd')]),
("a=b%26c=d", [('a', 'b&c=d')]),
("&a=b", [('a', 'b')]),
("a=a+b&b=b+c", [('a', 'a b'), ('b', 'b c')]),
("a=1&a=2", [('a', '1'), ('a', '2')]),
Expand All @@ -29,13 +33,25 @@
(b"=a", [(b'', b'a')]),
(b"a", [(b'a', b'')]),
(b"a=", [(b'a', b'')]),
(b"a=b=c", [(b'a', b'b=c')]),
(b"a%3Db=c", [(b'a=b', b'c')]),
(b"a=b&c=d", [(b'a', b'b'), (b'c', b'd')]),
(b"a=b%26c=d", [(b'a', b'b&c=d')]),
(b"&a=b", [(b'a', b'b')]),
(b"a=a+b&b=b+c", [(b'a', b'a b'), (b'b', b'b c')]),
(b"a=1&a=2", [(b'a', b'1'), (b'a', b'2')]),
(";a=b", [(';a', 'b')]),
("a=a+b;b=b+c", [('a', 'a b;b=b c')]),
(b";a=b", [(b';a', b'b')]),
(b"a=a+b;b=b+c", [(b'a', b'a b;b=b c')]),

("\u0141=\xE9", [('\u0141', '\xE9')]),
("%C5%81=%C3%A9", [('\u0141', '\xE9')]),
("%81=%A9", [('\ufffd', '\ufffd')]),
(b"\xc5\x81=\xc3\xa9", [(b'\xc5\x81', b'\xc3\xa9')]),
(b"%C5%81=%C3%A9", [(b'\xc5\x81', b'\xc3\xa9')]),
(b"\x81=\xA9", [(b'\x81', b'\xa9')]),
(b"%81=%A9", [(b'\x81', b'\xa9')]),
]

# Each parse_qs testcase is a two-tuple that contains
Expand All @@ -49,6 +65,10 @@
("=a", {'': ['a']}),
("a", {'a': ['']}),
("a=", {'a': ['']}),
("a=b=c", {'a': ['b=c']}),
("a%3Db=c", {'a=b': ['c']}),
("a=b&c=d", {'a': ['b'], 'c': ['d']}),
("a=b%26c=d", {'a': ['b&c=d']}),
("&a=b", {'a': ['b']}),
("a=a+b&b=b+c", {'a': ['a b'], 'b': ['b c']}),
("a=1&a=2", {'a': ['1', '2']}),
Expand All @@ -59,13 +79,26 @@
(b"=a", {b'': [b'a']}),
(b"a", {b'a': [b'']}),
(b"a=", {b'a': [b'']}),
(b"a=b=c", {b'a': [b'b=c']}),
(b"a%3Db=c", {b'a=b': [b'c']}),
(b"a=b&c=d", {b'a': [b'b'], b'c': [b'd']}),
(b"a=b%26c=d", {b'a': [b'b&c=d']}),
(b"&a=b", {b'a': [b'b']}),
(b"a=a+b&b=b+c", {b'a': [b'a b'], b'b': [b'b c']}),
(b"a=1&a=2", {b'a': [b'1', b'2']}),
(";a=b", {';a': ['b']}),
("a=a+b;b=b+c", {'a': ['a b;b=b c']}),
(b";a=b", {b';a': [b'b']}),
(b"a=a+b;b=b+c", {b'a':[ b'a b;b=b c']}),
(b"a=a%E2%80%99b", {b'a': [b'a\xe2\x80\x99b']}),

("\u0141=\xE9", {'\u0141': ['\xE9']}),
("%C5%81=%C3%A9", {'\u0141': ['\xE9']}),
("%81=%A9", {'\ufffd': ['\ufffd']}),
(b"\xc5\x81=\xc3\xa9", {b'\xc5\x81': [b'\xc3\xa9']}),
(b"%C5%81=%C3%A9", {b'\xc5\x81': [b'\xc3\xa9']}),
(b"\x81=\xA9", {b'\x81': [b'\xa9']}),
(b"%81=%A9", {b'\x81': [b'\xa9']}),
]

class UrlParseTestCase(unittest.TestCase):
Expand Down Expand Up @@ -995,8 +1028,8 @@ def test_parse_qsl_encoding(self):

def test_parse_qsl_max_num_fields(self):
with self.assertRaises(ValueError):
urllib.parse.parse_qs('&'.join(['a=a']*11), max_num_fields=10)
urllib.parse.parse_qs('&'.join(['a=a']*10), max_num_fields=10)
urllib.parse.parse_qsl('&'.join(['a=a']*11), max_num_fields=10)
urllib.parse.parse_qsl('&'.join(['a=a']*10), max_num_fields=10)

def test_parse_qs_separator(self):
parse_qs_semicolon_cases = [
Expand Down
2 changes: 1 addition & 1 deletion Lib/typing.py
Original file line number Diff line number Diff line change
Expand Up @@ -886,7 +886,7 @@ def __init__(self, arg, is_argument=True, module=None, *, is_class=False):
# If we do `def f(*args: *Ts)`, then we'll have `arg = '*Ts'`.
# Unfortunately, this isn't a valid expression on its own, so we
# do the unpacking manually.
if arg[0] == '*':
if arg.startswith('*'):
arg_to_compile = f'({arg},)[0]' # E.g. (*Ts,)[0] or (*tuple[int, int],)[0]
else:
arg_to_compile = arg
Expand Down
Loading

0 comments on commit dcc07d3

Please sign in to comment.