Author: Armin Rigo <[email protected]>
Branch:
Changeset: r88538:23ffdb9eb9cc
Date: 2016-11-22 11:44 +0100
http://bitbucket.org/pypy/pypy/changeset/23ffdb9eb9cc/
Log: Fixes for 8c314acb8dd4
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
@@ -495,11 +495,10 @@
if space.isinstance_w(w_data, space.w_unicode):
# note: "encode" is called before we acquire the lock
# for this file, which is done in file_write_str().
- # Direct access to unicodeobject because we don't want
+ # Use a specific space method because we don't want
# to call user-defined "encode" methods here.
- from pypy.objspace.std.unicodeobject import encode_object
- w_data = encode_object(space, w_data, self.encoding,
- self.errors)
+ w_data = space.encode_unicode_object(w_data,
+ self.encoding, self.errors)
data = space.charbuf_w(w_data)
self.file_write_str(data)
diff --git a/pypy/module/bz2/interp_bz2.py b/pypy/module/bz2/interp_bz2.py
--- a/pypy/module/bz2/interp_bz2.py
+++ b/pypy/module/bz2/interp_bz2.py
@@ -293,7 +293,7 @@
same_attributes_as_in_file.remove('__init__')
same_attributes_as_in_file.extend([
'name', 'mode', 'encoding', 'closed', 'newlines', 'softspace',
- 'writelines', '__exit__', '__weakref__'])
+ 'writelines', '__exit__', '__weakref__', 'write'])
W_BZ2File.typedef = TypeDef(
"BZ2File",
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
@@ -330,6 +330,9 @@
def unicode_from_object(self, w_obj):
return w_some_obj()
+ def encode_unicode_object(self, w_unicode, encoding, errors):
+ return w_some_obj()
+
def _try_fetch_pycode(self, w_func):
return None
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
@@ -626,6 +626,10 @@
from pypy.objspace.std.unicodeobject import unicode_from_object
return unicode_from_object(self, w_obj)
+ def encode_unicode_object(self, w_unicode, encoding, errors):
+ from pypy.objspace.std.unicodeobject import encode_object
+ return encode_object(self, w_unicode, encoding, errors)
+
def call_method(self, w_obj, methname, *arg_w):
return callmethod.call_method_opt(self, w_obj, methname, *arg_w)
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit