Author: Carl Friedrich Bolz <cfb...@gmx.de>
Branch: space-newtext
Changeset: r88100:b3e96486e8ae
Date: 2016-11-03 07:59 +0100
http://bitbucket.org/pypy/pypy/changeset/b3e96486e8ae/

Log:    posix

diff --git a/pypy/module/posix/interp_posix.py 
b/pypy/module/posix/interp_posix.py
--- a/pypy/module/posix/interp_posix.py
+++ b/pypy/module/posix/interp_posix.py
@@ -31,9 +31,9 @@
 
 def wrap_uid(space, uid):
     if uid <= r_uint(sys.maxint):
-        return space.wrap(intmask(uid))
+        return space.newint(intmask(uid))
     else:
-        return space.wrap(uid)     # an unsigned number
+        return space.newint(uid)     # an unsigned number
 wrap_gid = wrap_uid
 
 def fsencode_w(space, w_obj):
@@ -112,7 +112,7 @@
             space, w_fname, flag, mode)
     except OSError as e:
         raise wrap_oserror2(space, e, w_fname)
-    return space.wrap(fd)
+    return space.newint(fd)
 
 @unwrap_spec(fd=c_int, pos=r_longlong, how=c_int)
 def lseek(space, fd, pos, how):
@@ -124,7 +124,7 @@
     except OSError as e:
         raise wrap_oserror(space, e)
     else:
-        return space.wrap(pos)
+        return space.newint(pos)
 
 @unwrap_spec(fd=c_int)
 def isatty(space, fd):
@@ -135,7 +135,7 @@
     except OSError as e:
         raise wrap_oserror(space, e)
     else:
-        return space.wrap(res)
+        return space.newbool(res)
 
 @unwrap_spec(fd=c_int, buffersize=int)
 def read(space, fd, buffersize):
@@ -145,7 +145,7 @@
     except OSError as e:
         raise wrap_oserror(space, e)
     else:
-        return space.wrap(s)
+        return space.newbytes(s)
 
 @unwrap_spec(fd=c_int)
 def write(space, fd, w_data):
@@ -157,7 +157,7 @@
     except OSError as e:
         raise wrap_oserror(space, e)
     else:
-        return space.wrap(res)
+        return space.newint(res)
 
 @unwrap_spec(fd=c_int)
 def close(space, fd):
@@ -180,9 +180,9 @@
     except IOError as e:
         if not objectmodel.we_are_translated():
             # Python 2.6 raises an IOError here. Let's not repeat that mistake.
-            w_error = space.call_function(space.w_OSError, space.wrap(e.errno),
-                                          space.wrap(e.strerror),
-                                          space.wrap(e.filename))
+            w_error = space.call_function(space.w_OSError, 
space.newint(e.errno),
+                                          space.newtext(e.strerror),
+                                          space.newtext(e.filename))
             raise OperationError(space.w_OSError, w_error)
         raise AssertionError
     except OSError as e:
@@ -229,35 +229,35 @@
         if i < rposix_stat.N_INDEXABLE_FIELDS:
             # get the first 10 items by indexing; this gives us
             # 'st_Xtime' as an integer, too
-            w_value = space.wrap(st[i])
+            w_value = space.newint(st[i])
             lst[i] = w_value
         elif name.startswith('st_'):    # exclude 'nsec_Xtime'
-            w_value = space.wrap(getattr(st, name))
-            space.setitem(w_keywords, space.wrap(name), w_value)
+            w_value = space.newint(getattr(st, name))
+            space.setitem(w_keywords, space.newtext(name), w_value)
 
     # non-rounded values for name-based access
     if stat_float_times:
         space.setitem(w_keywords,
-                      space.wrap('st_atime'), space.wrap(st.st_atime))
+                      space.newtext('st_atime'), space.newfloat(st.st_atime))
         space.setitem(w_keywords,
-                      space.wrap('st_mtime'), space.wrap(st.st_mtime))
+                      space.newtext('st_mtime'), space.newfloat(st.st_mtime))
         space.setitem(w_keywords,
-                      space.wrap('st_ctime'), space.wrap(st.st_ctime))
+                      space.newtext('st_ctime'), space.newfloat(st.st_ctime))
     #else:
     #   filled by the __init__ method
 
     w_tuple = space.newtuple(lst)
     w_stat_result = space.getattr(space.getbuiltinmodule(os.name),
-                                  space.wrap('stat_result'))
+                                  space.newtext('stat_result'))
     return space.call_function(w_stat_result, w_tuple, w_keywords)
 
 
 def build_statvfs_result(space, st):
     vals_w = [None] * len(rposix_stat.STATVFS_FIELDS)
     for i, (name, _) in STATVFS_FIELDS:
