Author: Philip Jenvey <[email protected]>
Branch: py3k
Changeset: r72466:706409dc5979
Date: 2014-07-17 13:14 -0700
http://bitbucket.org/pypy/pypy/changeset/706409dc5979/
Log: Merged in yuyichao/pypy/py3k-posix-decode (pull request #247)
fix ascii decoding error in the posix module
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
@@ -488,8 +488,7 @@
cur = os.getlogin()
except OSError, e:
raise wrap_oserror(space, e)
- else:
- return space.wrap(cur)
+ return space.fsdecode(space.wrapbytes(cur))
# ____________________________________________________________
@@ -695,14 +694,21 @@
except OSError, e:
raise wrap_oserror(space, e)
-@unwrap_spec(path='fsencode')
-def readlink(space, path):
+def readlink(space, w_path):
"Return a string representing the path to which the symbolic link points."
+ is_unicode = space.isinstance_w(w_path, space.w_unicode)
+ if is_unicode:
+ path = space.fsencode_w(w_path)
+ else:
+ path = space.bytes0_w(w_path)
try:
result = os.readlink(path)
except OSError, e:
- raise wrap_oserror(space, e, path)
- return space.wrap(result)
+ raise wrap_oserror2(space, e, w_path)
+ w_result = space.wrapbytes(result)
+ if is_unicode:
+ return space.fsdecode(w_result)
+ return w_result
before_fork_hooks = []
after_fork_child_hooks = []
@@ -892,7 +898,8 @@
r = os.uname()
except OSError, 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.fsdecode(space.wrapbytes(i))
+ for i in [r[0], r[1], r[2], r[3], r[4]]]
return space.newtuple(l_w)
def getuid(space):
@@ -1219,7 +1226,7 @@
@unwrap_spec(fd=c_int)
def ttyname(space, fd):
try:
- return space.wrap(os.ttyname(fd))
+ return space.fsdecode(space.wrapbytes(os.ttyname(fd)))
except OSError, e:
raise wrap_oserror(space, e)
@@ -1354,7 +1361,7 @@
Return the name of the controlling terminal for this process.
"""
- return space.wrap(os.ctermid())
+ return space.fsdecode(space.wrapbytes(os.ctermid()))
@unwrap_spec(fd=c_int)
def device_encoding(space, fd):
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit