poppopjmp / shedskin

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

Call to undefined fn generated by Shed Skin #107

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
   I'm trying out Shed Skin by converting some standard library modules to be compatible with Shed Skin.  Here, I'm trying a modified version of "urlparse.py", compiled standalone to run its unit test. 

What steps will reproduce the problem?
1. Run Shed Skin 0.6 on attached file
2. make
3.

What is the expected output? What do you see instead?

$ shedskin urlparse.py
*** SHED SKIN Python-to-C++ Compiler 0.6 ***
Copyright 2005-2010 Mark Dufour; License GNU GPL version 3 (See LICENSE)

[iterative type analysis..]
********************************100%
[generating c++ code..]

nagle@user-PC ~/work
$ make
g++  -O2 -msse2 -fomit-frame-pointer -pipe -Wno-deprecated  -I. 
-I/home/nagle/shedskin/shedskin-0.6/shedskin/lib /home/nagle/shedski
n/shedskin-0.6/shedskin/lib/sys.cpp urlparse.cpp 
/home/nagle/shedskin/shedskin-0.6/shedskin/lib/builtin.cpp 
/home/nagle/shedskin/she
dskin-0.6/shedskin/lib/re.cpp -lgc -lpcre  -o urlparse
urlparse.cpp: In function `void __urlparse__::__init()':
urlparse.cpp:548: error: no matching function for call to 
`__shedskin__::dict<__shedskin__::str*, __shedskin__::str*>::update(__urlp
arse__::list_comp_1*)'
/home/nagle/shedskin/shedskin-0.6/shedskin/lib/builtin.hpp:2442: note: 
candidates are: void* __shedskin__::dict<K, V>::update(__shed
skin__::dict<K, V>*) [with K = __shedskin__::str*, V = __shedskin__::str*]
make: *** [urlparse] Error 1

Extracted the offending lines to generate a 3-line test case, 
"hextochrtest.py".  Same error.  Offending code is:

_hextochr = dict(('%02x' % i, chr(i)) for i in range(256))
_hextochr.update(('%02X' % i, chr(i)) for i in range(256))

The second line is the problem.

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

Shed Skin 0.6 on Cygwin on Windows 7.

Please provide any additional information below.

Original issue reported on code.google.com by na...@animats.com on 8 Nov 2010 at 5:55

Attachments:

GoogleCodeExporter commented 8 years ago
Rewriting the code without a list comprehension works, and produces working 
version of "urlparse.py" running under Shed Skin. 

Original comment by na...@animats.com on 8 Nov 2010 at 6:32

GoogleCodeExporter commented 8 years ago
thanks for the issues, john! :D I added hextochrtest.py to the unit tests, and 
will try to fix the problem later this week. 

I'm not sure which version of urlparse.py you were able to compile, but mine 
uses collections.namedtuple and mixin-classes, both of which aren't supported..?

Original comment by mark.duf...@gmail.com on 8 Nov 2010 at 8:42

GoogleCodeExporter commented 8 years ago
Here's a version of "urlparse.py" that works with Shed Skin.
I rewrote the code where necessary to make it work with Shed Skin.  It didn't 
really need "namedtuple" or mixins.  

This code still works with CPython.

I've been working on converting various library modules.  If I can get 
libraries all the way to "urllib2" working with Shed Skin, I'll put them on 
Google Code or SourceForge. 

The biggest fundamental incompatibility I've encountered so far is the lack of 
Unicode support.  Almost everything else can be worked around.  I'd suggest an 
"all Unicode" mode, like Python 3.    

Original comment by na...@animats.com on 8 Nov 2010 at 8:53

Attachments:

GoogleCodeExporter commented 8 years ago
ah, dict.update didn't accept arbitrary iterables yet. fixed in GIT, thanks!!

I'd also be very interested in adding these libraries to shedskin, once they 
mostly work!! :D

I haven't given unicode much thought, because it's typically not that useful in 
compute-intensive code.. or if there is there wouldn't be much of a speedup 
from using shedskin (string processing probably will never be faster than in 
CPython, because 99% of the time is spent inside hand-optimized string 
methods..). 

Original comment by mark.duf...@gmail.com on 13 Nov 2010 at 1:25

GoogleCodeExporter commented 8 years ago
Thanks.

(I'll send in or post all the libraries I've converted once I get "httplib" 
working.  As I work on the higher modules, I keep having to go back and fix 
things in the lower ones.  Another week, perhaps.)

Original comment by na...@animats.com on 13 Nov 2010 at 5:41