classification
Title: compiler.transformer dict key bug d[1,] = 1
Type: behavior Stage:
Components: Library (Lib) Versions: Python 2.6, Python 2.5
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: ChuckRhode, amaury.forgeotdarc, benjamin.peterson, kees (4)
Priority: Keywords patch

Created on 2009-09-23 13:35 by kees, last changed 2009-10-22 01:47 by benjamin.peterson.

Files
File name Uploaded Description Edit Remove
compiler.transformer.patch kees, 2009-09-23 14:24 patch for transformer.py
transformer.py.patch kees, 2009-10-07 12:30 patch for transformer.py
Messages (7)
msg93034 - (view) Author: Kees Bos (kees) Date: 2009-09-23 13:35
compiler.parse("d[1] = 1") should have a single tuple as subs


>>> compiler.parse("d[1] = 1")
Module(None, Stmt([Assign([Subscript(Name('d'), 'OP_ASSIGN',
[Const(1)])], Const(1))]))
>>> compiler.parse("d[1,] = 2")
Module(None, Stmt([Assign([Subscript(Name('d'), 'OP_ASSIGN',
[Const(1)])], Const(2))]))
>>> compiler.parse("d[1,2] = 3")
Module(None, Stmt([Assign([Subscript(Name('d'), 'OP_ASSIGN', [Const(1),
Const(2)])], Const(3))]))
>>> compiler.parse("d[(1,)] = 2")
Module(None, Stmt([Assign([Subscript(Name('d'), 'OP_ASSIGN',
[Tuple([Const(1)])])], Const(2))]))
msg93036 - (view) Author: Kees Bos (kees) Date: 2009-09-23 14:11
I just see that my patch is not correct, since the following is
supported by the language:

O[1:2:3, 4:5:6]

Where O[1:2:3, 4:5:6] == O[slice(1,2,3), slice(4,5,6)] ==
O.__getitem__((slice(1,2,3), slice(4,5,6)))
msg93037 - (view) Author: Kees Bos (kees) Date: 2009-09-23 14:24
patch which honors O[1:2:3, 4:5:6]
msg93690 - (view) Author: Amaury Forgeot d'Arc (amaury.forgeotdarc) Date: 2009-10-07 11:55
your patch is no more a diff file (the 'previous' file is empty)
msg93693 - (view) Author: Kees Bos (kees) Date: 2009-10-07 12:30
Sorry. Renamed .bak to .orig ...
Here's the patch compiler/transformer.py (against python 2.5)
msg94320 - (view) Author: Chuck Rhode (ChuckRhode) Date: 2009-10-21 19:48
PythonTidy encounters this problem.

o http://lacusveris.com/PythonTidy/PythonTidy.python

It is unable correctly to render line 694 of test_grammar.py in the
Python Test Suite:

    d[1,] = 2

becomes:

    d[1] = 2

because the *compiler* module does not return an abstract syntax tree
containing a tuple for the subscript.
msg94332 - (view) Author: Benjamin Peterson (benjamin.peterson) Date: 2009-10-22 01:47
The patch should have a test.
History
Date User Action Args
2009-10-22 01:47:10benjamin.petersonsetnosy: + benjamin.peterson
messages: + msg94332
2009-10-21 19:48:19ChuckRhodesetnosy: + ChuckRhode
messages: + msg94320
2009-10-07 12:30:53keessetfiles: + transformer.py.patch

messages: + msg93693
2009-10-07 11:55:33amaury.forgeotdarcsetnosy: + amaury.forgeotdarc
messages: + msg93690
2009-09-23 14:24:54keessetfiles: - compiler.transformer.patch
2009-09-23 14:24:23keessetfiles: + compiler.transformer.patch

messages: + msg93037
2009-09-23 14:11:26keessetmessages: + msg93036
2009-09-23 13:35:34keescreate