sgzwiz / brython

Automatically exported from code.google.com/p/brython
BSD 3-Clause "New" or "Revised" License
0 stars 1 forks source link

reference to function arguments fails inside list comprehension #105

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?

def argument_comprehension(i, j, k):
  ijk = [i,j,k]
  arg_comp = [arg for arg in [i,j,k]]
  #arg_comp = [arg for arg in ijk] #working alternative
  return arg_comp
a = argument_comprehension(1,2,3)
assert a == [1,2,3],  'instead arg comp failure as %s'%a
print('Ok')

What is the expected output? What do you see instead?
Ok

Instead:
AssertionError: instead arg comp failure as [3,4,3]
module '__main__' line 7
assert a == [1,2,3],  'instead arg comp failure as %s'%a

What version of the product are you using? On what operating system?
Brython version 1.1.20130317-111626
Linux Mint 14 Nadia - Firefox 19.0.2

Please provide any additional information below.
works ok in Python 3.2.3 
or in Brython when working alternative line is uncommented

Original issue reported on code.google.com by ca...@nce.ufrj.br on 18 Mar 2013 at 9:48

GoogleCodeExporter commented 9 years ago
Thanks Carlo
It was because internal code used the variable names i and j...
Fixed in the revision at
https://bitbucket.org/olemis/brython/commits/efa8f27af6892ef52cbf2480d2c72045493
1c7a9

Original comment by pierre.q...@gmail.com on 20 Mar 2013 at 9:34