[pypy-commit] pypy default: Add space.newfilename(), which is meant to replace the py3.5
arigo
pypy.commits at gmail.com
Tue Feb 21 08:33:32 EST 2017
Author: Armin Rigo <arigo at tunes.org>
Branch:
Changeset: r90264:168885e476f6
Date: 2017-02-21 14:32 +0100
http://bitbucket.org/pypy/pypy/changeset/168885e476f6/
Log: Add space.newfilename(), which is meant to replace the py3.5
space.wrap_fsdecoded()
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
@@ -501,7 +501,7 @@
except OSError as e:
raise wrap_oserror(space, e)
else:
- return space.newtext(cur)
+ return space.newfilename(cur)
# ____________________________________________________________
@@ -915,7 +915,7 @@
r = os.uname()
except OSError as e:
raise wrap_oserror(space, e)
- l_w = [space.newtext(i) for i in [r[0], r[1], r[2], r[3], r[4]]]
+ l_w = [space.newfilename(i) for i in [r[0], r[1], r[2], r[3], r[4]]]
return space.newtuple(l_w)
def getuid(space):
@@ -1226,7 +1226,7 @@
@unwrap_spec(fd=c_int)
def ttyname(space, fd):
try:
- return space.newtext(os.ttyname(fd))
+ return space.newfilename(os.ttyname(fd))
except OSError as e:
raise wrap_oserror(space, e)
@@ -1365,4 +1365,4 @@
Return the name of the controlling terminal for this process.
"""
- return space.newtext(os.ctermid())
+ return space.newfilename(os.ctermid())
diff --git a/pypy/objspace/fake/objspace.py b/pypy/objspace/fake/objspace.py
--- a/pypy/objspace/fake/objspace.py
+++ b/pypy/objspace/fake/objspace.py
@@ -213,6 +213,7 @@
newtext = newbytes
newtext_or_none = newbytes
+ newfilename = newbytes
@not_rpython
def wrap(self, x):
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
@@ -343,6 +343,10 @@
return self.w_None
return self.newtext(s)
+ def newfilename(self, s):
+ assert isinstance(s, str) # on pypy3, this decodes the byte string
+ return W_BytesObject(s) # with the filesystem encoding
+
def newunicode(self, uni):
assert uni is not None
assert isinstance(uni, unicode)
More information about the pypy-commit
mailing list