[pypy-svn] rev 782 - pypy/trunk/src/pypy/objspace/std

mwh at codespeak.net mwh at codespeak.net
Sat Jun 7 20:55:19 CEST 2003


Author: mwh
Date: Sat Jun  7 20:55:19 2003
New Revision: 782

Modified:
   pypy/trunk/src/pypy/objspace/std/stringobject.py
Log:
some bogus implementations of things that await proper implementation


Modified: pypy/trunk/src/pypy/objspace/std/stringobject.py
==============================================================================
--- pypy/trunk/src/pypy/objspace/std/stringobject.py	(original)
+++ pypy/trunk/src/pypy/objspace/std/stringobject.py	Sat Jun  7 20:55:19 2003
@@ -5,6 +5,7 @@
 from listobject import W_ListObject
 from instmethobject import W_InstMethObject
 from noneobject import W_NoneObject
+from tupleobject import W_TupleObject
 from pypy.interpreter.extmodule import make_builtin_func
 
 from rarray import CharArrayFromStr, CharArraySize
@@ -293,8 +294,8 @@
                              W_StringObject, W_IntObject)
 
 def getitem_str_slice(space, w_str, w_slice):
-#    return space.gethelper(applicationfile).call(
-#        "getitem_string_slice", [w_str, w_slice])
+    return space.gethelper(applicationfile).call(
+        "getitem_string_slice", [w_str, w_slice])
     w = space.wrap
     u = space.unwrap
     w_start, w_stop, w_step, w_sl = w_slice.indices(w(w_str._value.len))
@@ -338,8 +339,24 @@
 
 def str_repr(space, w_str):
     # XXX this is bogus -- mwh
+    return space.wrap(repr(space.unwrap(w_str)))
     a = space.add
     q = space.wrap("'")
     return a(a(q, w_str), q)
 
 StdObjSpace.repr.register(str_repr, W_StringObject)
+
+def str_ord(space, w_str):
+    return space.wrap(ord(space.unwrap(w_str)))
+
+StdObjSpace.ord.register(str_ord, W_StringObject)
+
+def str_mod_any(space, w_str, w_item):
+    return str_mod_tuple(space, w_str, space.newtuple([w_item]))
+
+StdObjSpace.mod.register(str_mod_any, W_StringObject, W_ANY)
+
+def str_mod_tuple(space, w_str, w_tuple):
+    return space.wrap(space.unwrap(w_str)%space.unwrap(w_tuple))
+
+StdObjSpace.mod.register(str_mod_tuple, W_StringObject, W_TupleObject)


More information about the Pypy-commit mailing list