-        vals_w[i] = space.wrap(getattr(st, name))
+        vals_w[i] = space.newint(getattr(st, name))
     w_tuple = space.newtuple(vals_w)
-    w_statvfs_result = space.getattr(space.getbuiltinmodule(os.name), 
space.wrap('statvfs_result'))
+    w_statvfs_result = space.getattr(space.getbuiltinmodule(os.name), 
space.newtext('statvfs_result'))
     return space.call_function(w_statvfs_result, w_tuple)
 
 
@@ -318,7 +318,7 @@
     state = space.fromcache(StatState)
 
     if w_value is None:
-        return space.wrap(state.stat_float_times)
+        return space.newbool(state.stat_float_times)
     else:
         state.stat_float_times = space.bool_w(w_value)
 
@@ -351,7 +351,7 @@
     except OSError as e:
         raise wrap_oserror(space, e)
     else:
-        return space.wrap(newfd)
+        return space.newint(newfd)
 
 @unwrap_spec(old_fd=c_int, new_fd=c_int)
 def dup2(space, old_fd, new_fd):
@@ -377,7 +377,7 @@
     except OSError as e:
         raise wrap_oserror2(space, e, w_path)
     else:
-        return space.wrap(ok)
+        return space.newint(ok)
 
 
 def times(space):
@@ -391,11 +391,11 @@
     except OSError as e:
         raise wrap_oserror(space, e)
     else:
-        return space.newtuple([space.wrap(times[0]),
-                               space.wrap(times[1]),
-                               space.wrap(times[2]),
-                               space.wrap(times[3]),
-                               space.wrap(times[4])])
+        return space.newtuple([space.newfloat(times[0]),
+                               space.newfloat(times[1]),
+                               space.newfloat(times[2]),
+                               space.newfloat(times[3]),
+                               space.newfloat(times[4])])
 
 @unwrap_spec(cmd='str0')
 def system(space, cmd):
@@ -405,7 +405,7 @@
     except OSError as e:
         raise wrap_oserror(space, e)
     else:
-        return space.wrap(rc)
+        return space.newint(rc)
 
 def unlink(space, w_path):
     """Remove a file (same as remove(path))."""
@@ -427,11 +427,11 @@
         if space.isinstance_w(w_path, space.w_unicode):
             path = FileEncoder(space, w_path)
             fullpath = rposix.getfullpathname(path)
-            w_fullpath = space.wrap(fullpath)
+            w_fullpath = space.newtext(fullpath)
         else:
             path = space.str0_w(w_path)
             fullpath = rposix.getfullpathname(path)
-            w_fullpath = space.wrap(fullpath)
+            w_fullpath = space.newtext(fullpath)
     except OSError as e:
         raise wrap_oserror2(space, e, w_path)
     else:
@@ -444,7 +444,7 @@
     except OSError as e:
         raise wrap_oserror(space, e)
     else:
-        return space.wrap(cur)
+        return space.newtext(cur)
 
 if _WIN32:
     def getcwdu(space):
@@ -454,7 +454,7 @@
         except OSError as e:
             raise wrap_oserror(space, e)
         else:
-            return space.wrap(cur)
+            return space.newunicode(cur)
 else:
     def getcwdu(space):
         """Return the current working directory as a unicode string."""
@@ -491,7 +491,7 @@
         text = os.strerror(errno)
     except ValueError:
         raise oefmt(space.w_ValueError, "strerror() argument out of range")
-    return space.wrap(text)
+    return space.newtext(text)
 
 def getlogin(space):
     """Return the currently logged in user."""
@@ -500,14 +500,14 @@
     except OSError as e:
         raise wrap_oserror(space, e)
     else:
-        return space.wrap(cur)
+        return space.newtext(cur)
 
 # ____________________________________________________________
 
 def getstatfields(space):
     # for app_posix.py: export the list of 'st_xxx' names that we know
     # about at RPython level
-    return space.newlist([space.wrap(name) for _, (name, _) in STAT_FIELDS])
+    return space.newlist([space.newtext(name) for _, (name, _) in STAT_FIELDS])
 
 
 class State:
@@ -531,7 +531,7 @@
 def _convertenviron(space, w_env):
     space.call_method(w_env, 'clear')
     for key, value in os.environ.items():
