[pypy-svn] r8876 - pypy/dist/pypy/objspace/std
pedronis at codespeak.net
pedronis at codespeak.net
Fri Feb 4 17:14:24 CET 2005
Author: pedronis
Date: Fri Feb 4 17:14:24 2005
New Revision: 8876
Modified:
pypy/dist/pypy/objspace/std/fake.py
Log:
trying to fake SRE_Pattern and _Match
Modified: pypy/dist/pypy/objspace/std/fake.py
==============================================================================
--- pypy/dist/pypy/objspace/std/fake.py (original)
+++ pypy/dist/pypy/objspace/std/fake.py Fri Feb 4 17:14:24 2005
@@ -41,9 +41,24 @@
"NOT_RPYTHON (not remotely so!)."
debug_print('faking %r'%(cpy_type,))
kw = {}
- for s, v in cpy_type.__dict__.items():
- if cpy_type is not unicode or s not in ['__add__', '__contains__']:
- kw[s] = v
+
+ if cpy_type.__name__ == 'SRE_Pattern':
+ import re
+ import __builtin__
+ p = re.compile("foo")
+ for meth_name in p.__methods__:
+ kw[meth_name] = __builtin__.eval("lambda p,*args,**kwds: p.%s(*args,**kwds)" % meth_name)
+ elif cpy_type.__name__ == 'SRE_Match':
+ import re
+ import __builtin__
+ m = re.compile("foo").match('foo')
+ for meth_name in m.__methods__:
+ kw[meth_name] = __builtin__.eval("lambda m,*args,**kwds: m.%s(*args,**kwds)" % meth_name)
+ else:
+ for s, v in cpy_type.__dict__.items():
+ if cpy_type is not unicode or s not in ['__add__', '__contains__']:
+ kw[s] = v
+
def fake__new__(space, w_type, args_w):
args = [space.unwrap(w_arg) for w_arg in args_w]
try:
More information about the Pypy-commit
mailing list