igormarfin / shedskin

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

shedskin says "KeyError: None" #168

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
So I'm extending the C64 emu to finally support the floppy drive the right way 
(i.e. emulating the drive CPU), for this I moved stuff around a bit and 
extended a few things and then this happened:

dannym@panther:~/source/playground/trunk/emu/C64/emulators$ svn info
Path: .
URL: http://svn.nomike.com/playground/trunk/emu/C64/emulators
Repository Root: http://svn.nomike.com/playground
Repository UUID: 19a344e9-eb95-c153-accd-d63d03d6c449
Revision: 3550
Node Kind: directory
Schedule: normal
Last Changed Author: dannym
Last Changed Rev: 3550
Last Changed Date: 2012-05-26 21:04:07 +0200 (Sat, 26 May 2012)
dannym@panther:~/source/playground/trunk/emu/C64/emulators$ shedskin -e -b -x 
__init__.py 
*** SHED SKIN Python-to-C++ Compiler 0.9.2 ***
Copyright 2005-2011 Mark Dufour; License GNU GPL version 3 (See LICENSE)

[analyzing types..]
********************************100%
[generating c++ code..]
*WARNING* 'Loader.parse' method not exported (cannot convert argument 'stream')
*WARNING* 'Loader.parse_entry' method not exported (cannot convert argument 
'stream')
*WARNING* 'Loader.stream' variable not exported (cannot convert)
*WARNING* 'Loader.parse' method not exported (cannot convert argument 'stream')
*WARNING* 'Loader.stream' variable not exported (cannot convert)
*WARNING* 'P00Loader.stream' variable not exported (cannot convert)
*WARNING* 'CIA.gregorian_time' variable not exported (cannot convert)
Traceback (most recent call last):
  File "/usr/local/bin/shedskin", line 3, in <module>
    shedskin.main()
  File "/usr/local/lib/python2.7/dist-packages/shedskin/__init__.py", line 106, in main
    start()
  File "/usr/local/lib/python2.7/dist-packages/shedskin/__init__.py", line 98, in start
    cpp.generate_code()
  File "/usr/local/lib/python2.7/dist-packages/shedskin/cpp.py", line 2534, in generate_code
    walk(module.ast, gv)
  File "/usr/lib/python2.7/compiler/visitor.py", line 106, in walk
    walker.preorder(tree, visitor)
  File "/usr/lib/python2.7/compiler/visitor.py", line 63, in preorder
    self.dispatch(tree, *args) # XXX *args make sense?
  File "/usr/lib/python2.7/compiler/visitor.py", line 57, in dispatch
    return meth(node, *args)
  File "/usr/local/lib/python2.7/dist-packages/shedskin/cpp.py", line 490, in visitModule
    self.module_cpp(node)
  File "/usr/local/lib/python2.7/dist-packages/shedskin/cpp.py", line 414, in module_cpp
    self.class_cpp(child)
  File "/usr/local/lib/python2.7/dist-packages/shedskin/cpp.py", line 641, in class_cpp
    self.visitFunction(func.node, cl, False)
  File "/usr/local/lib/python2.7/dist-packages/shedskin/cpp.py", line 1164, in visitFunction
    self.visit(node.code, func)
  File "/usr/lib/python2.7/compiler/visitor.py", line 57, in dispatch
    return meth(node, *args)
  File "/usr/local/lib/python2.7/dist-packages/shedskin/cpp.py", line 1324, in visitStmt
    self.visit(b, func)
  File "/usr/lib/python2.7/compiler/visitor.py", line 57, in dispatch
    return meth(node, *args)
  File "/usr/local/lib/python2.7/dist-packages/shedskin/cpp.py", line 2010, in visitAssign
    vartypes = self.mergeinh[lookupvar(lvalue.attrname, lcp[0])]
KeyError: None

What steps will reproduce the problem?
1. svn co -r 3550 http://svn.nomike.com/playground/trunk/emu/C64
2. cd C64/emulators
3. shedskin -e -b -x __init__.py 

What version of the product are you using? On what operating system?

shedskin git checkout from a few hours ago. GNU/Linux x86_64.

Please provide any additional information below.

Worked fine before I fiddled with the mmu of the emulator. Probably some typo 
there but hard to say...

Original issue reported on code.google.com by danny.m...@gmail.com on 26 May 2012 at 10:26

GoogleCodeExporter commented 8 years ago
I edited cpp.py and added a print statement right before it, that gives:

(class C128, AssAttr(Name('self'), 'CIA2', 'OP_ASSIGN'))
CIA2
(class C128, AssAttr(Name('self'), 'VIC', 'OP_ASSIGN'))
VIC
(class C64Configurator, AssAttr(Name('self'), 'port', 'OP_ASSIGN'))
port
(class C64Configurator, AssAttr(Name('self'), 'cache_map', 'OP_ASSIGN'))
cache_map
(class C64Configurator, AssAttr(Name('self'), 'data_direction', 'OP_ASSIGN'))
data_direction
(class C64Configurator, AssAttr(Name('self'), 'B_can_write', 'OP_ASSIGN'))
B_can_write
(class C64Configurator, AssAttr(Name('self'), 'B_active', 'OP_ASSIGN'))
B_active
(class C64Configurator, AssAttr(Name('self'), 'MMU', 'OP_ASSIGN'))
MMU
(class C64Configurator, AssAttr(Name('self'), 'data_direction', 'OP_ASSIGN'))
data_direction
(class C64Configurator, AssAttr(Name('self'), 'port', 'OP_ASSIGN'))
port
(class C128Configurator, AssAttr(Name('self'), 'cache_map', 'OP_ASSIGN'))

Original comment by danny.m...@gmail.com on 26 May 2012 at 10:47

GoogleCodeExporter commented 8 years ago
Yeah, forgot to pass some parameter:

It said:

class C128Configurator(memory.Memory): # $D500
    def __init__(self, B_active = True):
...
        cache_map = self.MMU.calc_cache_map(self.registers[0], self.registers[6], self.page0_page, self.page1_page)
        self.cache_map = cache_map

But self.MMU did not exist.

Original comment by danny.m...@gmail.com on 26 May 2012 at 10:49

GoogleCodeExporter commented 8 years ago
thanks a lot, as usual! :-) I will see if I can add a few warnings for such 
cases..

Original comment by mark.duf...@gmail.com on 26 May 2012 at 11:19

GoogleCodeExporter commented 8 years ago
alright, made cpp.py proceed when this happens, which leads to both a shedskin 
error ('cache_map has no type' for the second line) and a C++ error ('class 
C128.. has no member mmu). 

I will leave the issue open though, because I want to try a few other cases, 
and it would be nice if 'self.MMU' would trigger a more direct shedskin 
warning, but that is a bit more tricky to do.

thanks in any case for triggering :) please let me know if you run into 
anything else of course..

btw I just tried to compile C64/emulators/emulators.py at SVN HEAD.. is it true 
this involves almost 6,000 lines of code by now? :) (according to sloccount).. 
heh, that's more python code than in shedskin..

btw2 have you ever used GIT? :-) it's awesome..

Original comment by mark.duf...@gmail.com on 29 May 2012 at 9:47

GoogleCodeExporter commented 8 years ago
I added a few more warnings for this kind of situtions just now for 0.9.3, so 
things are looking much better on this front. closing this issue then, thanks! 

Original comment by mark.duf...@gmail.com on 5 Jan 2013 at 9:36

GoogleCodeExporter commented 8 years ago

Original comment by mark.duf...@gmail.com on 5 Jan 2013 at 9:37