[pypy-svn] r48483 - in pypy/branch/unicode-objspace/pypy: interpreter interpreter/test module/__builtin__ objspace objspace/cpy objspace/cpy/test objspace/fake objspace/std translator

cfbolz at codespeak.net cfbolz at codespeak.net
Sat Nov 10 00:40:56 CET 2007


Author: cfbolz
Date: Sat Nov 10 00:40:56 2007
New Revision: 48483

Modified:
   pypy/branch/unicode-objspace/pypy/interpreter/baseobjspace.py
   pypy/branch/unicode-objspace/pypy/interpreter/test/test_objspace.py
   pypy/branch/unicode-objspace/pypy/interpreter/test/test_typedef.py
   pypy/branch/unicode-objspace/pypy/module/__builtin__/operation.py
   pypy/branch/unicode-objspace/pypy/objspace/cpy/objspace.py
   pypy/branch/unicode-objspace/pypy/objspace/cpy/test/test_objspace.py
   pypy/branch/unicode-objspace/pypy/objspace/dump.py
   pypy/branch/unicode-objspace/pypy/objspace/fake/objspace.py
   pypy/branch/unicode-objspace/pypy/objspace/logic.py
   pypy/branch/unicode-objspace/pypy/objspace/std/objspace.py
   pypy/branch/unicode-objspace/pypy/objspace/thunk.py
   pypy/branch/unicode-objspace/pypy/translator/geninterplevel.py
Log:
get rid of newstring as well


Modified: pypy/branch/unicode-objspace/pypy/interpreter/baseobjspace.py
==============================================================================
--- pypy/branch/unicode-objspace/pypy/interpreter/baseobjspace.py	(original)
+++ pypy/branch/unicode-objspace/pypy/interpreter/baseobjspace.py	Sat Nov 10 00:40:56 2007
@@ -1036,7 +1036,6 @@
 #                              is_true(w_x) -> True or False
 #                  newtuple([w_1, w_2,...]) -> w_tuple
 #                   newlist([w_1, w_2,...]) -> w_list
-#                 newstring([w_1, w_2,...]) -> w_string from ascii numbers (bytes)
 #                                 newdict() -> empty w_dict
 #           newslice(w_start,w_stop,w_step) -> w_slice
 #              call_args(w_obj,Arguments()) -> w_result
@@ -1055,7 +1054,6 @@
     'is_w',
     'newtuple',
     'newlist',
-    'newstring',
     'newdict',
     'newslice',
     'call_args',

Modified: pypy/branch/unicode-objspace/pypy/interpreter/test/test_objspace.py
==============================================================================
--- pypy/branch/unicode-objspace/pypy/interpreter/test/test_objspace.py	(original)
+++ pypy/branch/unicode-objspace/pypy/interpreter/test/test_objspace.py	Sat Nov 10 00:40:56 2007
@@ -9,23 +9,6 @@
 # -- it's more to test that it's *there*
 
 class TestObjSpace: 
-    def test_newstring(self):
-        w = self.space.wrap
-        s = 'abc'
-        chars_w = [w(ord(c)) for c in s]
-        assert self.space.eq_w(w(s), self.space.newstring(chars_w))
-
-    def test_newstring_fail(self):
-        w = self.space.wrap
-        s = 'abc'
-        not_chars_w = [w(c) for c in s]
-        self.space.raises_w(self.space.w_TypeError,
-                            self.space.newstring,
-                            not_chars_w)
-        self.space.raises_w(self.space.w_ValueError,
-                            self.space.newstring,
-                            [w(-1)])
-
     def test_newlist(self):
         w = self.space.wrap
         l = range(10)

Modified: pypy/branch/unicode-objspace/pypy/interpreter/test/test_typedef.py
==============================================================================
--- pypy/branch/unicode-objspace/pypy/interpreter/test/test_typedef.py	(original)
+++ pypy/branch/unicode-objspace/pypy/interpreter/test/test_typedef.py	Sat Nov 10 00:40:56 2007
@@ -5,6 +5,7 @@
 class AppTestTraceBackAttributes:
 
     def test_newstring(self):
+        # XXX why is this called newstring?
         import sys
         def f():
             raise TypeError, "hello"

Modified: pypy/branch/unicode-objspace/pypy/module/__builtin__/operation.py
==============================================================================
--- pypy/branch/unicode-objspace/pypy/module/__builtin__/operation.py	(original)
+++ pypy/branch/unicode-objspace/pypy/module/__builtin__/operation.py	Sat Nov 10 00:40:56 2007
@@ -14,8 +14,12 @@
 
 def chr(space, w_ascii):
     "Return a string of one character with the given ascii code."
-    w_character = space.newstring([w_ascii])
-    return w_character
+    try:
+        char = __builtin__.chr(space.int_w(w_ascii))
+    except ValueError:  # chr(out-of-range)
+        raise OperationError(space.w_ValueError,
+                             space.wrap("character code not in range(256)"))
+    return space.wrap(char)
 
 def unichr(space, code):
     "Return a Unicode string of one character with the given ordinal."

Modified: pypy/branch/unicode-objspace/pypy/objspace/cpy/objspace.py
==============================================================================
--- pypy/branch/unicode-objspace/pypy/objspace/cpy/objspace.py	(original)
+++ pypy/branch/unicode-objspace/pypy/objspace/cpy/objspace.py	Sat Nov 10 00:40:56 2007
@@ -230,13 +230,6 @@
         PyString_InternInPlace(byref(w_s))
         return w_s
 
