sgzwiz / brython

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

Iterating on DomWrapper object fails (ex. when passing 'doc' as a function parameter) #19

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Tested with "console_fr.html" / firefox 17.0.1 (linux):

print("A", doc.__class__, doc)
for i in doc:
     print("A", "-", i)

def show(c, l):
    print(c, l.__class__, l)
    for i in l:
        print(c, "-", i.__class__, i)

for i in doc:
   show("B", i)

print("C", doc.__class__, doc)
show("C", doc)

print(doc.__class__, doc)
show("C", doc)

Output:

A undefined [object Object]
A - [object HTMLHtmlElement]
B undefined [object HTMLHtmlElement]
B - undefined [object HTMLHeadElement]
B - undefined [object Object]
B - undefined [object HTMLBodyElement]
C undefined [object Object]
C $DomWrapper [object Object]

and a console error after "C" case:
ExecutionError: ExecutionError: $iter2.__len__ is not a function
Line 7
    for i in l: @ http://www.brython.info/py_utils.js:34

Case "C" shows that when parsing arguments "doc" get wrapped (by $MakeArgs ?)
and loses its iteration ability.

Original issue reported on code.google.com by pedro.ro...@gmail.com on 28 Dec 2012 at 11:54

GoogleCodeExporter commented 9 years ago
This issue was closed by revision r260.

Original comment by pierre.q...@gmail.com on 29 Dec 2012 at 6:50