[pypy-svn] rev 490 - in pypy/trunk/src/pypy: interpreter/test objspace/std
arigo at codespeak.net
arigo at codespeak.net
Tue May 27 10:51:51 CEST 2003
Author: arigo
Date: Tue May 27 10:51:51 2003
New Revision: 490
Modified:
pypy/trunk/src/pypy/interpreter/test/hello_world.py
pypy/trunk/src/pypy/objspace/std/objspace.py
pypy/trunk/src/pypy/objspace/std/stringobject.py
Log:
got newstring() do some type-checking
Modified: pypy/trunk/src/pypy/interpreter/test/hello_world.py
==============================================================================
--- pypy/trunk/src/pypy/interpreter/test/hello_world.py (original)
+++ pypy/trunk/src/pypy/interpreter/test/hello_world.py Tue May 27 10:51:51 2003
@@ -3,4 +3,6 @@
print len(aStr)
map(main, ["hello world", "good bye"])
-apply(main, ("apply works, too",))
\ No newline at end of file
+apply(main, ("apply works, too",))
+
+print chr(65)
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 Tue May 27 10:51:51 2003
@@ -100,7 +100,14 @@
# nyyyaaaaaaaaagh! what do we do if chars_w is not a list, or
# if it is a list, but contains things other than wrapped
# integers -- mwh
- chars = [chr(self.unwrap(w_c)) for w_c in chars_w]
+ try:
+ chars = [chr(self.unwrap(w_c)) for w_c in chars_w]
+ except TypeError: # chr(not-an-integer)
+ raise OperationError(self.w_TypeError,
+ self.wrap("an integer is required"))
+ except ValueError: # chr(out-of-range)
+ raise OperationError(self.w_ValueError,
+ self.wrap("character code not in range(256)"))
import stringobject
return stringobject.W_StringObject(''.join(chars))
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 Tue May 27 10:51:51 2003
@@ -85,3 +85,8 @@
return space.wrap(len(w_str.value))
StdObjSpace.len.register(len_str, W_StringObject)
+
+def str_str(space, w_str):
+ return w_str
+
+StdObjSpace.str.register(str_str, W_StringObject)
More information about the Pypy-commit
mailing list