[pypy-dev] Two problems
Martin C. Martin
martin at martincmartin.com
Fri Jan 25 16:40:44 CET 2008
So it's not possible for RPython to call regular, non-RPython? Is there
some wrapper I could write to let RPython call regular python code?
Best,
Martin
Simon Burton wrote:
> On Fri, 25 Jan 2008 10:30:17 -0500
> "Martin C. Martin" <martin at martincmartin.com> wrote:
>
>> Hi,
>>
>> I'm really impressed with the C code generated for some functions I'd
>> like to use in my project. You guys rock!
>>
>> I've run into two problems this morning. In pypy-1.0.0, this:
>>
>> import re
>> import os, sys
>> from pypy.translator.interactive import Translation
>> import py
>>
>> def mytest():
>> x = re.search('bar', 'foobar')
>> return x.start()
>>
>> t = Translation(mytest)
>> t.annotate()
>>
>> throws an exception:
>>
>> File "/ita/downloaded/pypy-1.0.0/pypy/annotation/unaryop.py", line
>> 567, in simple_call
>> return bltn.analyser(bltn.s_self, *args)
>> File "/ita/downloaded/pypy-1.0.0/pypy/tool/instancemethod.py", line
>> 19, in __call__
>> return self.im_func(firstarg, *args, **kwds)
>> TypeError': method_get() takes exactly 3 arguments (2 given)
>> .. v1 = simple_call((builtin_function_or_method get), v0)
>> .. '(sre:213)_compile_star2'
>>
>>
>> This is an InstanceMethod where im_self is a SomeDict and args is a
>> tuple with a single element, a SomeTuple whose "const" is (<type 'str'>,
>> 'bar', 0) and whose "items" is (SomeObject, SomeString, SomeInteger).
>> It seems to be calling a method_get() with two args, SomeDict and
>> SomeTuple, whereas it wants 3. Any idea how to fix this?
>
> I'm not sure you can use module "re" in rpython code.
>
> The error is because somewhere there is a .get(XX) method call on a dict.
> In rpython the default arg for dict.get must be specified.
>
> Simon.
>
>
More information about the Pypy-dev
mailing list