[Python-bugs-list] [ python-Bugs-479186 ] compiler generates bad code for "del"
noreply@sourceforge.net
noreply@sourceforge.net
Wed, 07 Nov 2001 09:14:24 -0800
Bugs item #479186, was opened at 2001-11-07 09:14
You can respond by visiting:
http://sourceforge.net/tracker/?func=detail&atid=105470&aid=479186&group_id=5470
Category: Python Library
Group: None
Status: Open
Resolution: None
Priority: 5
Submitted By: Neil Schemenauer (nascheme)
Assigned to: Jeremy Hylton (jhylton)
Summary: compiler generates bad code for "del"
Initial Comment:
The compiler generates bad code from the following
statement:
del a[0], a[1]
Here is the AST:
Stmt([AssTuple([Subscript(Name('a'), 'OP_DELETE',
[Const(0)]), Subscript(Name('a'), 'OP_DELETE',
[Const(1)])])])
The bytecode generated is:
0 SET_LINENO 0
3 UNPACK_SEQUENCE 2
BAD ------^^^^^^^^^^^^^^^^^^^^^^^^^^
6 SET_LINENO 2
9 LOAD_NAME 0 (a)
12 LOAD_CONST 1 (0)
15 DELETE_SUBSCR
16 LOAD_NAME 0 (a)
19 LOAD_CONST 2 (1)
22 DELETE_SUBSCR
The problem, AFAICT, is that findOp does not find
OP_DELETE. Adding a visitSubscript method to OpFinder
seems to be the fix. A small patch is attached. This
is a 2.1.2 bugfix candidate, IMO.
----------------------------------------------------------------------
You can respond by visiting:
http://sourceforge.net/tracker/?func=detail&atid=105470&aid=479186&group_id=5470