Skip to content

Commit 31c3bb9

Browse files
committed
Merge main into multiply
2 parents 7aecc97 + 3901c08 commit 31c3bb9

File tree

164 files changed

+1884
-1229
lines changed

Some content is hidden

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

164 files changed

+1884
-1229
lines changed

Doc/faq/programming.rst

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -836,6 +836,27 @@ ago? ``-190 % 12 == 2`` is useful; ``-190 % 12 == -10`` is a bug waiting to
836836
bite.
837837

838838

839+
How do I get int literal attribute instead of SyntaxError?
840+
----------------------------------------------------------
841+
842+
Trying to lookup an ``int`` literal attribute in the normal manner gives
843+
a syntax error because the period is seen as a decimal point::
844+
845+
>>> 1.__class__
846+
File "<stdin>", line 1
847+
1.__class__
848+
^
849+
SyntaxError: invalid decimal literal
850+
851+
The solution is to separate the literal from the period
852+
with either a space or parentheses.
853+
854+
>>> 1 .__class__
855+
<class 'int'>
856+
>>> (1).__class__
857+
<class 'int'>
858+
859+
839860
How do I convert a string to a number?
840861
--------------------------------------
841862

Doc/library/asyncio-stream.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -395,8 +395,8 @@ TCP echo server using the :func:`asyncio.start_server` function::
395395
server = await asyncio.start_server(
396396
handle_echo, '127.0.0.1', 8888)
397397

398-
addr = server.sockets[0].getsockname()
399-
print(f'Serving on {addr}')
398+
addrs = ', '.join(str(sock.getsockname()) for sock in server.sockets)
399+
print(f'Serving on {addrs}')
400400

401401
async with server:
402402
await server.serve_forever()

Doc/library/csv.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -383,6 +383,8 @@ Dialects support the following attributes:
383383
:const:`False`. On reading, the *escapechar* removes any special meaning from
384384
the following character. It defaults to :const:`None`, which disables escaping.
385385

386+
.. versionchanged:: 3.11
387+
An empty *escapechar* is not allowed.
386388

387389
.. attribute:: Dialect.lineterminator
388390

@@ -402,6 +404,8 @@ Dialects support the following attributes:
402404
as the *delimiter* or *quotechar*, or which contain new-line characters. It
403405
defaults to ``'"'``.
404406

407+
.. versionchanged:: 3.11
408+
An empty *quotechar* is not allowed.
405409

406410
.. attribute:: Dialect.quoting
407411

Doc/library/hashlib.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -500,7 +500,7 @@ Keyed hashing
500500

501501
Keyed hashing can be used for authentication as a faster and simpler
502502
replacement for `Hash-based message authentication code
503-
<https://en.wikipedia.org/wiki/Hash-based_message_authentication_code>`_ (HMAC).
503+
<https://en.wikipedia.org/wiki/HMAC>`_ (HMAC).
504504
BLAKE2 can be securely used in prefix-MAC mode thanks to the
505505
indifferentiability property inherited from BLAKE.
506506

Doc/library/html.entities.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,4 +44,4 @@ This module defines four dictionaries, :data:`html5`,
4444

4545
.. rubric:: Footnotes
4646