-        space.setitem(w_env, space.wrap(key), space.wrap(value))
+        space.setitem(w_env, space.newtext(key), space.newtext(value))
 
 @unwrap_spec(name='str0', value='str0')
 def putenv(space, name, value):
@@ -579,7 +579,7 @@
             len_result = len(result)
             result_w = [None] * len_result
             for i in range(len_result):
-                w_bytes = space.wrap(result[i])
+                w_bytes = space.newtext(result[i])
                 try:
                     result_w[i] = space.call_method(w_bytes,
                                                     "decode", w_fs_encoding)
@@ -604,7 +604,7 @@
         fd1, fd2 = os.pipe()
     except OSError as e:
         raise wrap_oserror(space, e)
-    return space.newtuple([space.wrap(fd1), space.wrap(fd2)])
+    return space.newtuple([space.newint(fd1), space.newint(fd2)])
 
 @unwrap_spec(mode=c_int)
 def chmod(space, w_path, mode):
@@ -656,7 +656,7 @@
 def umask(space, mask):
     "Set the current numeric umask and return the previous umask."
     prevmask = os.umask(mask)
-    return space.wrap(prevmask)
+    return space.newint(prevmask)
 
 def getpid(space):
     "Return the current process id."
@@ -664,7 +664,7 @@
         pid = os.getpid()
     except OSError as e:
         raise wrap_oserror(space, e)
-    return space.wrap(pid)
+    return space.newint(pid)
 
 @unwrap_spec(pid=c_int, sig=c_int)
 def kill(space, pid, sig):
@@ -710,7 +710,7 @@
         result = os.readlink(path)
     except OSError as e:
         raise wrap_oserror(space, e, path)
-    return space.wrap(result)
+    return space.newtext(result)
 
 before_fork_hooks = []
 after_fork_child_hooks = []
@@ -763,7 +763,7 @@
 
 def fork(space):
     pid, irrelevant = _run_forking_function(space, "F")
-    return space.wrap(pid)
+    return space.newint(pid)
 
 def openpty(space):
     "Open a pseudo-terminal, returning open fd's for both master and slave 
end."
@@ -771,12 +771,12 @@
         master_fd, slave_fd = os.openpty()
     except OSError as e:
         raise wrap_oserror(space, e)
-    return space.newtuple([space.wrap(master_fd), space.wrap(slave_fd)])
+    return space.newtuple([space.newint(master_fd), space.newint(slave_fd)])
 
 def forkpty(space):
     pid, master_fd = _run_forking_function(space, "P")
-    return space.newtuple([space.wrap(pid),
-                           space.wrap(master_fd)])
+    return space.newtuple([space.newint(pid),
+                           space.newint(master_fd)])
 
 @unwrap_spec(pid=c_int, options=c_int)
 def waitpid(space, pid, options):
@@ -788,7 +788,7 @@
         pid, status = os.waitpid(pid, options)
     except OSError as e:
         raise wrap_oserror(space, e)
-    return space.newtuple([space.wrap(pid), space.wrap(status)])
+    return space.newtuple([space.newint(pid), space.newint(status)])
 
 @unwrap_spec(status=c_int)
 def _exit(space, status):
@@ -853,7 +853,7 @@
         ret = os.spawnv(mode, path, args)
     except OSError as e:
         raise wrap_oserror(space, e)
-    return space.wrap(ret)
+    return space.newint(ret)
 
 @unwrap_spec(mode=int, path='str0')
 def spawnve(space, mode, path, w_args, w_env):
@@ -863,7 +863,7 @@
         ret = os.spawnve(mode, path, args, env)
     except OSError as e:
         raise wrap_oserror(space, e)
-    return space.wrap(ret)
+    return space.newint(ret)
 
 def utime(space, w_path, w_tuple):
     """ utime(path, (atime, mtime))
@@ -902,7 +902,7 @@
         r = os.uname()
     except OSError as e:
         raise wrap_oserror(space, e)
-    l_w = [space.wrap(i) for i in [r[0], r[1], r[2], r[3], r[4]]]
+    l_w = [space.newtext(i) for i in [r[0], r[1], r[2], r[3], r[4]]]
     return space.newtuple(l_w)
 
 def getuid(space):
@@ -1031,7 +1031,7 @@
 
     Return the current process group id.
     """
-    return space.wrap(os.getpgrp())
+    return space.newint(os.getpgrp())
 
 def setpgrp(space):
     """ setpgrp()
@@ -1049,7 +1049,7 @@
 
     Return the parent's process id.
     """
