Converting for-loop fails #78

Open
pyjsorg opened this Issue Apr 27, 2012 · 2 comments

Comments

Projects
None yet
1 participant
@pyjsorg
Contributor

pyjsorg commented Apr 27, 2012

Pyjamas version 0.8alpha1.
Python version 2.5 final

Converting the following python code with pyjs:


import pyjd # this is dummy in pyjs.
from pyjamas.ui.RootPanel import RootPanel
from pyjamas.ui.Button import Button
from pyjamas.ui.HTML import HTML
from pyjamas.ui.Label import Label
from pyjamas import Window

a = [('a','A'), ('b','B')]
for i, (little, big) in enumerate(a):

print str(little)+':'+str(big)

Results in this error:


C:\pyjamas\examples>python buildall.py
********** Building HELLO **********
Building : Hello
PYJSPATH : [
C:\pyjamas\examples\test
C:\pyjamas\library
C:\pyjamas\addons
]
Translating : C:\pyjamas\examples\test\Hello.py
Traceback (most recent call last):
File "../../bin/pyjsbuild.py", line 21, in <module>
pyjs.browser.build_script()
File "C:\pyjamas\pyjs\src\pyjs\browser.py", line 555, in build_script
runtime_options, args)
File "C:\pyjamas\pyjs\src\pyjs\browser.py", line 408, in build
l()
File "C:\pyjamas\pyjs\src\pyjs\linker.py", line 254, in call
self.visit_modules(self.modules, platform)
File "C:\pyjamas\pyjs\src\pyjs\linker.py", line 306, in visit_modules
self.visit_module(p, override_paths, platform, module_name=mn)
File "C:\pyjamas\pyjs\src\pyjs\linker.py", line 359, in visit_module
self.keep_lib_files)
File "C:\pyjamas\pyjs\src\pyjs\linker.py", line 145, in out_translate
raise translator.TranslationError(stderr_value, None)
pyjs.translator_proto.TranslationError: line Unknown:
Traceback (most recent call last):
File "C:\pyjamas\pyjs\src\pyjs\translator.py", line 73, in <module>
main()
File "C:\pyjamas\pyjs\src\pyjs\translator.py", line 60, in main
*_get_compile_options(options))
File "C:\pyjamas\pyjs\src\pyjs\translator_proto.py", line 4340, in translate
module_name, sources[0], src, tree, output, *_kw)
File "C:\pyjamas\pyjs\src\pyjs\translator_proto.py", line 872, in init
self._for(child, None)
File "C:\pyjamas\pyjs\src\pyjs\translator_proto.py", line 3608, in _for
child_name = child.name
AttributeError: AssTuple instance has no attribute 'name'

None

Any idea how to solve this?

Original issue: http://code.google.com/p/pyjamas/issues/detail?id=645 (September 23, 2011 12:31:38)

@pyjsorg

This comment has been minimized.

Show comment Hide comment
@pyjsorg

pyjsorg Apr 27, 2012

Contributor

From eukre...@gmail.com on September 23, 2011 14:25:27:
This will work:

a = [('a','A'), ('b','B')]
for i, item in enumerate(a):
little, big = item
print str(little)+':'+str(big)

Contributor

pyjsorg commented Apr 27, 2012

From eukre...@gmail.com on September 23, 2011 14:25:27:
This will work:

a = [('a','A'), ('b','B')]
for i, item in enumerate(a):
little, big = item
print str(little)+':'+str(big)

@pyjsorg

This comment has been minimized.

Show comment Hide comment
@pyjsorg

pyjsorg Apr 27, 2012

Contributor

From eukre...@gmail.com on September 23, 2011 14:30:54:
Or you can use the dict translator instead of proto:

pyjsbuild --translator=dict Hello.py

Contributor

pyjsorg commented Apr 27, 2012

From eukre...@gmail.com on September 23, 2011 14:30:54:
Or you can use the dict translator instead of proto:

pyjsbuild --translator=dict Hello.py

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment