AttributeError: 'Name' object has no attribute 'left'

1 view
Skip to first unread message

Ondrej Certik

unread,
Apr 29, 2010, 6:29:11 PM4/29/10
to py2js list
Hi,

try this on the attached ui.py:



$ python py2js.py ui.py
Traceback (most recent call last):
File "py2js.py", line 47, in <module>
code = pyread(argfile)
File "/home/ondrej/repos/py2js-hg/pyfrontend.py", line 623, in pyread
return gv.parse(contents)
File "/home/ondrej/repos/py2js-hg/pyfrontend.py", line 83, in parse
return self.visit(ast)
File "/home/ondrej/repos/py2js-hg/pyfrontend.py", line 90, in visit
return getattr(self,name)(ast)
File "/home/ondrej/repos/py2js-hg/pyfrontend.py", line 510, in Module
modulebody = self.Statements(ast.body)
File "/home/ondrej/repos/py2js-hg/pyfrontend.py", line 548, in Statements
stmts = self.visit(s)
File "/home/ondrej/repos/py2js-hg/pyfrontend.py", line 90, in visit
return getattr(self,name)(ast)
File "/home/ondrej/repos/py2js-hg/pyfrontend.py", line 463, in ImportFrom
code = pyread(modpath,(ast.module,modpath,namespace))
File "/home/ondrej/repos/py2js-hg/pyfrontend.py", line 623, in pyread
return gv.parse(contents)
File "/home/ondrej/repos/py2js-hg/pyfrontend.py", line 83, in parse
return self.visit(ast)
File "/home/ondrej/repos/py2js-hg/pyfrontend.py", line 90, in visit
return getattr(self,name)(ast)
File "/home/ondrej/repos/py2js-hg/pyfrontend.py", line 510, in Module
modulebody = self.Statements(ast.body)
File "/home/ondrej/repos/py2js-hg/pyfrontend.py", line 548, in Statements
stmts = self.visit(s)
File "/home/ondrej/repos/py2js-hg/pyfrontend.py", line 90, in visit
return getattr(self,name)(ast)
File "/home/ondrej/repos/py2js-hg/pyfrontend.py", line 463, in ImportFrom
code = pyread(modpath,(ast.module,modpath,namespace))
File "/home/ondrej/repos/py2js-hg/pyfrontend.py", line 623, in pyread
return gv.parse(contents)
File "/home/ondrej/repos/py2js-hg/pyfrontend.py", line 83, in parse
return self.visit(ast)
File "/home/ondrej/repos/py2js-hg/pyfrontend.py", line 90, in visit
return getattr(self,name)(ast)
File "/home/ondrej/repos/py2js-hg/pyfrontend.py", line 510, in Module
modulebody = self.Statements(ast.body)
File "/home/ondrej/repos/py2js-hg/pyfrontend.py", line 548, in Statements
stmts = self.visit(s)
File "/home/ondrej/repos/py2js-hg/pyfrontend.py", line 90, in visit
return getattr(self,name)(ast)
File "/home/ondrej/repos/py2js-hg/pyfrontend.py", line 463, in ImportFrom
code = pyread(modpath,(ast.module,modpath,namespace))
File "/home/ondrej/repos/py2js-hg/pyfrontend.py", line 623, in pyread
return gv.parse(contents)
File "/home/ondrej/repos/py2js-hg/pyfrontend.py", line 83, in parse
return self.visit(ast)
File "/home/ondrej/repos/py2js-hg/pyfrontend.py", line 90, in visit
return getattr(self,name)(ast)
File "/home/ondrej/repos/py2js-hg/pyfrontend.py", line 510, in Module
modulebody = self.Statements(ast.body)
File "/home/ondrej/repos/py2js-hg/pyfrontend.py", line 548, in Statements
stmts = self.visit(s)
File "/home/ondrej/repos/py2js-hg/pyfrontend.py", line 90, in visit
return getattr(self,name)(ast)
File "/home/ondrej/repos/py2js-hg/pyfrontend.py", line 303, in ClassDef
stmts = self.visit(stmt)
File "/home/ondrej/repos/py2js-hg/pyfrontend.py", line 90, in visit
return getattr(self,name)(ast)
File "/home/ondrej/repos/py2js-hg/pyfrontend.py", line 388, in FunctionDef
body = self.Statements(ast.body)
File "/home/ondrej/repos/py2js-hg/pyfrontend.py", line 548, in Statements
stmts = self.visit(s)
File "/home/ondrej/repos/py2js-hg/pyfrontend.py", line 90, in visit
return getattr(self,name)(ast)
File "/home/ondrej/repos/py2js-hg/pyfrontend.py", line 601, in While
body = self.Statements(ast.body)
File "/home/ondrej/repos/py2js-hg/pyfrontend.py", line 548, in Statements
stmts = self.visit(s)
File "/home/ondrej/repos/py2js-hg/pyfrontend.py", line 90, in visit
return getattr(self,name)(ast)
File "/home/ondrej/repos/py2js-hg/pyfrontend.py", line 276, in Assign
expr = self.visit(ast.value)
File "/home/ondrej/repos/py2js-hg/pyfrontend.py", line 90, in visit
return getattr(self,name)(ast)
File "/home/ondrej/repos/py2js-hg/pyfrontend.py", line 225, in ListComp
generators.append(self.visit(g))
File "/home/ondrej/repos/py2js-hg/pyfrontend.py", line 90, in visit
return getattr(self,name)(ast)
File "/home/ondrej/repos/py2js-hg/pyfrontend.py", line 172, in comprehension
target = self.visit(e.left)
AttributeError: 'Name' object has no attribute 'left'