-    return space.wrap(os.getppid())
+    return space.newint(os.getppid())
 
 @unwrap_spec(pid=c_int)
 def getpgid(space, pid):
@@ -1061,7 +1061,7 @@
         pgid = os.getpgid(pid)
     except OSError as e:
         raise wrap_oserror(space, e)
-    return space.wrap(pgid)
+    return space.newint(pgid)
 
 @unwrap_spec(pid=c_int, pgrp=c_int)
 def setpgid(space, pid, pgrp):
@@ -1107,7 +1107,7 @@
         sid = os.getsid(pid)
     except OSError as e:
         raise wrap_oserror(space, e)
-    return space.wrap(sid)
+    return space.newint(sid)
 
 def setsid(space):
     """ setsid()
@@ -1130,7 +1130,7 @@
         pgid = os.tcgetpgrp(fd)
     except OSError as e:
         raise wrap_oserror(space, e)
-    return space.wrap(pgid)
+    return space.newint(pgid)
 
 @unwrap_spec(fd=c_int, pgid=c_int)
 def tcsetpgrp(space, fd, pgid):
@@ -1195,7 +1195,7 @@
     if name in ('WEXITSTATUS', 'WSTOPSIG', 'WTERMSIG'):
         @unwrap_spec(status=c_int)
         def WSTAR(space, status):
-            return space.wrap(getattr(os, name)(status))
+            return space.newint(getattr(os, name)(status))
     else:
         @unwrap_spec(status=c_int)
         def WSTAR(space, status):
@@ -1235,7 +1235,7 @@
         res = os.sysconf(num)
     except OSError as e:
         raise wrap_oserror(space, e)
-    return space.wrap(res)
+    return space.newint(res)
 
 @unwrap_spec(fd=c_int)
 def fpathconf(space, fd, w_name):
@@ -1244,7 +1244,7 @@
         res = os.fpathconf(fd, num)
     except OSError as e:
         raise wrap_oserror(space, e)
-    return space.wrap(res)
+    return space.newint(res)
 
 @unwrap_spec(path='str0')
 def pathconf(space, path, w_name):
@@ -1253,7 +1253,7 @@
         res = os.pathconf(path, num)
     except OSError as e:
         raise wrap_oserror(space, e)
-    return space.wrap(res)
+    return space.newint(res)
 
 def confstr(space, w_name):
     num = confname_w(space, w_name, os.confstr_names)
@@ -1261,7 +1261,7 @@
         res = os.confstr(num)
     except OSError as e:
         raise wrap_oserror(space, e)
-    return space.wrap(res)
+    return space.newtext(res)
 
 @unwrap_spec(path='str0', uid=c_uid_t, gid=c_gid_t)
 def chown(space, path, uid, gid):
@@ -1295,24 +1295,24 @@
         load = os.getloadavg()
     except OSError:
         raise oefmt(space.w_OSError, "Load averages are unobtainable")
-    return space.newtuple([space.wrap(load[0]),
-                           space.wrap(load[1]),
-                           space.wrap(load[2])])
+    return space.newtuple([space.newfloat(load[0]),
+                           space.newfloat(load[1]),
+                           space.newfloat(load[2])])
 
 @unwrap_spec(major=c_int, minor=c_int)
 def makedev(space, major, minor):
     result = os.makedev(major, minor)
-    return space.wrap(result)
+    return space.newint(result)
 
 @unwrap_spec(device="c_uint")
 def major(space, device):
     result = os.major(intmask(device))
-    return space.wrap(result)
+    return space.newint(result)
 
 @unwrap_spec(device="c_uint")
 def minor(space, device):
     result = os.minor(intmask(device))
-    return space.wrap(result)
+    return space.newint(result)
 
 @unwrap_spec(inc=c_int)
 def nice(space, inc):
@@ -1321,7 +1321,7 @@
         res = os.nice(inc)
     except OSError as e:
         raise wrap_oserror(space, e)
-    return space.wrap(res)
+    return space.newint(res)
 
 @unwrap_spec(n=int)
 def urandom(space, n):
@@ -1331,7 +1331,7 @@
     """
     context = get(space).random_context
     try:
-        return space.wrap(rurandom.urandom(context, n))
+        return space.newbytes(rurandom.urandom(context, n))
     except OSError as e:
         raise wrap_oserror(space, e)
 
@@ -1340,4 +1340,4 @@
 
     Return the name of the controlling terminal for this process.
     """
-    return space.wrap(os.ctermid())
+    return space.newtext(os.ctermid())
_______________________________________________
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to