Author: Carl Friedrich Bolz <[email protected]>
Branch: space-newtext
Changeset: r88547:6673bc3db17b
Date: 2016-11-22 13:41 +0100
http://bitbucket.org/pypy/pypy/changeset/6673bc3db17b/

Log:    a number of fixes

diff --git a/pypy/goal/targetpypystandalone.py 
b/pypy/goal/targetpypystandalone.py
--- a/pypy/goal/targetpypystandalone.py
+++ b/pypy/goal/targetpypystandalone.py
@@ -33,7 +33,7 @@
     if w_dict is not None: # for tests
         w_entry_point = space.getitem(w_dict, space.newtext('entry_point'))
         w_run_toplevel = space.getitem(w_dict, space.newtext('run_toplevel'))
-        w_initstdio = space.getitem(w_dict, space.wrap('initstdio'))
+        w_initstdio = space.getitem(w_dict, space.newtext('initstdio'))
         withjit = space.config.objspace.usemodules.pypyjit
     else:
         w_initstdio = space.appexec([], """():
@@ -112,7 +112,7 @@
         try:
             # initialize sys.{path,executable,stdin,stdout,stderr}
             # (in unbuffered mode, to avoid troubles) and import site
-            space.appexec([w_path, space.wrap(home), w_initstdio],
+            space.appexec([w_path, space.newtext(home), w_initstdio],
             r"""(path, home, initstdio):
                 import sys
                 sys.path[:] = path
diff --git a/pypy/interpreter/astcompiler/misc.py 
b/pypy/interpreter/astcompiler/misc.py
--- a/pypy/interpreter/astcompiler/misc.py
+++ b/pypy/interpreter/astcompiler/misc.py
@@ -20,7 +20,7 @@
     If the user has set this warning to raise an error, a SyntaxError will be
     raised."""
     w_msg = space.newtext(msg)
-    w_filename = space.wrap(fn)
+    w_filename = space.newtext(fn)
     w_lineno = space.newint(lineno)
     w_offset = space.newint(offset)
     _emit_syntax_warning(space, w_msg, w_filename, w_lineno, w_offset)
diff --git a/pypy/interpreter/error.py b/pypy/interpreter/error.py
--- a/pypy/interpreter/error.py
+++ b/pypy/interpreter/error.py
@@ -557,6 +557,6 @@
             # when untranslated, we don't wrap into an app-level
             # SystemError (this makes debugging tests harder)
             raise
-        return OperationError(space.w_SystemError, space.wrap(
+        return OperationError(space.w_SystemError, space.newtext(
             "unexpected internal exception (please report a bug): %r%s" %
             (e, extra)))
diff --git a/pypy/module/_cffi_backend/cffi1_module.py 
b/pypy/module/_cffi_backend/cffi1_module.py
--- a/pypy/module/_cffi_backend/cffi1_module.py
+++ b/pypy/module/_cffi_backend/cffi1_module.py
@@ -43,8 +43,8 @@
     module = Module(space, w_name)
     if path is not None:
         module.setdictvalue(space, '__file__', space.newtext(path))
-    module.setdictvalue(space, 'ffi', space.newtext(ffi))
-    module.setdictvalue(space, 'lib', space.newtext(lib))
+    module.setdictvalue(space, 'ffi', ffi)
+    module.setdictvalue(space, 'lib', lib)
     w_modules_dict = space.sys.get('modules')
-    space.setitem(w_modules_dict, w_name, space.newtext(module))
-    space.setitem(w_modules_dict, space.newtext(name + '.lib'), 
space.newtext(lib))
+    space.setitem(w_modules_dict, w_name, module)
+    space.setitem(w_modules_dict, space.newtext(name + '.lib'), lib)
diff --git a/pypy/module/_file/interp_file.py b/pypy/module/_file/interp_file.py
--- a/pypy/module/_file/interp_file.py
+++ b/pypy/module/_file/interp_file.py
@@ -617,9 +617,9 @@
                                     "possibly with 'b' or '+' added)",
                                     wrapfn="newtext"),
     encoding = interp_attrproperty('encoding', cls=W_File,
-        wrapfn="wrap_none"),
+        wrapfn="newtext_or_none"),
     errors = interp_attrproperty('errors', cls=W_File,
-        wrapfn="wrap_none"),
+        wrapfn="newtext_or_none"),
     closed   = GetSetProperty(descr_file_closed, cls=W_File,
                               doc="True if the file is closed"),
     newlines = GetSetProperty(descr_file_newlines, cls=W_File,
diff --git a/pypy/module/_io/interp_textio.py b/pypy/module/_io/interp_textio.py
--- a/pypy/module/_io/interp_textio.py
+++ b/pypy/module/_io/interp_textio.py
@@ -908,7 +908,7 @@
                                              space.bytes_w(w_chunk))
 
             w_decoded = space.call_method(self.w_decoder, "decode",
-                                          w_chunk, 
space.newbool(cookie.need_eof))
+                                          w_chunk, 
space.newbool(bool(cookie.need_eof)))
             check_decoded(space, w_decoded)
             self._set_decoded_chars(space.unicode_w(w_decoded))
 
diff --git a/pypy/module/_pypyjson/interp_encoder.py 
b/pypy/module/_pypyjson/interp_encoder.py
--- a/pypy/module/_pypyjson/interp_encoder.py
+++ b/pypy/module/_pypyjson/interp_encoder.py
@@ -79,4 +79,4 @@
                 sb.append(HEX[s2 & 0x0f])
 
     res = sb.build()
-    return space.wrap(res)
+    return space.newtext(res)
diff --git a/pypy/module/_rawffi/alt/interp_funcptr.py 
b/pypy/module/_rawffi/alt/interp_funcptr.py
--- a/pypy/module/_rawffi/alt/interp_funcptr.py
+++ b/pypy/module/_rawffi/alt/interp_funcptr.py
@@ -342,7 +342,7 @@
         return space.newint(address_as_uint)
 
     def getidentifier(self, space):
-        return space.wrap(self.cdll.getidentifier())
+        return space.newint(self.cdll.getidentifier())
 
 @unwrap_spec(name='str_or_None', mode=int)
 def descr_new_cdll(space, w_type, name, mode=-1):
diff --git a/pypy/module/select/interp_select.py 
b/pypy/module/select/interp_select.py
--- a/pypy/module/select/interp_select.py
+++ b/pypy/module/select/interp_select.py
@@ -82,7 +82,7 @@
         retval_w = []
         for fd, revents in retval:
             retval_w.append(space.newtuple([space.newint(fd),
-                                            space.newtext(revents)]))
+                                            space.newint(revents)]))
         return space.newlist(retval_w)
 
 pollmethods = {}
diff --git a/pypy/module/token/__init__.py b/pypy/module/token/__init__.py
--- a/pypy/module/token/__init__.py
+++ b/pypy/module/token/__init__.py
@@ -7,7 +7,7 @@
 
     appleveldefs = {}
     interpleveldefs = {
-        "NT_OFFSET" : "space.wrap(256)",
+        "NT_OFFSET" : "space.newint(256)",
         "ISTERMINAL" : "__init__.isterminal",
         "ISNONTERMINAL" : "__init__.isnonterminal",
         "ISEOF" : "__init__.iseof"
@@ -27,12 +27,12 @@
 
 @unwrap_spec(tok=int)
 def isterminal(space, tok):
-    return space.wrap(tok < 256)
+    return space.newbool(tok < 256)
 
 @unwrap_spec(tok=int)
 def isnonterminal(space, tok):
-    return space.wrap(tok >= 256)
+    return space.newbool(tok >= 256)
 
 @unwrap_spec(tok=int)
 def iseof(space, tok):
-    return space.wrap(tok == pygram.tokens.ENDMARKER)
+    return space.newbool(tok == pygram.tokens.ENDMARKER)
diff --git a/pypy/objspace/std/listobject.py b/pypy/objspace/std/listobject.py
--- a/pypy/objspace/std/listobject.py
+++ b/pypy/objspace/std/listobject.py
@@ -2001,6 +2001,7 @@
     _none_value = None
 
     def wrap(self, stringval):
+        assert stringval is not None
         return self.space.newunicode(stringval)
 
     def unwrap(self, w_string):
diff --git a/pypy/objspace/std/objectobject.py 
b/pypy/objspace/std/objectobject.py
--- a/pypy/objspace/std/objectobject.py
+++ b/pypy/objspace/std/objectobject.py
@@ -98,7 +98,7 @@
             w_parent_init is not space.w_object):
             # 2.7: warn about excess arguments when both methods are
             # overridden
-            space.warn(space.wrap("object() takes no parameters"),
+            space.warn(space.newtext("object() takes no parameters"),
                        space.w_DeprecationWarning, 1)
         elif (w_parent_new is not space.w_object or
               w_parent_init is space.w_object):
@@ -122,7 +122,7 @@
             w_parent_new is not space.w_object):
             # 2.7: warn about excess arguments when both methods are
             # overridden
-            space.warn(space.wrap("object.__init__() takes no parameters"),
+            space.warn(space.newtext("object.__init__() takes no parameters"),
                        space.w_DeprecationWarning, 1)
         elif (w_parent_init is not space.w_object or
               w_parent_new is space.w_object):
diff --git a/pypy/objspace/std/objspace.py b/pypy/objspace/std/objspace.py
--- a/pypy/objspace/std/objspace.py
+++ b/pypy/objspace/std/objspace.py
@@ -8,7 +8,7 @@
 from rpython.rlib.objectmodel import instantiate, specialize, 
is_annotation_constant
 from rpython.rlib.debug import make_sure_not_resized
 from rpython.rlib.rarithmetic import base_int, widen, is_valid_int
-from rpython.rlib.objectmodel import import_from_mixin
+from rpython.rlib.objectmodel import import_from_mixin, enforceargs
 from rpython.rlib import jit
 
 # Object imports
@@ -340,6 +340,7 @@
         return self.newtext(s)
 
     def newunicode(self, uni):
+        assert uni is not None
         assert isinstance(uni, unicode)
         return W_UnicodeObject(uni)
 
diff --git a/pypy/objspace/std/transparent.py b/pypy/objspace/std/transparent.py
--- a/pypy/objspace/std/transparent.py
+++ b/pypy/objspace/std/transparent.py
@@ -39,9 +39,9 @@
 def setup(space):
     """Add proxy functions to the __pypy__ module."""
     w___pypy__ = space.getbuiltinmodule("__pypy__")
-    space.setattr(w___pypy__, space.newtext('tproxy'), space.wrap(app_proxy))
+    space.setattr(w___pypy__, space.newtext('tproxy'), 
app_proxy.spacebind(space))
     space.setattr(w___pypy__, space.newtext('get_tproxy_controller'),
-                  space.wrap(app_proxy_controller))
+                  app_proxy_controller.spacebind(space))
 
 
 def proxy(space, w_type, w_controller):
diff --git a/pypy/objspace/std/unicodeobject.py 
b/pypy/objspace/std/unicodeobject.py
--- a/pypy/objspace/std/unicodeobject.py
+++ b/pypy/objspace/std/unicodeobject.py
@@ -1,7 +1,8 @@
 """The builtin unicode implementation"""
 
 from rpython.rlib.objectmodel import (
-    compute_hash, compute_unique_id, import_from_mixin)
+    compute_hash, compute_unique_id, import_from_mixin,
+    enforceargs)
 from rpython.rlib.buffer import StringBuffer
 from rpython.rlib.rstring import StringBuilder, UnicodeBuilder
 from rpython.rlib.runicode import (
@@ -29,6 +30,7 @@
     import_from_mixin(StringMethods)
     _immutable_fields_ = ['_value']
 
+    @enforceargs(uni=unicode)
     def __init__(self, unistr):
         assert isinstance(unistr, unicode)
         self._value = unistr
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to