Note: it should probably raise an exception "Decorators are not
supported", or any other meaningful exception, so that I know what
exactly is wrong with my code.

Ondrej

--
You received this message because you are subscribed to the Google Groups "JavaScript for Python programmers" group.
To post to this group, send an email to js...@googlegroups.com.
To unsubscribe from this group, send email to js4py+un...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/js4py?hl=en-GB.

ui.py

Ondrej Certik

unread,
Apr 29, 2010, 8:05:17 PM4/29/10
to py2js list
On Thu, Apr 29, 2010 at 3:29 PM, Ondrej Certik <ond...@certik.cz> wrote:
> Hi,
>
> try this on the attached ui.py:

I am now attaching a file that can be compiled by our py2js.py, but not js4py:


$ python2.5 py2js.py triangulation.py
Traceback (most recent call last):
File "py2js.py", line 47, in <module>
code = pyread(argfile)
File "/home/ondrej/repos/js4py-read-only/sandbox/py2js/pyfrontend.py",
line 626, in pyread
return gv.parse(contents)
File "/home/ondrej/repos/js4py-read-only/sandbox/py2js/pyfrontend.py",
line 78, in parse
return self.visit(ast)
File "/home/ondrej/repos/js4py-read-only/sandbox/py2js/pyfrontend.py",
line 85, in visit
return getattr(self,name)(ast)
File "/home/ondrej/repos/js4py-read-only/sandbox/py2js/pyfrontend.py",
line 513, in Module
modulebody = self.Statements(ast.body)
File "/home/ondrej/repos/js4py-read-only/sandbox/py2js/pyfrontend.py",
line 551, in Statements
stmts = self.visit(s)
File "/home/ondrej/repos/js4py-read-only/sandbox/py2js/pyfrontend.py",
line 85, in visit
return getattr(self,name)(ast)
File "/home/ondrej/repos/js4py-read-only/sandbox/py2js/pyfrontend.py",
line 382, in FunctionDef
body = self.Statements(ast.body)
File "/home/ondrej/repos/js4py-read-only/sandbox/py2js/pyfrontend.py",
line 551, in Statements
stmts = self.visit(s)
File "/home/ondrej/repos/js4py-read-only/sandbox/py2js/pyfrontend.py",
line 85, in visit
return getattr(self,name)(ast)
File "/home/ondrej/repos/js4py-read-only/sandbox/py2js/pyfrontend.py",
line 349, in For
upb = loopexpr.args[1]
IndexError: list index out of range


neither the latest py2js from bitbucket. Essentially this code:

def For(self, ast):
target = self.visit(ast.target)
loopexpr = self.visit(ast.iter)
body = self.Statements(ast.body)
if isinstance(loopexpr,FunctionCall):
if loopexpr.fname == "xrange" or loopexpr.fname == 'range':
lwb = loopexpr.args[0]
upb = loopexpr.args[1]
if len(loopexpr.args)==3:
step = loopexpr.args[2]
else:
step = Literal(1)
fdef = ForStatement(target,lwb,upb,step,body)
return [fdef]

fdef = ForInStatement(target,loopexpr,body)
return [fdef]


is doing some optimizations for range() that apparently fail.
triangulation.py
Reply all
Reply to author
Forward
0 new messages