mirror of
https://github.com/python/cpython.git
synced 2025-10-03 05:35:59 +00:00
merge
This commit is contained in:
commit
72d4693336
2 changed files with 16 additions and 2 deletions
|
@ -19,6 +19,7 @@ def disassemble(func):
|
||||||
def dis_single(line):
|
def dis_single(line):
|
||||||
return disassemble(compile(line, '', 'single'))
|
return disassemble(compile(line, '', 'single'))
|
||||||
|
|
||||||
|
|
||||||
class TestTranforms(unittest.TestCase):
|
class TestTranforms(unittest.TestCase):
|
||||||
|
|
||||||
def test_unot(self):
|
def test_unot(self):
|
||||||
|
@ -294,11 +295,23 @@ class TestTranforms(unittest.TestCase):
|
||||||
self.assertNotIn('BINARY_', asm, e)
|
self.assertNotIn('BINARY_', asm, e)
|
||||||
self.assertNotIn('BUILD_', asm, e)
|
self.assertNotIn('BUILD_', asm, e)
|
||||||
|
|
||||||
|
class TestBuglets(unittest.TestCase):
|
||||||
|
|
||||||
|
def test_bug_11510(self):
|
||||||
|
# folded constant set optimization was commingled with the tuple
|
||||||
|
# unpacking optimization which would fail if the set had duplicate
|
||||||
|
# elements so that the set length was unexpected
|
||||||
|
def f():
|
||||||
|
x, y = {1, 1}
|
||||||
|
return x, y
|
||||||
|
with self.assertRaises(ValueError):
|
||||||
|
f()
|
||||||
|
|
||||||
|
|
||||||
def test_main(verbose=None):
|
def test_main(verbose=None):
|
||||||
import sys
|
import sys
|
||||||
from test import support
|
from test import support
|
||||||
test_classes = (TestTranforms,)
|
test_classes = (TestTranforms, TestBuglets)
|
||||||
support.run_unittest(*test_classes)
|
support.run_unittest(*test_classes)
|
||||||
|
|
||||||
# verify reference counting
|
# verify reference counting
|
||||||
|
|
|
@ -535,7 +535,8 @@ PyCode_Optimize(PyObject *code, PyObject* consts, PyObject *names,
|
||||||
}
|
}
|
||||||
if (codestr[i+3] != UNPACK_SEQUENCE ||
|
if (codestr[i+3] != UNPACK_SEQUENCE ||
|
||||||
!ISBASICBLOCK(blocks,i,6) ||
|
!ISBASICBLOCK(blocks,i,6) ||
|
||||||
j != GETARG(codestr, i+3))
|
j != GETARG(codestr, i+3) ||
|
||||||
|
opcode == BUILD_SET)
|
||||||
continue;
|
continue;
|
||||||
if (j == 1) {
|
if (j == 1) {
|
||||||
memset(codestr+i, NOP, 6);
|
memset(codestr+i, NOP, 6);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue