Skip to content

Commit

Permalink
Merge branch 'main' into isolate-io/prepare-iobase
Browse files Browse the repository at this point in the history
  • Loading branch information
erlend-aasland committed May 12, 2023
2 parents 3d782e9 + 3c2992e commit e436471
Show file tree
Hide file tree
Showing 34 changed files with 690 additions and 469 deletions.
14 changes: 11 additions & 3 deletions Doc/library/pdb.rst
Original file line number Diff line number Diff line change
Expand Up @@ -602,9 +602,17 @@ can be overridden by the local file.

Execute the (one-line) *statement* in the context of the current stack frame.
The exclamation point can be omitted unless the first word of the statement
resembles a debugger command. To set a global variable, you can prefix the
assignment command with a :keyword:`global` statement on the same line,
e.g.::
resembles a debugger command, e.g.:

.. code-block:: none
(Pdb) ! n=42
(Pdb)
To set a global variable, you can prefix the assignment command with a
:keyword:`global` statement on the same line, e.g.:

.. code-block:: none
(Pdb) global list_options; list_options = ['-l']
(Pdb)
Expand Down
7 changes: 2 additions & 5 deletions Include/internal/pycore_code.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,6 @@ typedef struct {

typedef struct {
uint16_t counter;
uint16_t class_version[2];
uint16_t self_type_version[2];
uint16_t method[4];
} _PySuperAttrCache;

#define INLINE_CACHE_ENTRIES_LOAD_SUPER_ATTR CACHE_ENTRIES(_PySuperAttrCache)
Expand Down Expand Up @@ -227,8 +224,8 @@ extern int _PyLineTable_PreviousAddressRange(PyCodeAddressRange *range);

/* Specialization functions */

extern void _Py_Specialize_LoadSuperAttr(PyObject *global_super, PyObject *cls, PyObject *self,
_Py_CODEUNIT *instr, PyObject *name, int load_method);
extern void _Py_Specialize_LoadSuperAttr(PyObject *global_super, PyObject *cls,
_Py_CODEUNIT *instr, int load_method);
extern void _Py_Specialize_LoadAttr(PyObject *owner, _Py_CODEUNIT *instr,
PyObject *name);
extern void _Py_Specialize_StoreAttr(PyObject *owner, _Py_CODEUNIT *instr,
Expand Down
24 changes: 12 additions & 12 deletions Include/internal/pycore_opcode.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 0 additions & 2 deletions Include/internal/pycore_typeobject.h
Original file line number Diff line number Diff line change
Expand Up @@ -142,8 +142,6 @@ PyAPI_DATA(PyTypeObject) _PyBufferWrapper_Type;

PyObject *
_PySuper_Lookup(PyTypeObject *su_type, PyObject *su_obj, PyObject *name, int *meth_found);
PyObject *
_PySuper_LookupDescr(PyTypeObject *su_type, PyObject *su_obj, PyObject *name);

#ifdef __cplusplus
}
Expand Down
55 changes: 28 additions & 27 deletions Include/opcode.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions Lib/collections/abc.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
from _collections_abc import *
from _collections_abc import __all__
from _collections_abc import _CallableGenericAlias

_deprecated_ByteString = globals().pop("ByteString")

def __getattr__(attr):
if attr == "ByteString":
import warnings
warnings._deprecated("collections.abc.ByteString", remove=(3, 14))
return _deprecated_ByteString
raise AttributeError(f"module 'collections.abc' has no attribute {attr!r}")
3 changes: 2 additions & 1 deletion Lib/importlib/_bootstrap_external.py
Original file line number Diff line number Diff line change
Expand Up @@ -443,6 +443,7 @@ def _write_atomic(path, data, mode=0o666):
# Python 3.12b1 3527 (Add LOAD_SUPER_ATTR)
# Python 3.12b1 3528 (Add LOAD_SUPER_ATTR_METHOD specialization)
# Python 3.12b1 3529 (Inline list/dict/set comprehensions)
# Python 3.12b1 3530 (Shrink the LOAD_SUPER_ATTR caches)

# Python 3.13 will start with 3550

Expand All @@ -459,7 +460,7 @@ def _write_atomic(path, data, mode=0o666):
# Whenever MAGIC_NUMBER is changed, the ranges in the magic_values array
# in PC/launcher.c must also be updated.

MAGIC_NUMBER = (3529).to_bytes(2, 'little') + b'\r\n'
MAGIC_NUMBER = (3530).to_bytes(2, 'little') + b'\r\n'

_RAW_MAGIC_NUMBER = int.from_bytes(MAGIC_NUMBER, 'little') # For import.c

Expand Down
4 changes: 1 addition & 3 deletions Lib/opcode.py
Original file line number Diff line number Diff line change
Expand Up @@ -373,6 +373,7 @@ def pseudo_op(name, op, real_ops):
"FOR_ITER_GEN",
],
"LOAD_SUPER_ATTR": [
"LOAD_SUPER_ATTR_ATTR",
"LOAD_SUPER_ATTR_METHOD",
],
"LOAD_ATTR": [
Expand Down Expand Up @@ -450,9 +451,6 @@ def pseudo_op(name, op, real_ops):
},
"LOAD_SUPER_ATTR": {
"counter": 1,
"class_version": 2,
"self_type_version": 2,
"method": 4,
},
"LOAD_ATTR": {
"counter": 1,
Expand Down
11 changes: 7 additions & 4 deletions Lib/pdb.py
Original file line number Diff line number Diff line change
Expand Up @@ -440,7 +440,7 @@ def displayhook(self, obj):
self.message(repr(obj))

def default(self, line):
if line[:1] == '!': line = line[1:]
if line[:1] == '!': line = line[1:].strip()
locals = self.curframe_locals
globals = self.curframe.f_globals
try:
Expand Down Expand Up @@ -1642,9 +1642,12 @@ def help_exec(self):
Execute the (one-line) statement in the context of the current
stack frame. The exclamation point can be omitted unless the
first word of the statement resembles a debugger command. To
assign to a global variable you must always prefix the command
with a 'global' command, e.g.:
first word of the statement resembles a debugger command, e.g.:
(Pdb) ! n=42
(Pdb)
To assign to a global variable you must always prefix the command with
a 'global' command, e.g.:
(Pdb) global list_options; list_options = ['-l']
(Pdb)
"""
Expand Down
13 changes: 8 additions & 5 deletions Lib/pydoc_data/topics.py
Original file line number Diff line number Diff line change
Expand Up @@ -5283,11 +5283,14 @@
'current\n'
' stack frame. The exclamation point can be omitted unless the '
'first\n'
' word of the statement resembles a debugger command. To set '
'a\n'
' global variable, you can prefix the assignment command with '
'a\n'
' "global" statement on the same line, e.g.:\n'
' word of the statement resembles a debugger command, e.g.:'
'\n'
' (Pdb) ! n=42\n'
' (Pdb)\n'
'\n'
' To set a global variable, you can prefix the assignment command '
' with \n'
' a "global" statement on the same line, e.g.:\n'
'\n'
" (Pdb) global list_options; list_options = ['-l']\n"
' (Pdb)\n'
Expand Down
16 changes: 10 additions & 6 deletions Lib/test/libregrtest/refleak.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,13 @@ def dash_R(ns, test_name, test_func):
else:
zdc = zipimport._zip_directory_cache.copy()
abcs = {}
for abc in [getattr(collections.abc, a) for a in collections.abc.__all__]:
if not isabstract(abc):
continue
for obj in abc.__subclasses__() + [abc]:
abcs[obj] = _get_dump(obj)[0]
# catch and ignore collections.abc.ByteString deprecation
with warnings.catch_warnings(action='ignore', category=DeprecationWarning):
for abc in [getattr(collections.abc, a) for a in collections.abc.__all__]:
if not isabstract(abc):
continue
for obj in abc.__subclasses__() + [abc]:
abcs[obj] = _get_dump(obj)[0]

# bpo-31217: Integer pool to get a single integer object for the same
# value. The pool is used to prevent false alarm when checking for memory
Expand Down Expand Up @@ -173,7 +175,9 @@ def dash_R_cleanup(fs, ps, pic, zdc, abcs):
zipimport._zip_directory_cache.update(zdc)

# Clear ABC registries, restoring previously saved ABC registries.
abs_classes = [getattr(collections.abc, a) for a in collections.abc.__all__]
# ignore deprecation warning for collections.abc.ByteString
with warnings.catch_warnings(action='ignore', category=DeprecationWarning):
abs_classes = [getattr(collections.abc, a) for a in collections.abc.__all__]
abs_classes = filter(isabstract, abs_classes)
for abc in abs_classes:
for obj in abc.__subclasses__() + [abc]:
Expand Down
13 changes: 13 additions & 0 deletions Lib/test/test_buffer.py
Original file line number Diff line number Diff line change
Expand Up @@ -4749,6 +4749,19 @@ def __buffer__(self, flags):
c.clear()
self.assertIs(c.buffer, None)

def test_release_buffer_with_exception_set(self):
class A:
def __buffer__(self, flags):
return memoryview(bytes(8))
def __release_buffer__(self, view):
pass

b = bytearray(8)
with memoryview(b):
# now b.extend will raise an exception due to exports
with self.assertRaises(BufferError):
b.extend(A())


if __name__ == "__main__":
unittest.main()
10 changes: 9 additions & 1 deletion Lib/test/test_collections.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import string
import sys
from test import support
from test.support.import_helper import import_fresh_module
import types
import unittest

Expand All @@ -25,7 +26,7 @@
from collections.abc import Set, MutableSet
from collections.abc import Mapping, MutableMapping, KeysView, ItemsView, ValuesView
from collections.abc import Sequence, MutableSequence
from collections.abc import ByteString, Buffer
from collections.abc import Buffer


class TestUserObjects(unittest.TestCase):
Expand Down Expand Up @@ -1939,6 +1940,8 @@ def assert_index_same(seq1, seq2, index_args):
nativeseq, seqseq, (letter, start, stop))

def test_ByteString(self):
with self.assertWarns(DeprecationWarning):
from collections.abc import ByteString
for sample in [bytes, bytearray]:
with self.assertWarns(DeprecationWarning):
self.assertIsInstance(sample(), ByteString)
Expand All @@ -1960,6 +1963,11 @@ class X(ByteString): pass
# No metaclass conflict
class Z(ByteString, Awaitable): pass

def test_ByteString_attribute_access(self):
collections_abc = import_fresh_module("collections.abc")
with self.assertWarns(DeprecationWarning):
collections_abc.ByteString

def test_Buffer(self):
for sample in [bytes, bytearray, memoryview]:
self.assertIsInstance(sample(b"x"), Buffer)
Expand Down
Loading

0 comments on commit e436471

Please sign in to comment.