mnba / shedskin

Automatically exported from code.google.com/p/shedskin
0 stars 0 forks source link

base class's method can't contain "for" if the subclass is in another file #71

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
The following 2 files can't work, but works well if I put a.py into b.py 
or remove the "for" clause in a.py:

E:\test>cat a.py
class aa(object):
  def __init__(self):
    print "init a"
    aa=[1,2]
    for i in aa:
      print i

E:\test>cat b.py
from a import *

class b(aa):
  def __init__(self):
    aa.__init__(self)
    print "init b"

instance=b()

E:\test>shedskin b
*** SHED SKIN Python-to-C++ Compiler 0.5 ***
Copyright 2005-2010 Mark Dufour; License GNU GPL version 3 (See LICENSE)

Traceback (most recent call last):
  File "C:\Downloads\tools\shedskin\shedskin-0.4-r1408.win32\shedskin.py", 
line 3, in <module>
    shedskin.main()
  File "C:\Downloads\tools\shedskin\shedskin-0.4-r1408.win32
\shedskin\__init__.py", line 92, in main

    infer.analyze(name)
  File "C:\Downloads\tools\shedskin\shedskin-0.4-r1408.win32
\shedskin\infer.py", line 834, in analyz
e
    getgx().main_module = graph.parse_module(getgx().main_mod, ast)
  File "C:\Downloads\tools\shedskin\shedskin-0.4-r1408.win32
\shedskin\graph.py", line 1521, in parse
_module
    mv.dispatch(mod.ast)
  File "C:\Downloads\tools\shedskin\shedskin-0.4-r1408.win32
\shedskin\graph.py", line 50, in dispatc
h
    ASTVisitor.dispatch(self, node, *args)
  File "C:\Programs\Python26\lib\compiler\visitor.py", line 57, in dispatch
    return meth(node, *args)
  File "C:\Downloads\tools\shedskin\shedskin-0.4-r1408.win32
\shedskin\graph.py", line 316, in visitM
odule
    self.visitFunction(func_copy, cl, inherited_from=ancestor)
  File "C:\Downloads\tools\shedskin\shedskin-0.4-r1408.win32
\shedskin\graph.py", line 532, in visitF
unction
    self.visit(node.code, func)
  File "C:\Downloads\tools\shedskin\shedskin-0.4-r1408.win32
\shedskin\graph.py", line 50, in dispatc
h
    ASTVisitor.dispatch(self, node, *args)
  File "C:\Programs\Python26\lib\compiler\visitor.py", line 57, in dispatch
    return meth(node, *args)
  File "C:\Downloads\tools\shedskin\shedskin-0.4-r1408.win32
\shedskin\graph.py", line 245, in visitS
tmt
    self.visit(b, func)
  File "C:\Downloads\tools\shedskin\shedskin-0.4-r1408.win32
\shedskin\graph.py", line 50, in dispatc
h
    ASTVisitor.dispatch(self, node, *args)
  File "C:\Programs\Python26\lib\compiler\visitor.py", line 57, in dispatch
    return meth(node, *args)
  File "C:\Downloads\tools\shedskin\shedskin-0.4-r1408.win32
\shedskin\graph.py", line 916, in visitF
or
    self.do_for(node, assnode, get_iter, func)
  File "C:\Downloads\tools\shedskin\shedskin-0.4-r1408.win32
\shedskin\graph.py", line 942, in do_for

    self.tempvar2(node, inode(node.list), func)
  File "C:\Downloads\tools\shedskin\shedskin-0.4-r1408.win32
\shedskin\graph.py", line 825, in tempva
r2
    tvar = self.tempvar(node, func)
  File "C:\Downloads\tools\shedskin\shedskin-0.4-r1408.win32
\shedskin\graph.py", line 811, in tempva
r
    varname = self.tempcount[getgx().parent_nodes[node]]
KeyError: For(AssName('i', 'OP_ASSIGN'), Name('aa'), Stmt([Printnl([Name
('i')], None)]), None)

Original issue reported on code.google.com by jason.mi...@gmail.com on 11 May 2010 at 1:05

GoogleCodeExporter commented 9 years ago
thanks for reporting! I will look into this for 0.5.

Original comment by mark.duf...@gmail.com on 11 May 2010 at 1:14

GoogleCodeExporter commented 9 years ago
The aa=[1,2] should be changed to temp=[1,2], otherwise conflicted with the 
class 
name, but the issue is the same.

Original comment by jason.mi...@gmail.com on 11 May 2010 at 1:59

GoogleCodeExporter commented 9 years ago
alright, it looks like this works now.. could you please verify? btw, 'aa=[1,2]'
works fine here..? (shedskin changes aa into _aa to avoid the conflict). thanks 
again
for reporting!!

Original comment by mark.duf...@gmail.com on 15 May 2010 at 7:14

GoogleCodeExporter commented 9 years ago
Great, I tested it, issue fixed. 
You are right, there is no name issue.

Original comment by jason.mi...@gmail.com on 16 May 2010 at 2:13

GoogleCodeExporter commented 9 years ago
thanks again! closing..

Original comment by mark.duf...@gmail.com on 16 May 2010 at 8:34