47-
.. [#] See https://www.w3.org/TR/html5/syntax.html#named-character-references
47+
.. [#] See https://html.spec.whatwg.org/multipage/syntax.html#named-character-references

Doc/library/http.cookiejar.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ The following classes are provided:
122122
:mod:`http.cookiejar` and :mod:`http.cookies` modules do not depend on each
123123
other.
124124

125-
https://curl.haxx.se/rfc/cookie_spec.html
125+
https://curl.se/rfc/cookie_spec.html
126126
The specification of the original Netscape cookie protocol. Though this is
127127
still the dominant protocol, the 'Netscape cookie protocol' implemented by all
128128
the major browsers (and :mod:`http.cookiejar`) only bears a passing resemblance to

Doc/library/ipaddress.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -682,7 +682,7 @@ dictionaries.
682682

683683
Note that currently expanded netmasks are not supported. That means
684684
``2001:db00::0/24`` is a valid argument while ``2001:db00::0/ffff:ff00::``
685-
not.
685+
is not.
686686

687687
2. An integer that fits into 128 bits. This is equivalent to a
688688
single-address network, with the network address being *address* and

Doc/library/json.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@
1111

1212
--------------
1313

14-
`JSON (JavaScript Object Notation) <http://json.org>`_, specified by
14+
`JSON (JavaScript Object Notation) <https://json.org>`_, specified by
1515
:rfc:`7159` (which obsoletes :rfc:`4627`) and by
16-
`ECMA-404 <http://www.ecma-international.org/publications/standards/Ecma-404.htm>`_,
16+
`ECMA-404 <https://www.ecma-international.org/publications-and-standards/standards/ecma-404/>`_,
1717
is a lightweight data interchange format inspired by
1818
`JavaScript <https://en.wikipedia.org/wiki/JavaScript>`_ object literal syntax
1919
(although it is not a strict subset of JavaScript [#rfc-errata]_ ).
@@ -544,7 +544,7 @@ Standard Compliance and Interoperability
544544
----------------------------------------
545545

546546
The JSON format is specified by :rfc:`7159` and by
547-
`ECMA-404 <http://www.ecma-international.org/publications/standards/Ecma-404.htm>`_.
547+
`ECMA-404 <https://www.ecma-international.org/publications-and-standards/standards/ecma-404/>`_.
548548
This section details this module's level of compliance with the RFC.
549549
For simplicity, :class:`JSONEncoder` and :class:`JSONDecoder` subclasses, and
550550
parameters other than those explicitly mentioned, are not considered.

Doc/library/test.rst

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -607,6 +607,15 @@ The :mod:`test.support` module defines the following functions:
607607
target of the "as" clause, if there is one.
608608

609609

610+
.. function:: flush_std_streams()
611+
612+
Call the ``flush()`` method on :data:`sys.stdout` and then on
613+
:data:`sys.stderr`. It can be used to make sure that the logs order is
614+
consistent before writing into stderr.
615+
616+
.. versionadded:: 3.11
617+
618+
610619
.. function:: print_warning(msg)
611620

612621
Print a warning into :data:`sys.__stderr__`. Format the message as:

Doc/library/xml.dom.minidom.rst

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,9 @@ module documentation. This section lists the differences between the API and
156156
The :meth:`writexml` method now preserves the attribute order specified
157157
by the user.
158158

159+
.. versionchanged:: 3.9
160+
The *standalone* parameter was added.
161+
159162
.. method:: Node.toxml(encoding=None, standalone=None)
160163

161164
Return a string or byte string containing the XML represented by
@@ -174,6 +177,9 @@ module documentation. This section lists the differences between the API and
174177
The :meth:`toxml` method now preserves the attribute order specified
175178
by the user.
176179

180+
.. versionchanged:: 3.9
181+
The *standalone* parameter was added.
182+
177183
.. method:: Node.toprettyxml(indent="\\t", newl="\\n", encoding=None, \
178184
standalone=None)
179185

@@ -190,6 +196,8 @@ module documentation. This section lists the differences between the API and
190196
The :meth:`toprettyxml` method now preserves the attribute order specified
191197
by the user.
192198

199+
.. versionchanged:: 3.9
200+
The *standalone* parameter was added.
193201

194202
.. _dom-example:
195203

Doc/reference/compound_stmts.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1017,7 +1017,7 @@ A class pattern represents a class and its positional and keyword arguments
10171017

10181018
The same keyword should not be repeated in class patterns.
10191019

1020-
The following is the logical flow for matching a mapping pattern against a
1020+
The following is the logical flow for matching a class pattern against a
10211021
subject value:
10221022

10231023
#. If ``name_or_attr`` is not an instance of the builtin :class:`type` , raise

Doc/using/configure.rst

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -416,15 +416,19 @@ Libraries options
416416
Security Options
417417
----------------
418418

419-
.. cmdoption:: --with-hash-algorithm=[fnv|siphash24]
419+
.. cmdoption:: --with-hash-algorithm=[fnv|siphash13|siphash24]
420420

421421
Select hash algorithm for use in ``Python/pyhash.c``:
422422

423-
* ``siphash24`` (default).
424-
* ``fnv``;
423+
* ``siphash13`` (default);
424+
* ``siphash24``;
425+
* ``fnv``.
425426

426427
.. versionadded:: 3.4
427428

429+
.. versionadded:: 3.11
430+
``siphash13`` is added and it is the new default.
431+
428432
.. cmdoption:: --with-builtin-hashlib-hashes=md5,sha1,sha256,sha512,sha3,blake2
429433

430434
Built-in hash modules:

Doc/whatsnew/3.11.rst

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,11 @@ Other CPython Implementation Changes
175175
support :class:`typing.SupportsComplex` and :class:`typing.SupportsBytes` protocols.
176176
(Contributed by Mark Dickinson and Dong-hee Na in :issue:`24234`.)
177177

178+
* ``siphash13`` is added as a new internal hashing algorithms. It's has similar security
179+
properties as ``siphash24`` but it is slightly faster for long inputs. ``str``, ``bytes``,
180+
and some other types now use it as default algorithm for ``hash()``. :pep:`552`
181+
hash-based pyc files now use ``siphash13``, too.
182+
(Contributed by Inada Naoki in :issue:`29410`.)
178183

179184
New Modules
180185
===========
@@ -452,6 +457,8 @@ Build Changes
452457
* CPython can now be built with the ThinLTO option via ``--with-lto=thin``.
453458
(Contributed by Dong-hee Na and Brett Holman in :issue:`44340`.)
454459

460+
* libpython is no longer linked against libcrypt.
461+
(Contributed by Mike Gilbert in :issue:`45433`.)
455462

456463
C API Changes
457464
=============
@@ -547,6 +554,10 @@ Porting to Python 3.11
547554

548555
(Contributed by Victor Stinner in :issue:`39573`.)
549556

557+
* The ``<Python.h>`` header file no longer includes ``<stdlib.h>``. C
558+
extensions using ``<stdlib.h>`` must now include it explicitly.
559+
(Contributed by Victor Stinner in :issue:`45434`.)
560+
550561
Deprecated
551562
----------
552563

@@ -572,3 +583,22 @@ Removed
572583
Use the new :c:type:`PyConfig` API of the :ref:`Python Initialization Configuration
573584
<init-config>` instead (:pep:`587`).
574585
(Contributed by Victor Stinner in :issue:`44113`.)
586+
587+
* Remove the following math macros using the ``errno`` variable:
588+
589+
* ``Py_ADJUST_ERANGE1()``
590+
* ``Py_ADJUST_ERANGE2()``
591+
* ``Py_OVERFLOWED()``
592+
* ``Py_SET_ERANGE_IF_OVERFLOW()``
593+
* ``Py_SET_ERRNO_ON_MATH_ERROR()``
594+
595+
(Contributed by Victor Stinner in :issue:`45412`.)
596+
597+
* Remove ``Py_UNICODE_COPY()`` and ``Py_UNICODE_FILL()`` macros, deprecated
598+
since Python 3.3. Use ``PyUnicode_CopyCharacters()`` or ``memcpy()``
599+
(``wchar_t*`` string), and ``PyUnicode_Fill()`` functions instead.
600+
(Contributed by Victor Stinner in :issue:`41123`.)
601+
602+
* Remove the ``pystrhex.h`` header file. It only contains private functions.
603+
C extensions should only include the main ``<Python.h>`` header file.
604+
(Contributed by Victor Stinner in :issue:`45434`.)

Include/Python.h

Lines changed: 13 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -1,83 +1,49 @@
1+
// Entry point of the Python C API.
2+
// C extensions should only #include <Python.h>, and not include directly
3+
// the other Python header files included by <Python.h>.
4+
15
#ifndef Py_PYTHON_H
26
#define Py_PYTHON_H
3-
/* Since this is a "meta-include" file, no #ifdef __cplusplus / extern "C" { */
47

5-
/* Include nearly all Python header files */
8+
// Since this is a "meta-include" file, no #ifdef __cplusplus / extern "C" {
69

10+
// Include Python header files
711
#include "patchlevel.h"
812
#include "pyconfig.h"
913
#include "pymacconfig.h"
1014

11-
#include <limits.h>
12-
13-
#ifndef UCHAR_MAX
14-
#error "Something's broken. UCHAR_MAX should be defined in limits.h."
15-
#endif
16-
17-
#if UCHAR_MAX != 255
18-
#error "Python's source code assumes C's unsigned char is an 8-bit type."
19-
#endif
20-
2115
#if defined(__sgi) && !defined(_SGI_MP_SOURCE)
22-
#define _SGI_MP_SOURCE
16+
# define _SGI_MP_SOURCE
2317
#endif
2418

25-
#include <stdio.h>
19+
#include <stdio.h> // NULL, FILE*
2620
#ifndef NULL
2721
# error "Python.h requires that stdio.h define NULL."
2822
#endif
2923

30-
#include <string.h>
24+
#include <string.h> // memcpy()
3125
#ifdef HAVE_ERRNO_H
32-
#include <errno.h>
26+
# include <errno.h> // errno
3327
#endif
34-
#include <stdlib.h>
3528
#ifndef MS_WINDOWS
36-
#include <unistd.h>
29+
# include <unistd.h>
3730
#endif
38-
39-
/* For size_t? */
4031
#ifdef HAVE_STDDEF_H
41-
#include <stddef.h>
32+
// For size_t
33+
# include <stddef.h>
4234
#endif
4335

44-
/* CAUTION: Build setups should ensure that NDEBUG is defined on the
45-
* compiler command line when building Python in release mode; else
46-
* assert() calls won't be removed.
47-
*/
4836
#include <assert.h>
4937

5038
#include "pyport.h"
5139
#include "pymacro.h"
52-
53-
/* A convenient way for code to know if sanitizers are enabled. */
54-
#if defined(__has_feature)
55-
# if __has_feature(memory_sanitizer)
56-
# if !defined(_Py_MEMORY_SANITIZER)
57-
# define _Py_MEMORY_SANITIZER
58-
# endif
59-
# endif
60-
# if __has_feature(address_sanitizer)
61-
# if !defined(_Py_ADDRESS_SANITIZER)
62-
# define _Py_ADDRESS_SANITIZER
63-
# endif
64-
# endif
65-
#elif defined(__GNUC__)
66-
# if defined(__SANITIZE_ADDRESS__)
67-
# define _Py_ADDRESS_SANITIZER
68-
# endif
69-
#endif
70-
7140
#include "pymath.h"
7241
#include "pymem.h"
73-
7442
#include "object.h"
7543
#include "objimpl.h"
7644
#include "typeslots.h"
7745
#include "pyhash.h"
78-
7946
#include "cpython/pydebug.h"
80-
8147
#include "bytearrayobject.h"
8248
#include "bytesobject.h"
8349
#include "unicodeobject.h"
@@ -115,15 +81,12 @@
11581
#include "namespaceobject.h"
11682
#include "cpython/picklebufobject.h"
11783
#include "cpython/pytime.h"
118-
11984
#include "codecs.h"
12085
#include "pyerrors.h"
121-
12286
#include "cpython/initconfig.h"
12387
#include "pythread.h"
12488
#include "pystate.h"
12589
#include "context.h"
126-
12790
#include "modsupport.h"
12891
#include "compile.h"
12992
#include "pythonrun.h"
@@ -133,12 +96,9 @@
13396
#include "osmodule.h"
13497
#include "intrcheck.h"
13598
#include "import.h"
136-
13799
#include "abstract.h"
138100
#include "bltinmodule.h"
139-
140101
#include "eval.h"
141-
142102
#include "cpython/pyctype.h"
143103
#include "pystrtod.h"
144104
#include "pystrcmp.h"

Include/bytearrayobject.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@
66
extern "C" {
77
#endif
88

9-
#include <stdarg.h>
10-
119
/* Type PyByteArrayObject represents a mutable array of bytes.
1210
* The Python API is that of a sequence;
1311
* the bytes are mapped to ints in [0, 256).

Include/bytesobject.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
extern "C" {
88
#endif
99

10-
#include <stdarg.h>
10+
#include <stdarg.h> // va_list
1111

1212
/*
1313
Type PyBytesObject represents a byte string. An extra zero byte is

0 commit comments

Comments
 (0)