diff options
| author | Neal Norwitz <nnorwitz@gmail.com> | 2005-12-18 07:06:23 +0000 | 
|---|---|---|
| committer | Neal Norwitz <nnorwitz@gmail.com> | 2005-12-18 07:06:23 +0000 | 
| commit | 51abbc7b4affeeedb8faf1adee8195be9ad8195f (patch) | |
| tree | c4bc413f79bfff8a43e91a0f2bd15322da92cce9 | |
| parent | 0e7a0ed335b464eb82e2b06f334566fe6d35226a (diff) | |
| download | cpython-git-51abbc7b4affeeedb8faf1adee8195be9ad8195f.tar.gz | |
Fix Armin's bug 1333982. He found it, he didn't created it :-)
This code generated a C assertion:
        assert 1, ([s for s in x] +
                   [s for s in x])
        pass
assert was completely broken, it needed to use the proper block.
compiler_use_block() is now no longer used, so remove it.
| -rw-r--r-- | Lib/test/test_dis.py | 40 | ||||
| -rw-r--r-- | Python/compile.c | 10 | 
2 files changed, 41 insertions, 9 deletions
diff --git a/Lib/test/test_dis.py b/Lib/test/test_dis.py index 985c878bba..ff4e34f7c2 100644 --- a/Lib/test/test_dis.py +++ b/Lib/test/test_dis.py @@ -46,6 +46,43 @@ dis_bug708901 = """\       bug708901.func_code.co_firstlineno + 2,       bug708901.func_code.co_firstlineno + 3) + +def bug1333982(x=[]): +    assert 0, ([s for s in x] + +              1) +    pass + +dis_bug1333982 = """\ + %-4d         0 LOAD_CONST               1 (0) +              3 JUMP_IF_TRUE            47 (to 53) +              6 POP_TOP +              7 LOAD_GLOBAL              0 (AssertionError) +             10 BUILD_LIST               0 +             13 DUP_TOP +             14 LOAD_ATTR                1 (append) +             17 STORE_FAST               1 (_[1]) +             20 LOAD_FAST                0 (x) +             23 GET_ITER +        >>   24 FOR_ITER                16 (to 43) +             27 STORE_FAST               2 (s) +             30 LOAD_FAST                1 (_[1]) +             33 LOAD_FAST                2 (s) +             36 CALL_FUNCTION            1 +             39 POP_TOP +             40 JUMP_ABSOLUTE           24 +        >>   43 DELETE_FAST              1 (_[1]) + + %-4d        46 LOAD_CONST               2 (1) +             49 BINARY_ADD +             50 RAISE_VARARGS            2 +        >>   53 POP_TOP + + %-4d        54 LOAD_CONST               0 (None) +             57 RETURN_VALUE +"""%(bug1333982.func_code.co_firstlineno + 1, +     bug1333982.func_code.co_firstlineno + 2, +     bug1333982.func_code.co_firstlineno + 3) +  class DisTests(unittest.TestCase):      def do_disassembly_test(self, func, expected):          s = StringIO.StringIO() @@ -83,6 +120,9 @@ class DisTests(unittest.TestCase):      def test_bug_708901(self):          self.do_disassembly_test(bug708901, dis_bug708901) +    def test_bug_1333982(self): +        self.do_disassembly_test(bug1333982, dis_bug1333982) +  def test_main():      run_unittest(DisTests) diff --git a/Python/compile.c b/Python/compile.c index 606a446405..60b4933a9f 100644 --- a/Python/compile.c +++ b/Python/compile.c @@ -171,7 +171,6 @@ static int compiler_addop(struct compiler *, int);  static int compiler_addop_o(struct compiler *, int, PyObject *, PyObject *);  static int compiler_addop_i(struct compiler *, int, int);  static int compiler_addop_j(struct compiler *, int, basicblock *, int); -static void compiler_use_block(struct compiler *, basicblock *);  static basicblock *compiler_use_new_block(struct compiler *);  static int compiler_error(struct compiler *, const char *);  static int compiler_nameop(struct compiler *, identifier, expr_context_ty); @@ -1178,13 +1177,6 @@ compiler_new_block(struct compiler *c)  	return b;  } -static void -compiler_use_block(struct compiler *c, basicblock *block) -{ -        assert (block != NULL); -	c->u->u_curblock = block; -} -  static basicblock *  compiler_use_new_block(struct compiler *c)  { @@ -2529,7 +2521,7 @@ compiler_assert(struct compiler *c, stmt_ty s)  	else {  		ADDOP_I(c, RAISE_VARARGS, 1);  	} -	compiler_use_block(c, end); +	compiler_use_next_block(c, end);  	ADDOP(c, POP_TOP);  	return 1;  }  | 
