Author: Maciej Fijalkowski <[email protected]>
Branch:
Changeset: r64180:e981356d611c
Date: 2013-05-15 19:01 +0200
http://bitbucket.org/pypy/pypy/changeset/e981356d611c/
Log: RPython is odd, just give up. You can't mix methods in one call site
that are different functions from the same class, but you can mix
functions. Work around this problem.
diff --git a/pypy/objspace/fake/checkmodule.py
b/pypy/objspace/fake/checkmodule.py
--- a/pypy/objspace/fake/checkmodule.py
+++ b/pypy/objspace/fake/checkmodule.py
@@ -5,6 +5,7 @@
def checkmodule(*modnames):
config = get_pypy_config(translating=True)
space = FakeObjSpace(config)
+ space.setup()
seeobj_w = []
for modname in modnames:
mod = __import__('pypy.module.%s' % modname, None, None, ['__doc__'])
diff --git a/pypy/objspace/fake/objspace.py b/pypy/objspace/fake/objspace.py
--- a/pypy/objspace/fake/objspace.py
+++ b/pypy/objspace/fake/objspace.py
@@ -323,38 +323,36 @@
t.buildrtyper().specialize()
t.checkgraphs()
+ def setup(space):
+ for name in (ObjSpace.ConstantTable +
+ ObjSpace.ExceptionTable +
+ ['int', 'str', 'float', 'long', 'tuple', 'list',
+ 'dict', 'unicode', 'complex', 'slice', 'bool',
+ 'basestring', 'object', 'bytearray']):
+ setattr(space, 'w_' + name, w_some_obj())
+ space.w_type = w_some_type()
+ #
+ for (name, _, arity, _) in ObjSpace.MethodTable:
+ if name == 'type':
+ continue
+ args = ['w_%d' % i for i in range(arity)]
+ params = args[:]
+ d = {'is_root': is_root,
+ 'w_some_obj': w_some_obj}
+ if name in ('get',):
+ params[-1] += '=None'
+ exec compile2("""\
+ def meth(%s):
+ %s
+ return w_some_obj()
+ """ % (', '.join(params),
+ '; '.join(['is_root(%s)' % arg for arg in args]))) in d
+ meth = func_with_new_name(d['meth'], name)
+ setattr(space, name, meth)
+ #
+ for name in ObjSpace.IrregularOpTable:
+ assert hasattr(space, name) # missing?
-def setup():
- for name in (ObjSpace.ConstantTable +
- ObjSpace.ExceptionTable +
- ['int', 'str', 'float', 'long', 'tuple', 'list',
- 'dict', 'unicode', 'complex', 'slice', 'bool',
- 'basestring', 'object', 'bytearray']):
- setattr(FakeObjSpace, 'w_' + name, w_some_obj())
- FakeObjSpace.w_type = w_some_type()
- #
- for (name, _, arity, _) in ObjSpace.MethodTable:
- if name == 'type':
- continue
- args = ['w_%d' % i for i in range(arity)]
- params = args[:]
- d = {'is_root': is_root,
- 'w_some_obj': w_some_obj}
- if name in ('get',):
- params[-1] += '=None'
- exec compile2("""\
- def meth(self, %s):
- %s
- return w_some_obj()
- """ % (', '.join(params),
- '; '.join(['is_root(%s)' % arg for arg in args]))) in d
- meth = func_with_new_name(d['meth'], name)
- setattr(FakeObjSpace, name, meth)
- #
- for name in ObjSpace.IrregularOpTable:
- assert hasattr(FakeObjSpace, name) # missing?
-
-setup()
# ____________________________________________________________
diff --git a/rpython/tool/sourcetools.py b/rpython/tool/sourcetools.py
--- a/rpython/tool/sourcetools.py
+++ b/rpython/tool/sourcetools.py
@@ -169,14 +169,14 @@
try:
co = compile2_cache[key]
#print "***** duplicate code ******* "
- #print source
- except KeyError:
- #if DEBUG:
- co = py.code.compile(source, filename, mode, flags)
- #else:
- # co = compile(source, filename, mode, flags)
- compile2_cache[key] = co
- return co
+ #print source
+ except KeyError:
+ #if DEBUG:
+ co = py.code.compile(source, filename, mode, flags)
+ #else:
+ # co = compile(source, filename, mode, flags)
+ compile2_cache[key] = co
+ return co
compile2_cache = {}
@@ -203,7 +203,7 @@
localnames = locals.keys()
localnames.sort()
values = [locals[key] for key in localnames]
-
+
source = source.putaround(
before = "def container(%s):" % (', '.join(localnames),),
after = "# no unindent\n return %s" % resultname)
@@ -305,7 +305,7 @@
items = [_convert_const_maybe(item, encoding) for item in x]
return tuple(items)
return x
-
+
def with_unicode_literals(fn=None, **kwds):
"""Decorator that replace all string literals with unicode literals.
Similar to 'from __future__ import string literals' at function level.
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit