[pypy-svn] r5588 - in pypy/trunk/src/pypy: module objspace/std
mwh at codespeak.net
mwh at codespeak.net
Fri Jul 16 15:47:13 CEST 2004
Author: mwh
Date: Fri Jul 16 15:47:13 2004
New Revision: 5588
Added:
pypy/trunk/src/pypy/objspace/std/basestringtype.py
Modified:
pypy/trunk/src/pypy/module/__builtin__module.py
pypy/trunk/src/pypy/objspace/std/fake.py
pypy/trunk/src/pypy/objspace/std/objspace.py
pypy/trunk/src/pypy/objspace/std/stringtype.py
pypy/trunk/src/pypy/objspace/std/typetype.py
Log:
Say hi to basestring.
Make str inherit from same.
Tweaks to faking machinery so that unicode and str inherit from
the *same* basestring...
Modified: pypy/trunk/src/pypy/module/__builtin__module.py
==============================================================================
--- pypy/trunk/src/pypy/module/__builtin__module.py (original)
+++ pypy/trunk/src/pypy/module/__builtin__module.py Fri Jul 16 15:47:13 2004
@@ -11,7 +11,6 @@
object = __interplevel__eval('space.w_object')
# XXX these are faked:
-basestring = __interplevel__eval('space.wrap(basestring)')
unicode = __interplevel__eval('space.wrap(unicode)')
file = __interplevel__eval('space.wrap(file)')
open = file
Added: pypy/trunk/src/pypy/objspace/std/basestringtype.py
==============================================================================
--- (empty file)
+++ pypy/trunk/src/pypy/objspace/std/basestringtype.py Fri Jul 16 15:47:13 2004
@@ -0,0 +1,7 @@
+from pypy.objspace.std.stdtypedef import *
+
+
+# ____________________________________________________________
+
+basestring_typedef = StdTypeDef("basestring",
+ )
Modified: pypy/trunk/src/pypy/objspace/std/fake.py
==============================================================================
--- pypy/trunk/src/pypy/objspace/std/fake.py (original)
+++ pypy/trunk/src/pypy/objspace/std/fake.py Fri Jul 16 15:47:13 2004
@@ -43,7 +43,11 @@
return w_obj.val
kw['__new__'] = gateway.interp2app(fake__new__)
if cpy_type.__base__ is not object:
- base = space.wrap(cpy_type.__base__).instancetypedef
+ n = 'w_' + cpy_type.__base__.__name__
+ if hasattr(space, n):
+ base = getattr(space, n).instancetypedef
+ else:
+ base = space.wrap(cpy_type.__base__).instancetypedef
else:
base = None
class W_Fake(W_Object):
Modified: pypy/trunk/src/pypy/objspace/std/objspace.py
==============================================================================
--- pypy/trunk/src/pypy/objspace/std/objspace.py (original)
+++ pypy/trunk/src/pypy/objspace/std/objspace.py Fri Jul 16 15:47:13 2004
@@ -58,6 +58,7 @@
from pypy.objspace.std.tupletype import tuple_typedef
from pypy.objspace.std.listtype import list_typedef
from pypy.objspace.std.dicttype import dict_typedef
+ from pypy.objspace.std.basestringtype import basestring_typedef
from pypy.objspace.std.stringtype import str_typedef
from pypy.objspace.std.typetype import type_typedef
from pypy.objspace.std.slicetype import slice_typedef
Modified: pypy/trunk/src/pypy/objspace/std/stringtype.py
==============================================================================
--- pypy/trunk/src/pypy/objspace/std/stringtype.py (original)
+++ pypy/trunk/src/pypy/objspace/std/stringtype.py Fri Jul 16 15:47:13 2004
@@ -1,4 +1,6 @@
from pypy.objspace.std.stdtypedef import *
+from pypy.objspace.std.basestringtype import basestring_typedef
+
str_join = MultiMethod('join', 2)
str_split = MultiMethod('split', 3, defaults=(None,-1))
@@ -51,7 +53,7 @@
# ____________________________________________________________
-str_typedef = StdTypeDef("str",
+str_typedef = StdTypeDef("str", basestring_typedef,
__new__ = newmethod(descr__new__),
)
str_typedef.registermethods(globals())
Modified: pypy/trunk/src/pypy/objspace/std/typetype.py
==============================================================================
--- pypy/trunk/src/pypy/objspace/std/typetype.py (original)
+++ pypy/trunk/src/pypy/objspace/std/typetype.py Fri Jul 16 15:47:13 2004
@@ -26,12 +26,22 @@
def descr__bases(space, w_type):
return space.newtuple(w_type.bases_w)
+def descr__base(space, w_type):
+ if w_type is space.w_object:
+ return space.w_None
+ b = w_type.instancetypedef.base
+ if b is not None:
+ return space.gettypeobject(b)
+ else:
+ return space.w_object
+
# ____________________________________________________________
type_typedef = StdTypeDef("type",
__new__ = newmethod(descr__new__),
__name__ = attrproperty('name'),
__bases__ = GetSetProperty(descr__bases),
+ __base__ = GetSetProperty(descr__base),
__mro__ = GetSetProperty(descr_get__mro__),
__dict__ = default_dict_descr,
)
More information about the Pypy-commit
mailing list