[issue9656] compiler module provides wrong AST for extended slice of length 1

Kay Hayen report at bugs.python.org
Sat Aug 21 18:32:27 CEST 2010


New submission from Kay Hayen <kayhayen at gmx.de>:

Please check the following:

[GCC 4.4.5 20100728 (prerelease)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import compiler
>>> compiler.parse( "d[1,] = None" )
Module(None, Stmt([Assign([Subscript(Name('d'), 'OP_ASSIGN', [Const(1)])], Name('None'))]))
>>> compiler.parse( "d[1] = None" )
Module(None, Stmt([Assign([Subscript(Name('d'), 'OP_ASSIGN', [Const(1)])], Name('None'))]))
>>> d = {}
>>> d[1,] = None
>>> d[1] = None
>>> d
{1: None, (1,): None}

As you can see d[1] = None and d[1,] = None do different things, but do they lead to the same abstract syntax tree. It's the same on Python 2.7:

Python 2.7.0+ (r27:82500, Aug  7 2010, 19:41:51) 
[GCC 4.4.5 20100728 (prerelease)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import compiler
>>> compiler.parse( "d[1,] = None" )
Module(None, Stmt([Assign([Subscript(Name('d'), 'OP_ASSIGN', [Const(1)])], Name('None'))]))
>>> compiler.parse( "d[1] = None" )
Module(None, Stmt([Assign([Subscript(Name('d'), 'OP_ASSIGN', [Const(1)])], Name('None'))]))

----------
components: Library (Lib)
messages: 114507
nosy: kayhayen
priority: normal
severity: normal
status: open
title: compiler module provides wrong AST for extended slice of length 1
type: behavior
versions: Python 2.6, Python 2.7

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue9656>
_______________________________________


More information about the Python-bugs-list mailing list