Skip to content

Commit 8698571

Browse files
committed
Merge remote-tracking branch 'upstream/main' into pythongh-120686
2 parents 6123c18 + dacc5ac commit 8698571

30 files changed

+896
-735
lines changed

.github/CODEOWNERS

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ Python/bytecodes.c @markshannon
4242
Python/optimizer*.c @markshannon
4343
Python/optimizer_analysis.c @Fidget-Spinner
4444
Python/optimizer_bytecodes.c @Fidget-Spinner
45-
Python/symtable.c @JelleZijlstra @carljm
45+
Python/symtable.c @JelleZijlstra @carljm
4646
Lib/_pyrepl/* @pablogsal @lysnikolaou @ambv
4747
Lib/test/test_patma.py @brandtbucher
4848
Lib/test/test_type_*.py @JelleZijlstra
@@ -201,7 +201,6 @@ Doc/c-api/stable.rst @encukou
201201
**/*itertools* @rhettinger
202202
**/*collections* @rhettinger
203203
**/*random* @rhettinger
204-
**/*queue* @rhettinger
205204
**/*bisect* @rhettinger
206205
**/*heapq* @rhettinger
207206
**/*functools* @rhettinger

Doc/library/dis.rst

Lines changed: 11 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -780,16 +780,6 @@ not have to be) the original ``STACK[-2]``.
780780
.. versionadded:: 3.12
781781

782782

