kgashok / shedskin

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

Bug generating c++ code - self.line doesn't exist #162

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Try to translate my python code

What is the expected output? What do you see instead?
$ shedskin decompressor.py
*** SHED SKIN Python-to-C++ Compiler 0.9.1 ***
Copyright 2005-2011 Mark Dufour; License GNU GPL version 3 (See LICENSE)

[analyzing types..]
********************************100% 
[generating c++ code..]
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 104, in main
    start()
  File "/usr/local/lib/python2.7/dist-packages/shedskin/__init__.py", line 96, in start
    cpp.generate_code()
  File "/usr/local/lib/python2.7/dist-packages/shedskin/cpp.py", line 2529, 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 487, in visitModule
    self.module_cpp(node)
  File "/usr/local/lib/python2.7/dist-packages/shedskin/cpp.py", line 417, in module_cpp
    self.visit(child)
  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 1144, in visitFunction
    self.generator_class(func)
  File "/usr/local/lib/python2.7/dist-packages/shedskin/cpp.py", line 1212, in generator_class
    self.visit(child, func)
  File "/usr/lib/python2.7/compiler/visitor.py", line 57, in dispatch
    return meth(node, *args)
  File "/usr/lib/python2.7/compiler/visitor.py", line 40, in default
    self.dispatch(child, *args)
  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 1748, in visitCallFunc
    self.visitm(node.node, '(', func)
  File "/usr/local/lib/python2.7/dist-packages/shedskin/cpp.py", line 204, in visitm
    self.visit(arg, 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 2383, in visitGetattr
    self.visit(node.expr, 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 2477, in visitName
    self.append(self.cpp_name(node.name))
  File "/usr/local/lib/python2.7/dist-packages/shedskin/cpp.py", line 185, in append
    self.line += text
AttributeError: generateVisitor instance has no attribute 'line'

What version of the product are you using? On what operating system?
Debian Wheezy (testing) on x86 (32 bit), Python 2.7.2, shedskin 0.9.1 and 
shedskin from git (commit 28a6367c52b40f5810beb82b88d09895c664fc30).

Please provide any additional information below.
Thanks Mark for your work :)

Original issue reported on code.google.com by frap...@gmail.com on 9 Mar 2012 at 11:05

Attachments:

GoogleCodeExporter commented 9 years ago
thanks for reporting!

shedskin should give a warning here about unsupported usage of struct.unpack. 
the following syntax avoids the problem, and is arguably nicer.. ;-)

lenght, = struct.unpack('<I', data)
offset, = struct.unpack('<H', stream[cursor:cursor+2])

I will see if I can add a warning message here.

Original comment by mark.duf...@gmail.com on 9 Mar 2012 at 11:18

GoogleCodeExporter commented 9 years ago
btw, note that you could use the multiprocessing module from 'outside', by 
letting shedskin generate an extension module. there will be some copying 
overhead then of course (see examples/pylot_main for an example of this 
approach).

Original comment by mark.duf...@gmail.com on 9 Mar 2012 at 11:21

GoogleCodeExporter commented 9 years ago
Wow! You're so fast :D Thank you very much :)

Original comment by frap...@gmail.com on 9 Mar 2012 at 11:26

GoogleCodeExporter commented 9 years ago
actually it looks like there are already warning messages.. not sure why I 
didn't see those, perhaps because of the other observed problems. attachment 
leads to clear warning messages in any case, and after changing the code as 
suggested in these warnings, things compile fine. I added some tests for these 
warning messages in any case.. so I consider this issue to be fixed ;-) please 
reopen if I missed anything.

Original comment by mark.duf...@gmail.com on 28 Mar 2012 at 9:56

GoogleCodeExporter commented 9 years ago
btw do you have or know of a pure-python lz4 compressor as well? I'd love to 
add an lz4/snappy compressor to shedskin/examples..

Original comment by mark.duf...@gmail.com on 28 Mar 2012 at 10:09

GoogleCodeExporter commented 9 years ago
It would be great! :)
Actually not, I hope to finish it in next months (lz4-python project is an 
hobby, while actually I've to develop a Django application for work).

Original comment by frap...@gmail.com on 28 Mar 2012 at 10:21