Author: Matti Picus <[email protected]>
Branch: unicode-utf8-py3
Changeset: r94965:beaa8a7c7e84
Date: 2018-08-06 21:59 -0700
http://bitbucket.org/pypy/pypy/changeset/beaa8a7c7e84/
Log: unicode0_w -> utf8_0_w
diff --git a/pypy/interpreter/baseobjspace.py b/pypy/interpreter/baseobjspace.py
--- a/pypy/interpreter/baseobjspace.py
+++ b/pypy/interpreter/baseobjspace.py
@@ -1717,6 +1717,16 @@
def utf8_w(self, w_obj):
return w_obj.utf8_w(self)
+ def utf8_0_w(self, w_obj):
+ "Like utf_w, but rejects strings with NUL bytes."
+ from rpython.rlib import rstring
+ result = w_obj.utf8_w(self)
+ if '\x00' in result:
+ raise oefmt(self.w_TypeError,
+ "argument must be a string without NUL "
+ "characters")
+ return rstring.assert_str0(result)
+
def convert_to_w_unicode(self, w_obj):
return w_obj.convert_to_w_unicode(self)
diff --git a/pypy/module/cpyext/unicodeobject.py
b/pypy/module/cpyext/unicodeobject.py
--- a/pypy/module/cpyext/unicodeobject.py
+++ b/pypy/module/cpyext/unicodeobject.py
@@ -595,7 +595,7 @@
w_output = space.fsdecode(w_obj)
if not space.isinstance_w(w_output, space.w_unicode):
raise oefmt(space.w_TypeError, "decoder failed to return unicode")
- data = space.unicode0_w(w_output) # Check for NUL bytes
+ data = space.utf8_0_w(w_output) # Check for NUL bytes
result[0] = make_ref(space, w_output)
return Py_CLEANUP_SUPPORTED
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
@@ -141,7 +141,7 @@
"can't specify None for path argument")
if _WIN32:
try:
- path_u = space.unicode0_w(w_value)
+ path_u = space.utf8_0_w(w_value)
return Path(-1, None, path_u, w_value)
except OperationError:
pass
diff --git a/pypy/module/posix/interp_scandir.py
b/pypy/module/posix/interp_scandir.py
--- a/pypy/module/posix/interp_scandir.py
+++ b/pypy/module/posix/interp_scandir.py
@@ -269,7 +269,7 @@
def get_stat_or_lstat(self, follow_symlinks): # 'follow_symlinks'
ignored
if not self.stat_cached:
- path = self.space.unicode0_w(self.fget_path(self.space))
+ path = self.space.utf8_0_w(self.fget_path(self.space))
self.d_stat = rposix_stat.stat(path)
self.stat_cached = True
return self.d_stat
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit