This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: compiler module provides wrong AST for extended slice of length 1
Type: behavior Stage:
Components: Library (Lib) Versions: Python 2.7
process
Status: closed Resolution: wont fix
Dependencies: Superseder:
Assigned To: Nosy List: benjamin.peterson, brett.cannon, eric.araujo, georg.brandl, kayhayen, ncoghlan
Priority: normal Keywords:

Created on 2010-08-21 16:32 by kayhayen, last changed 2022-04-11 14:57 by admin. This issue is now closed.

Messages (3)
msg114507 - (view) Author: Kay Hayen (kayhayen) Date: 2010-08-21 16:32
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'))]))
msg114522 - (view) Author: Éric Araujo (eric.araujo) * (Python committer) Date: 2010-08-21 17:29
Thank you for the report. I have added  people found in Misc/maintainers.rst ot the nosy list, and also removed 2.6 since it’s in security mode and does not get bug fixes anymore.
msg114533 - (view) Author: Benjamin Peterson (benjamin.peterson) * (Python committer) Date: 2010-08-21 18:01
The compiler module is deprecated and essentially unmaintained.
History
Date User Action Args
2022-04-11 14:57:05adminsetgithub: 53865
2010-08-21 18:01:03benjamin.petersonsetstatus: open -> closed
resolution: wont fix
messages: + msg114533
2010-08-21 17:29:19eric.araujosetnosy: + brett.cannon, ncoghlan, eric.araujo, benjamin.peterson, georg.brandl

messages: + msg114522
versions: - Python 2.6
2010-08-21 16:32:19kayhayencreate