Skip to content

Commit 7b2efa4

Browse files
committed
Merge branch 'main' into inline-attributes-with-opt
2 parents b25b1d9 + f79f3b4 commit 7b2efa4

Some content is hidden

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

60 files changed

+544
-483
lines changed

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/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/whatsnew/3.11.rst

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -457,6 +457,8 @@ Build Changes
457457
* CPython can now be built with the ThinLTO option via ``--with-lto=thin``.
458458
(Contributed by Dong-hee Na and Brett Holman in :issue:`44340`.)
459459

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

461463
C API Changes
462464
=============
@@ -552,6 +554,10 @@ Porting to Python 3.11
552554

553555
(Contributed by Victor Stinner in :issue:`39573`.)
554556

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+
555561
Deprecated
556562
----------
557563

@@ -577,3 +583,18 @@ Removed
577583
Use the new :c:type:`PyConfig` API of the :ref:`Python Initialization Configuration
578584
<init-config>` instead (:pep:`587`).
579585
(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`.)

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/cpython/abstract.h

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ PyVectorcall_Function(PyObject *callable)
7171
return NULL;
7272
}
7373
assert(PyCallable_Check(callable));
74+
7475
offset = tp->tp_vectorcall_offset;
7576
assert(offset > 0);
7677
memcpy(&ptr, (char *) callable + offset, sizeof(ptr));
@@ -159,15 +160,6 @@ _PyObject_FastCall(PyObject *func, PyObject *const *args, Py_ssize_t nargs)
159160
return _PyObject_FastCallTstate(tstate, func, args, nargs);
160161
}
161162

162-
/* Call a callable without any arguments
163-
Private static inline function variant of public function
164-
PyObject_CallNoArgs(). */
165-
static inline PyObject *
166-
_PyObject_CallNoArg(PyObject *func) {
167-
PyThreadState *tstate = PyThreadState_Get();
168-
return _PyObject_VectorcallTstate(tstate, func, NULL, 0, NULL);
169-
}
170-
171163
static inline PyObject *
172164
PyObject_CallOneArg(PyObject *func, PyObject *arg)
173165
{

Include/cpython/unicodeobject.h

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -50,19 +50,6 @@
5050
Py_UNICODE_ISDIGIT(ch) || \
5151
Py_UNICODE_ISNUMERIC(ch))
5252

53-
Py_DEPRECATED(3.3) static inline void
54-
Py_UNICODE_COPY(Py_UNICODE *target, const Py_UNICODE *source, Py_ssize_t length) {
55-
memcpy(target, source, (size_t)(length) * sizeof(Py_UNICODE));
56-
}
57-
58-
Py_DEPRECATED(3.3) static inline void
59-
Py_UNICODE_FILL(Py_UNICODE *target, Py_UNICODE value, Py_ssize_t length) {
60-
Py_ssize_t i;
61-
for (i = 0; i < length; i++) {
62-
target[i] = value;
63-
}
64-
}
65-
6653
/* macros to work with surrogates */
6754
#define Py_UNICODE_IS_SURROGATE(ch) (0xD800 <= (ch) && (ch) <= 0xDFFF)
6855
#define Py_UNICODE_IS_HIGH_SURROGATE(ch) (0xD800 <= (ch) && (ch) <= 0xDBFF)

Include/internal/pycore_call.h

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,14 @@ PyAPI_FUNC(PyObject *) _PyObject_Call(
2929
PyObject *kwargs);
3030

3131
static inline PyObject *
32-
_PyObject_CallNoArgTstate(PyThreadState *tstate, PyObject *func) {
32+
_PyObject_CallNoArgsTstate(PyThreadState *tstate, PyObject *func) {
33+
return _PyObject_VectorcallTstate(tstate, func, NULL, 0, NULL);
34+
}
35+
36+
// Private static inline function variant of public PyObject_CallNoArgs()
37+
static inline PyObject *
38+
_PyObject_CallNoArgs(PyObject *func) {
39+
PyThreadState *tstate = PyThreadState_Get();
3340
return _PyObject_VectorcallTstate(tstate, func, NULL, 0, NULL);
3441
}
3542

0 commit comments

Comments
 (0)