Skip to content

Commit 77cf187

Browse files
committed
Merge branch 'main' into lazy-frame
2 parents 2cad33b + aab1899 commit 77cf187

File tree

88 files changed

+6215
-5194
lines changed

Some content is hidden

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

88 files changed

+6215
-5194
lines changed

.github/CODEOWNERS

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ Lib/ast.py @isidentical
128128

129129
**/*idlelib* @terryjreedy
130130

131-
**/*typing* @gvanrossum @ilevkivskyi
131+
**/*typing* @gvanrossum @Fidget-Spinner
132132

133133
**/*asyncore @giampaolo
134134
**/*asynchat @giampaolo

Doc/distributing/index.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -131,11 +131,11 @@ involved in creating and publishing a project:
131131
* `The .pypirc file`_
132132

133133
.. _Project structure: \
134-
https://packaging.python.org/tutorials/distributing-packages/
134+
https://packaging.python.org/tutorials/packaging-projects/#packaging-python-projects
135135
.. _Building and packaging the project: \
136-
https://packaging.python.org/tutorials/distributing-packages/#packaging-your-project
136+
https://packaging.python.org/tutorials/packaging-projects/#creating-the-package-files
137137
.. _Uploading the project to the Python Packaging Index: \
138-
https://packaging.python.org/tutorials/distributing-packages/#uploading-your-project-to-pypi
138+
https://packaging.python.org/tutorials/packaging-projects/#uploading-the-distribution-archives
139139
.. _The .pypirc file: \
140140
https://packaging.python.org/specifications/pypirc/
141141

Doc/library/binascii.rst

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,11 +50,23 @@ The :mod:`binascii` module defines the following functions:
5050
Added the *backtick* parameter.
5151

5252

53-
.. function:: a2b_base64(string)
53+
.. function:: a2b_base64(string, strict_mode=False)
5454

5555
Convert a block of base64 data back to binary and return the binary data. More
5656
than one line may be passed at a time.
5757

58+
If *strict_mode* is true, only valid base64 data will be converted. Invalid base64
59+
data will raise :exc:`binascii.Error`.
60+
61+
Valid base64:
62+
* Conforms to :rfc:`3548`.
63+
* Contains only characters from the base64 alphabet.
64+
* Contains no excess data after padding (including excess padding, newlines, etc.).
65+
* Does not start with a padding.
66+
67+
.. versionchanged:: 3.11
68+
Added the *strict_mode* parameter.
69+
5870

5971
.. function:: b2a_base64(data, *, newline=True)
6072

Doc/library/pprint.rst

Lines changed: 14 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@ The :mod:`pprint` module defines one class:
4646

4747
*stream* (default ``sys.stdout``) is a :term:`file-like object` to
4848
which the output will be written by calling its :meth:`write` method.
49+
If both *stream* and ``sys.stdout`` are ``None``, then
50+
:meth:`~PrettyPrinter.pprint` silently returns.
4951

5052
Other values configure the manner in which nesting of complex data
5153
structures is displayed.
@@ -84,6 +86,9 @@ The :mod:`pprint` module defines one class:
8486
.. versionchanged:: 3.10
8587
Added the *underscore_numbers* parameter.
8688

89+
.. versionchanged:: 3.11
90+
No longer attempts to write to ``sys.stdout`` if it is ``None``.
91+
8792
>>> import pprint
8893
>>> stuff = ['spam', 'eggs', 'lumberjack', 'knights', 'ni']
8994
>>> stuff.insert(0, stuff[:])
@@ -107,24 +112,13 @@ The :mod:`pprint` module defines one class:
107112
>>> pp.pprint(tup)
108113
('spam', ('eggs', ('lumberjack', ('knights', ('ni', ('dead', (...)))))))
109114

110-
111-
The :mod:`pprint` module also provides several shortcut functions:
112-
113115
.. function:: pformat(object, indent=1, width=80, depth=None, *, \
114116
compact=False, sort_dicts=True, underscore_numbers=False)
115117

116118
Return the formatted representation of *object* as a string. *indent*,
117-
*width*, *depth*, *compact*, *sort_dicts* and *underscore_numbers* will be passed to the
118-
:class:`PrettyPrinter` constructor as formatting parameters.
119-
120-
.. versionchanged:: 3.4
121-
Added the *compact* parameter.
122-
123-
.. versionchanged:: 3.8
124-
Added the *sort_dicts* parameter.
125-
126-
.. versionchanged:: 3.10
127-
Added the *underscore_numbers* parameter.
119+
*width*, *depth*, *compact*, *sort_dicts* and *underscore_numbers* are
120+
passed to the :class:`PrettyPrinter` constructor as formatting parameters
121+
and their meanings are as described in its documentation above.
128122

129123

130124
.. function:: pp(object, *args, sort_dicts=False, **kwargs)
@@ -142,20 +136,15 @@ The :mod:`pprint` module also provides several shortcut functions:
142136
compact=False, sort_dicts=True, underscore_numbers=False)
143137

144138
Prints the formatted representation of *object* on *stream*, followed by a
145-
newline. If *stream* is ``None``, ``sys.stdout`` is used. This may be used
139+
newline. If *stream* is ``None``, ``sys.stdout`` is used. This may be used
146140
in the interactive interpreter instead of the :func:`print` function for
147141
inspecting values (you can even reassign ``print = pprint.pprint`` for use
148-
within a scope). *indent*, *width*, *depth*, *compact*, *sort_dicts* and *underscore_numbers* will
149-
be passed to the :class:`PrettyPrinter` constructor as formatting parameters.
150-
151-
.. versionchanged:: 3.4
152-
Added the *compact* parameter.
153-
154-
.. versionchanged:: 3.8
155-
Added the *sort_dicts* parameter.
142+
within a scope).
156143

157-
.. versionchanged:: 3.10
158-
Added the *underscore_numbers* parameter.
144+
The configuration parameters *stream*, *indent*, *width*, *depth*,
145+
*compact*, *sort_dicts* and *underscore_numbers* are passed to the
146+
:class:`PrettyPrinter` constructor and their meanings are as
147+
described in its documentation above.
159148

160149
>>> import pprint
161150
>>> stuff = ['spam', 'eggs', 'lumberjack', 'knights', 'ni']
@@ -168,7 +157,6 @@ The :mod:`pprint` module also provides several shortcut functions:
168157
'knights',
169158
'ni']
170159

171-
172160
.. function:: isreadable(object)
173161

174162
.. index:: builtin: eval

Doc/library/symtable.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -194,5 +194,5 @@ Examining Symbol Tables
194194

195195
.. method:: get_namespace()
196196

197-
Return the namespace bound to this name. If more than one namespace is
198-
bound, :exc:`ValueError` is raised.
197+
Return the namespace bound to this name. If more than one or no namespace
198+
is bound to this name, a :exc:`ValueError` is raised.

Doc/library/traceback.rst

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -353,6 +353,14 @@ capture data for later printing in a lightweight fashion.
353353
.. versionchanged:: 3.6
354354
Long sequences of repeated frames are now abbreviated.
355355

356+
.. method:: format_frame(frame)
357+
358+
Returns a string for printing one of the frames involved in the stack.
359+
This method gets called for each frame object to be printed in the
360+
:class:`StackSummary`.
361+
362+
.. versionadded:: 3.11
363+
356364

357365
:class:`FrameSummary` Objects
358366
-----------------------------

Doc/library/zipfile.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -566,6 +566,10 @@ Path objects are traversable using the ``/`` operator or ``joinpath``.
566566
Prior to 3.10, ``joinpath`` was undocumented and accepted
567567
exactly one parameter.
568568

569+
The `zipp <https://pypi.org/project/zipp>`_ project provides backports
570+
of the latest path object functionality to older Pythons. Use
571+
``zipp.Path`` in place of ``zipfile.Path`` for early access to
572+
changes.
569573

570574
.. _pyzipfile-objects:
571575

Grammar/python.gram

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -666,7 +666,6 @@ await_primary[expr_ty] (memo):
666666
| AWAIT a=primary { CHECK_VERSION(expr_ty, 5, "Await expressions are", _PyAST_Await(a, EXTRA)) }
667667
| primary
668668
primary[expr_ty]:
669-
| invalid_primary # must be before 'primay genexp' because of invalid_genexp
670669
| a=primary '.' b=NAME { _PyAST_Attribute(a, b->v.Name.id, Load, EXTRA) }
671670
| a=primary b=genexp { _PyAST_Call(a, CHECK(asdl_expr_seq*, (asdl_expr_seq*)_PyPegen_singleton_seq(p, b)), NULL, EXTRA) }
672671
| a=primary '(' b=[arguments] ')' {
@@ -893,8 +892,6 @@ invalid_del_stmt:
893892
RAISE_SYNTAX_ERROR_INVALID_TARGET(DEL_TARGETS, a) }
894893
invalid_block:
895894
| NEWLINE !INDENT { RAISE_INDENTATION_ERROR("expected an indented block") }
896-
invalid_primary:
897-
| primary a='{' { RAISE_SYNTAX_ERROR_KNOWN_LOCATION(a, "invalid syntax") }
898895
invalid_comprehension:
899896
| ('[' | '(' | '{') a=starred_expression for_if_clauses {
900897
RAISE_SYNTAX_ERROR_KNOWN_LOCATION(a, "iterable unpacking cannot be used in comprehension") }

Include/cpython/code.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,6 @@ typedef uint16_t _Py_CODEUNIT;
2323
# define _Py_MAKECODEUNIT(opcode, oparg) ((opcode)|((oparg)<<8))
2424
#endif
2525

26-
typedef struct _PyOpcache _PyOpcache;
27-
2826

2927
/* Bytecode object */
3028
struct PyCodeObject {

Include/genericaliasobject.h

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

8-
#ifndef Py_LIMITED_API
9-
PyAPI_FUNC(PyObject *) _Py_subs_parameters(PyObject *, PyObject *, PyObject *, PyObject *);
10-
PyAPI_FUNC(PyObject *) _Py_make_parameters(PyObject *);
11-
#endif
12-
138
PyAPI_FUNC(PyObject *) Py_GenericAlias(PyObject *, PyObject *);
149
PyAPI_DATA(PyTypeObject) Py_GenericAliasType;
1510

Include/internal/pycore_code.h

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -4,29 +4,6 @@
44
extern "C" {
55
#endif
66

7-
/* Legacy Opcache */
8-
9-
typedef struct {
10-
PyObject *ptr; /* Cached pointer (borrowed reference) */
11-
uint64_t globals_ver; /* ma_version of global dict */
12-
uint64_t builtins_ver; /* ma_version of builtin dict */
13-
} _PyOpcache_LoadGlobal;
14-
15-
typedef struct {
16-
PyTypeObject *type;
17-
Py_ssize_t hint;
18-
unsigned int tp_version_tag;
19-
} _PyOpCodeOpt_LoadAttr;
20-
21-
struct _PyOpcache {
22-
union {
23-
_PyOpcache_LoadGlobal lg;
24-
_PyOpCodeOpt_LoadAttr la;
25-
} u;
26-
char optimized;
27-
};
28-
29-
307
/* PEP 659
318
* Specialization and quickening structs and helper functions
329
*/

Include/internal/pycore_unionobject.h

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,13 @@ extern "C" {
88
# error "this header requires Py_BUILD_CORE define"
99
#endif
1010

11-
PyAPI_FUNC(PyObject *) _Py_Union(PyObject *args);
12-
PyAPI_DATA(PyTypeObject) _Py_UnionType;
13-
PyAPI_FUNC(PyObject *) _Py_union_type_or(PyObject* self, PyObject* param);
11+
extern PyTypeObject _PyUnion_Type;
12+
#define _PyUnion_Check(op) Py_IS_TYPE(op, &_PyUnion_Type)
13+
extern PyObject *_Py_union_type_or(PyObject *, PyObject *);
14+
15+
#define _PyGenericAlias_Check(op) PyObject_TypeCheck(op, &Py_GenericAliasType)
16+
extern PyObject *_Py_subs_parameters(PyObject *, PyObject *, PyObject *, PyObject *);
17+
extern PyObject *_Py_make_parameters(PyObject *);
1418

1519
#ifdef __cplusplus
1620
}

Include/modsupport.h

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ PyAPI_FUNC(PyObject *) Py_BuildValue(const char *, ...);
5050
PyAPI_FUNC(PyObject *) _Py_BuildValue_SizeT(const char *, ...);
5151

5252

53+
#define ANY_VARARGS(n) (n == PY_SSIZE_T_MAX)
5354
#ifndef Py_LIMITED_API
5455
PyAPI_FUNC(int) _PyArg_UnpackStack(
5556
PyObject *const *args,
@@ -73,7 +74,7 @@ PyAPI_FUNC(void) _PyArg_BadArgument(const char *, const char *, const char *, Py
7374
PyAPI_FUNC(int) _PyArg_CheckPositional(const char *, Py_ssize_t,
7475
Py_ssize_t, Py_ssize_t);
7576
#define _PyArg_CheckPositional(funcname, nargs, min, max) \
76-
(((min) <= (nargs) && (nargs) <= (max)) \
77+
((!ANY_VARARGS(max) && (min) <= (nargs) && (nargs) <= (max)) \
7778
|| _PyArg_CheckPositional((funcname), (nargs), (min), (max)))
7879

7980
#endif
@@ -127,6 +128,14 @@ PyAPI_FUNC(PyObject * const *) _PyArg_UnpackKeywords(
127128
struct _PyArg_Parser *parser,
128129
int minpos, int maxpos, int minkw,
129130
PyObject **buf);
131+
132+
PyAPI_FUNC(PyObject * const *) _PyArg_UnpackKeywordsWithVararg(
133+
PyObject *const *args, Py_ssize_t nargs,
134+
PyObject *kwargs, PyObject *kwnames,
135+
struct _PyArg_Parser *parser,
136+
int minpos, int maxpos, int minkw,
137+
int vararg, PyObject **buf);
138+
130139
#define _PyArg_UnpackKeywords(args, nargs, kwargs, kwnames, parser, minpos, maxpos, minkw, buf) \
131140
(((minkw) == 0 && (kwargs) == NULL && (kwnames) == NULL && \
132141
(minpos) <= (nargs) && (nargs) <= (maxpos) && args != NULL) ? (args) : \

Lib/inspect.py

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2444,15 +2444,23 @@ def _signature_from_callable(obj, *,
24442444
if call is not None:
24452445
sig = _get_signature_of(call)
24462446
else:
2447-
# Now we check if the 'obj' class has a '__new__' method
2447+
factory_method = None
24482448
new = _signature_get_user_defined_method(obj, '__new__')
2449-
if new is not None:
2450-
sig = _get_signature_of(new)
2451-
else:
2452-
# Finally, we should have at least __init__ implemented
2453-
init = _signature_get_user_defined_method(obj, '__init__')
2454-
if init is not None:
2455-
sig = _get_signature_of(init)
2449+
init = _signature_get_user_defined_method(obj, '__init__')
2450+
# Now we check if the 'obj' class has an own '__new__' method
2451+
if '__new__' in obj.__dict__:
2452+
factory_method = new
2453+
# or an own '__init__' method
2454+
elif '__init__' in obj.__dict__:
2455+
factory_method = init
2456+
# If not, we take inherited '__new__' or '__init__', if present
2457+
elif new is not None:
2458+
factory_method = new
2459+
elif init is not None:
2460+
factory_method = init
2461+
2462+
if factory_method is not None:
2463+
sig = _get_signature_of(factory_method)
24562464

24572465
if sig is None:
24582466
# At this point we know, that `obj` is a class, with no user-

0 commit comments

Comments
 (0)