Author: Brian Kearns <[email protected]>
Branch: stdlib-2.7.8
Changeset: r73034:b8a0ce713c2e
Date: 2014-08-24 16:03 -0400
http://bitbucket.org/pypy/pypy/changeset/b8a0ce713c2e/

Log:    ensure bz2 file sets name attribute before opening

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
@@ -250,6 +250,7 @@
     def direct_bz2__init__(self, w_name, mode='r', buffering=-1,
                            compresslevel=9):
         self.direct_close()
+        self.w_name = w_name
         # the stream should always be opened in binary mode
         if "b" not in mode:
             mode = mode + "b"
diff --git a/pypy/module/bz2/test/test_bz2_file.py 
b/pypy/module/bz2/test/test_bz2_file.py
--- a/pypy/module/bz2/test/test_bz2_file.py
+++ b/pypy/module/bz2/test/test_bz2_file.py
@@ -97,6 +97,9 @@
         # a large buf size
         BZ2File(self.temppath, mode='w', buffering=4096)
 
+        exc = raises(IOError, BZ2File, 'xxx', 'r')
+        assert "'xxx'" in str(exc.value)
+
     def test_close(self):
         from bz2 import BZ2File
 
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to