-    def newstring(self, bytes_w):
-        length = len(bytes_w)
-        buf = ctypes.create_string_buffer(length)
-        for i in range(length):
-            buf[i] = chr(self.int_w(bytes_w[i]))
-        return PyString_FromStringAndSize(buf, length)
-
     def newint(self, intval):
         return PyInt_FromLong(intval)
 

Modified: pypy/branch/unicode-objspace/pypy/objspace/cpy/test/test_objspace.py
==============================================================================
--- pypy/branch/unicode-objspace/pypy/objspace/cpy/test/test_objspace.py	(original)
+++ pypy/branch/unicode-objspace/pypy/objspace/cpy/test/test_objspace.py	Sat Nov 10 00:40:56 2007
@@ -49,9 +49,9 @@
     w2 = space.wrap(11)
     raises_w(space, space.w_TypeError, space.sub, w1, w2)
 
-def test_newstring():
+def test_wrapstring():
     space = CPyObjSpace()
-    w = space.newstring([space.wrap(65), space.wrap(66)])
+    w = space.wrap('AB')
     assert space.str_w(w) == 'AB'
 
 def test_wrapunicode():

Modified: pypy/branch/unicode-objspace/pypy/objspace/dump.py
==============================================================================
--- pypy/branch/unicode-objspace/pypy/objspace/dump.py	(original)
+++ pypy/branch/unicode-objspace/pypy/objspace/dump.py	Sat Nov 10 00:40:56 2007
@@ -153,7 +153,6 @@
         'is_w': 2,
         'newtuple': 0,
         'newlist': 0,
-        'newstring': 0,
         'newdict': 0,
         'newslice': 0,
         'call_args': 1,
@@ -164,7 +163,6 @@
         'wrap': True,
         'newtuple': True,
         'newlist': True,
-        'newstring': True,
         'newdict': True,
         'newslice': True,
         'call_args': True,

Modified: pypy/branch/unicode-objspace/pypy/objspace/fake/objspace.py
==============================================================================
--- pypy/branch/unicode-objspace/pypy/objspace/fake/objspace.py	(original)
+++ pypy/branch/unicode-objspace/pypy/objspace/fake/objspace.py	Sat Nov 10 00:40:56 2007
@@ -88,7 +88,6 @@
     str_w             = str_dummy
     call_args         = make_dummy()
     new_interned_str  = make_dummy()
-    newstring         = make_dummy()
     newint            = make_dummy()
     newlong           = make_dummy()
     newfloat          = make_dummy()

Modified: pypy/branch/unicode-objspace/pypy/objspace/logic.py
==============================================================================
--- pypy/branch/unicode-objspace/pypy/objspace/logic.py	(original)
+++ pypy/branch/unicode-objspace/pypy/objspace/logic.py	Sat Nov 10 00:40:56 2007
@@ -57,7 +57,6 @@
         'is_w': 2,
         'newtuple': 0,
         'newlist': 0,
-        'newstring': 0,
         'newdict': 0,
         'newslice': 0,
         'call_args': 1,

Modified: pypy/branch/unicode-objspace/pypy/objspace/std/objspace.py
==============================================================================
--- pypy/branch/unicode-objspace/pypy/objspace/std/objspace.py	(original)
+++ pypy/branch/unicode-objspace/pypy/objspace/std/objspace.py	Sat Nov 10 00:40:56 2007
@@ -525,14 +525,6 @@
     def newslice(self, w_start, w_end, w_step):
         return W_SliceObject(w_start, w_end, w_step)
 
-    def newstring(self, chars_w):
-        try:
-            chars = [chr(self.int_w(w_c)) for w_c in chars_w]
-        except ValueError:  # chr(out-of-range)
-            raise OperationError(self.w_ValueError,
-                                 self.wrap("character code not in range(256)"))
-        return self.wrap(''.join(chars))
-
     def newseqiter(self, w_obj):
         return W_SeqIterObject(w_obj)
 

Modified: pypy/branch/unicode-objspace/pypy/objspace/thunk.py
==============================================================================
--- pypy/branch/unicode-objspace/pypy/objspace/thunk.py	(original)
+++ pypy/branch/unicode-objspace/pypy/objspace/thunk.py	Sat Nov 10 00:40:56 2007
@@ -158,7 +158,6 @@
         'is_w': 2,
         'newtuple': 0,
         'newlist': 0,
-        'newstring': 0,
         'newdict': 0,
         'newslice': 0,
         'call_args': 1,

Modified: pypy/branch/unicode-objspace/pypy/translator/geninterplevel.py
==============================================================================
--- pypy/branch/unicode-objspace/pypy/translator/geninterplevel.py	(original)
+++ pypy/branch/unicode-objspace/pypy/translator/geninterplevel.py	Sat Nov 10 00:40:56 2007
@@ -177,7 +177,7 @@
 
         # special constructors:
         self.has_listarg = {}
-        for name in "newtuple newlist newstring".split():
+        for name in "newtuple newlist".split():
             self.has_listarg[name] = name
 
         # catching all builtins in advance, to avoid problems



More information about the Pypy-commit mailing list