783-
.. opcode:: BEFORE_ASYNC_WITH
784-
785-
Resolves ``__aenter__`` and ``__aexit__`` from ``STACK[-1]``.
786-
Pushes ``__aexit__`` and result of ``__aenter__()`` to the stack::
787-
788-
STACK.extend((__aexit__, __aenter__())
789-
790-
.. versionadded:: 3.5
791-
792-
793783

794784
**Miscellaneous opcodes**
795785

@@ -944,18 +934,6 @@ iterations of the loop.
944934
Pushes :func:`!builtins.__build_class__` onto the stack. It is later called
945935
to construct a class.
946936

947-
948-
.. opcode:: BEFORE_WITH
949-
950-
This opcode performs several operations before a with block starts. First,
951-
it loads :meth:`~object.__exit__` from the context manager and pushes it onto
952-
the stack for later use by :opcode:`WITH_EXCEPT_START`. Then,
953-
:meth:`~object.__enter__` is called. Finally, the result of calling the
954-
``__enter__()`` method is pushed onto the stack.
955-
956-
.. versionadded:: 3.11
957-
958-
959937
.. opcode:: GET_LEN
960938

961939
Perform ``STACK.append(len(STACK[-1]))``.
@@ -1812,6 +1790,17 @@ iterations of the loop.
18121790
.. versionadded:: 3.12
18131791

18141792

1793+
.. opcode:: LOAD_SPECIAL
1794+
1795+
Performs special method lookup on ``STACK[-1]``.
1796+
If ``type(STACK[-1]).__xxx__`` is a method, leave
1797+
``type(STACK[-1]).__xxx__; STACK[-1]`` on the stack.
1798+
If ``type(STACK[-1]).__xxx__`` is not a method, leave
1799+
``STACK[-1].__xxx__; NULL`` on the stack.
1800+
1801+
.. versionadded:: 3.14
1802+
1803+
18151804
**Pseudo-instructions**
18161805

18171806
These opcodes do not appear in Python bytecode. They are used by the compiler

Doc/library/inspect.rst

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -504,9 +504,9 @@ attributes (see :ref:`import-mod-attrs` for module attributes):
504504
are true.
505505

506506
This, for example, is true of ``int.__add__``. An object passing this test
507-
has a :meth:`~object.__get__` method but not a :meth:`~object.__set__`
508-
method, but beyond that the set of attributes varies. A
509-
:attr:`~definition.__name__` attribute is usually
507+
has a :meth:`~object.__get__` method, but not a :meth:`~object.__set__`
508+
method or a :meth:`~object.__delete__` method. Beyond that, the set of
509+
attributes varies. A :attr:`~definition.__name__` attribute is usually
510510
sensible, and :attr:`!__doc__` often is.
511511

512512
Methods implemented via descriptors that also pass one of the other tests
@@ -515,6 +515,11 @@ attributes (see :ref:`import-mod-attrs` for module attributes):
515515
:attr:`~method.__func__` attribute (etc) when an object passes
516516
:func:`ismethod`.
517517

518+
.. versionchanged:: 3.13
519+
This function no longer incorrectly reports objects with :meth:`~object.__get__`
520+
and :meth:`~object.__delete__`, but not :meth:`~object.__set__`, as being method
521+
descriptors (such objects are data descriptors, not method descriptors).
522+
518523

519524
.. function:: isdatadescriptor(object)
520525

Doc/library/smtplib.rst

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -556,34 +556,33 @@ This example prompts the user for addresses needed in the message envelope ('To'
556556
and 'From' addresses), and the message to be delivered. Note that the headers
557557
to be included with the message must be included in the message as entered; this
558558
example doesn't do any processing of the :rfc:`822` headers. In particular, the
559-
'To' and 'From' addresses must be included in the message headers explicitly. ::
559+
'To' and 'From' addresses must be included in the message headers explicitly::
560560

561561
import smtplib
562562

563-
def prompt(prompt):
564-
return input(prompt).strip()
563+
def prompt(title):
564+
return input(title).strip()
565565

566-
fromaddr = prompt("From: ")
567-
toaddrs = prompt("To: ").split()
566+
from_addr = prompt("From: ")
567+
to_addrs = prompt("To: ").split()
568568
print("Enter message, end with ^D (Unix) or ^Z (Windows):")
569569

570570
# Add the From: and To: headers at the start!
571-
msg = ("From: %s\r\nTo: %s\r\n\r\n"
572-
% (fromaddr, ", ".join(toaddrs)))
571+
lines = [f"From: {from_addr}", f"To: {', '.join(to_addrs)}", ""]
573572
while True:
574573
try:
575574
line = input()
576575
except EOFError:
577576
break
578-
if not line:
579-
break
580-
msg = msg + line
577+
else:
578+
lines.append(line)
581579

580+
msg = "\r\n".join(lines)
582581
print("Message length is", len(msg))
583582

584-
server = smtplib.SMTP('localhost')
583+
server = smtplib.SMTP("localhost")
585584
server.set_debuglevel(1)
586-
server.sendmail(fromaddr, toaddrs, msg)
585+
server.sendmail(from_addr, to_addrs, msg)
587586
server.quit()
588587

589588
.. note::

Include/ceval.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,13 @@ PyAPI_FUNC(void) PyEval_ReleaseThread(PyThreadState *tstate);
133133
#define FVS_MASK 0x4
134134
#define FVS_HAVE_SPEC 0x4
135135

136+
/* Special methods used by LOAD_SPECIAL */
137+
#define SPECIAL___ENTER__ 0
138+
#define SPECIAL___EXIT__ 1
139+
#define SPECIAL___AENTER__ 2
140+
#define SPECIAL___AEXIT__ 3
141+
#define SPECIAL_MAX 3
142+
136143
#ifndef Py_LIMITED_API
137144
# define Py_CPYTHON_CEVAL_H
138145
# include "cpython/ceval.h"

Include/internal/pycore_ceval.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -245,6 +245,13 @@ typedef PyObject *(*conversion_func)(PyObject *);
245245
PyAPI_DATA(const binaryfunc) _PyEval_BinaryOps[];
246246
PyAPI_DATA(const conversion_func) _PyEval_ConversionFuncs[];
247247

248+
typedef struct _special_method {
249+
PyObject *name;
250+
const char *error;
251+
} _Py_SpecialMethod;
252+
253+
PyAPI_DATA(const _Py_SpecialMethod) _Py_SpecialMethods[];
254+
248255
PyAPI_FUNC(int) _PyEval_CheckExceptStarTypeValid(PyThreadState *tstate, PyObject* right);
249256
PyAPI_FUNC(int) _PyEval_CheckExceptTypeValid(PyThreadState *tstate, PyObject* right);
250257
PyAPI_FUNC(int) _PyEval_ExceptionGroupMatch(PyObject* exc_value, PyObject *match_type, PyObject **match, PyObject **rest);

Include/internal/pycore_object.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -709,6 +709,7 @@ extern int _PyObject_IsInstanceDictEmpty(PyObject *);
709709

710710
// Export for 'math' shared extension
711711
PyAPI_FUNC(PyObject*) _PyObject_LookupSpecial(PyObject *, PyObject *);
712+
PyAPI_FUNC(PyObject*) _PyObject_LookupSpecialMethod(PyObject *self, PyObject *attr, PyObject **self_or_null);
712713

713714
extern int _PyObject_IsAbstract(PyObject *);
714715

Include/internal/pycore_opcode_metadata.h

Lines changed: 11 additions & 16 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Include/internal/pycore_uop_ids.h

Lines changed: 1 addition & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Include/internal/pycore_uop_metadata.h

Lines changed: 5 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)