Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 88fb2b9

Browse files
Merge branch 'main' into sqlite-autocommit
2 parents 7f645ee + 7476154 commit 88fb2b9

29 files changed

+782
-272
lines changed

Grammar/python.gram

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -391,7 +391,7 @@ for_stmt[stmt_ty]:
391391
with_stmt[stmt_ty]:
392392
| invalid_with_stmt_indent
393393
| 'with' '(' a[asdl_withitem_seq*]=','.with_item+ ','? ')' ':' b=block {
394-
_PyAST_With(a, b, NULL, EXTRA) }
394+
CHECK_VERSION(stmt_ty, 9, "Parenthesized context managers are", _PyAST_With(a, b, NULL, EXTRA)) }
395395
| 'with' a[asdl_withitem_seq*]=','.with_item+ ':' tc=[TYPE_COMMENT] b=block {
396396
_PyAST_With(a, b, NEW_TYPE_COMMENT(p, tc), EXTRA) }
397397
| ASYNC 'with' '(' a[asdl_withitem_seq*]=','.with_item+ ','? ')' ':' b=block {

Lib/enum.py

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1112,14 +1112,6 @@ def __new__(cls, value):
11121112
def __init__(self, *args, **kwds):
11131113
pass
11141114

1115-
def __getattribute__(self, name):
1116-
self_dict = super().__getattribute__('__dict__')
1117-
cls = super().__getattribute__('__class__')
1118-
value = super().__getattribute__(name)
1119-
if isinstance(value, cls) and name not in self_dict and name in self._member_names_:
1120-
raise AttributeError("<enum '%s'> member has no attribute %r" % (cls.__name__, name))
1121-
return super().__getattribute__(name)
1122-
11231115
def _generate_next_value_(name, start, count, last_values):
11241116
"""
11251117
Generate the next value when not given.

Lib/idlelib/NEWS.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ What's New in IDLE 3.10.0
2929
Released on 2021-10-04
3030
=========================
3131

32+
bpo-45193: Make completion boxes appear on Ubuntu again.
3233

3334
bpo-40128: Mostly fix completions on macOS when not using tcl/tk 8.6.11
3435
(as with 3.9).

Lib/test/test_ast.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -738,6 +738,14 @@ def test_ast_asdl_signature(self):
738738
expressions[0] = f"expr = {ast.expr.__subclasses__()[0].__doc__}"
739739
self.assertCountEqual(ast.expr.__doc__.split("\n"), expressions)
740740

741+
def test_parenthesized_with_feature_version(self):
742+
ast.parse('with (CtxManager() as example): ...', feature_version=(3, 10))
743+
# While advertised as a feature in Python 3.10, this was allowed starting 3.9
744+
ast.parse('with (CtxManager() as example): ...', feature_version=(3, 9))
745+
with self.assertRaises(SyntaxError):
746+
ast.parse('with (CtxManager() as example): ...', feature_version=(3, 8))
747+
ast.parse('with CtxManager() as example: ...', feature_version=(3, 8))
748+
741749
def test_issue40614_feature_version(self):
742750
ast.parse('f"{x=}"', feature_version=(3, 8))
743751
with self.assertRaises(SyntaxError):

Lib/test/test_bytes.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1710,6 +1710,23 @@ def test_repeat_after_setslice(self):
17101710
self.assertEqual(b1, b)
17111711
self.assertEqual(b3, b'xcxcxc')
17121712

1713+
def test_mutating_index(self):
1714+
class Boom:
1715+
def __index__(self):
1716+
b.clear()
1717+
return 0
1718+
1719+
with self.subTest("tp_as_mapping"):
1720+
b = bytearray(b'Now you see me...')
1721+
with self.assertRaises(IndexError):
1722+
b[0] = Boom()
1723+
1724+
with self.subTest("tp_as_sequence"):
1725+
_testcapi = import_helper.import_module('_testcapi')
1726+
b = bytearray(b'Now you see me...')
1727+
with self.assertRaises(IndexError):
1728+
_testcapi.sequence_setitem(b, 0, Boom())
1729+
17131730

17141731
class AssortedBytesTest(unittest.TestCase):
17151732
#

Lib/test/test_code.py

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
freevars: ()
1818
nlocals: 2
1919
flags: 3
20-
lnotab: [4, 1, 10, 2]
2120
consts: ('None', '<code object g>')
2221
2322
>>> dump(f(4).__code__)
@@ -31,7 +30,6 @@
3130
freevars: ('x',)
3231
nlocals: 1
3332
flags: 19
34-
lnotab: [4, 1]
3533
consts: ('None',)
3634
3735
>>> def h(x, y):
@@ -52,7 +50,6 @@
5250
freevars: ()
5351
nlocals: 5
5452
flags: 3
55-
lnotab: [2, 1, 10, 1, 10, 1, 10, 1]
5653
consts: ('None',)
5754
5855
>>> def attrs(obj):
@@ -71,7 +68,6 @@
7168
freevars: ()
7269
nlocals: 1
7370
flags: 3
74-
lnotab: [2, 1, 46, 1, 46, 1]
7571
consts: ('None',)
7672
7773
>>> def optimize_away():
@@ -91,7 +87,6 @@
9187
freevars: ()
9288
nlocals: 0
9389
flags: 3
94-
lnotab: [2, 2, 2, 1, 2, 1]
9590
consts: ("'doc string'", 'None')
9691
9792
>>> def keywordonly_args(a,b,*,k1):
@@ -109,7 +104,6 @@
109104
freevars: ()
110105
nlocals: 3
111106
flags: 3
112-
lnotab: [2, 1]
113107
consts: ('None',)
114108
115109
>>> def posonly_args(a,b,/,c):
@@ -127,7 +121,6 @@
127121
freevars: ()
128122
nlocals: 3
129123
flags: 3
130-
lnotab: [2, 1]
131124
consts: ('None',)
132125
133126
"""
@@ -168,7 +161,6 @@ def dump(co):
168161
"kwonlyargcount", "names", "varnames",
169162
"cellvars", "freevars", "nlocals", "flags"]:
170163
print("%s: %s" % (attr, getattr(co, "co_" + attr)))
171-
print("lnotab:", list(co.co_lnotab))
172164
print("consts:", tuple(consts(co.co_consts)))
173165

