[issue20699] Behavior of ZipFile with file-like object and BufferedWriter.

Martin Panter report at bugs.python.org
Sun Jun 8 08:28:00 CEST 2014


Martin Panter added the comment:

I have a related issue in Python 3.4. I suspect it is the same underlying problem as Henning’s. BufferedWriter is trying to write memoryview() objects, but the documentation for RawIOBase.write() implies it only has to accept bytes() and bytearray() objects.

>>> from io import BufferedWriter, RawIOBase
>>> class Raw(RawIOBase):
...     def writable(self): return True
...     def write(self, b): print(b.startswith(b"\n"))
... 
>>> b = BufferedWriter(Raw())
>>> b.write(b"abc")
3
>>> b.close()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "<stdin>", line 3, in write
AttributeError: 'memoryview' object has no attribute 'startswith'

----------
nosy: +vadmium
versions: +Python 3.4

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue20699>
_______________________________________


More information about the Python-bugs-list mailing list