174166
# Needed for test_closure_injection below
@@ -436,21 +428,6 @@ def func():
436428
self.assertIsNone(line)
437429
self.assertEqual(end_line, new_code.co_firstlineno + 1)
438430

439-
def test_large_lnotab(self):
440-
d = {}
441-
lines = (
442-
["def f():"] +
443-
[""] * (1 << 17) +
444-
[" pass"] * (1 << 17)
445-
)
446-
source = "\n".join(lines)
447-
exec(source, d)
448-
code = d["f"].__code__
449-
450-
expected = 1032 * [0, 127] + [0, 9] + ((1 << 17) - 1) * [2, 1]
451-
expected[0] = 2
452-
self.assertEqual(list(code.co_lnotab), expected)
453-
454431

455432
def isinterned(s):
456433
return s is sys.intern(('_' + s + '_')[1:-1])

Lib/test/test_concurrent_futures.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -485,7 +485,7 @@ def test_cancel_futures_wait_false(self):
485485
t = ThreadPoolExecutor()
486486
t.submit(sleep_and_print, .1, "apple")
487487
t.shutdown(wait=False, cancel_futures=True)
488-
""".format(executor_type=self.executor_type.__name__))
488+
""")
489489
# Errors in atexit hooks don't change the process exit code, check
490490
# stderr manually.
491491
self.assertFalse(err)

Lib/test/test_enum.py

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2646,19 +2646,14 @@ class Private(Enum):
26462646
self.assertEqual(Private._Private__corporal, 'Radar')
26472647
self.assertEqual(Private._Private__major_, 'Hoolihan')
26482648

2649+
@unittest.skip("Accessing all values retained for performance reasons, see GH-93910")
26492650
def test_exception_for_member_from_member_access(self):
26502651
with self.assertRaisesRegex(AttributeError, "<enum .Di.> member has no attribute .NO."):
26512652
class Di(Enum):
26522653
YES = 1
26532654
NO = 0
26542655
nope = Di.YES.NO
26552656

2656-
def test_no_exception_for_overridden_member_from_member_access(self):
2657-
class Di(Enum):
2658-
YES = 1
2659-
NO = 0
2660-
Di.YES.NO = Di.NO
2661-
nope = Di.YES.NO
26622657

26632658
def test_dynamic_members_with_static_methods(self):
26642659
#

Lib/test/test_sqlite3/__init__.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,4 @@ def load_tests(*args):
1212
return load_package_tests(pkg_dir, *args)
1313

1414
if verbose:
15-
print("test_sqlite3: testing with version",
16-
"{!r}, sqlite_version {!r}".format(sqlite3.version,
17-
sqlite3.sqlite_version))
15+
print(f"test_sqlite3: testing with SQLite version {sqlite3.sqlite_version}")
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Fix reference counting bug in :meth:`bool.__repr__`. Patch by Kumar Aditya.

0 commit comments

Comments
 (0)