[issue20699] Document that binary IO classes work with bytes-likes objects

2016-06-10 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: Oh, I forgot to say my LGTM on your last patch. It LGTM. But I'm feeling the documentation epic about bytes-like objects is far from the end. -- ___ Python tracker

[issue20699] Document that binary IO classes work with bytes-likes objects

2016-06-10 Thread Martin Panter
Martin Panter added the comment: Thanks for you help figuring this out Serhiy, especially for the Python 2 case. -- resolution: -> fixed stage: commit review -> resolved status: open -> closed ___ Python tracker _

[issue20699] Document that binary IO classes work with bytes-likes objects

2016-06-10 Thread Roundup Robot
Roundup Robot added the comment: New changeset ec69518aeebc by Martin Panter in branch '2.7': Issue #20699: Document that “io” methods should accept memoryview https://hg.python.org/cpython/rev/ec69518aeebc -- ___ Python tracker

[issue20699] Document that binary IO classes work with bytes-likes objects

2016-06-07 Thread Martin Panter
Martin Panter added the comment: New patch that I plan to commit: * Use bytes instead of str * bytes, bytearray or memoryview for readinto() methods * bytes or memoryview for write() methods * Added single “Changed in version 2.7” notice under the IOBase class (rather than every version of read

[issue20699] Document that binary IO classes work with bytes-likes objects

2016-06-03 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: Current docs use "bytes or bytearray object" (without references). "bytes" is just an alias to "str" in 2.7, but I prefer to use this name, for consistency with 3.x and for accenting the binary nature of the data. Your new wording LGTM. --

[issue20699] Document that binary IO classes work with bytes-likes objects

2016-06-03 Thread Martin Panter
Martin Panter added the comment: I thought :class:`str` is better documented in Python 2, but I can write bytes if you prefer. I guess it is more consistent with the rest of io.rst. -- ___ Python tracker _

[issue20699] Document that binary IO classes work with bytes-likes objects

2016-06-03 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: Why :class:`str` and not :class:`bytes`? -- ___ Python tracker ___ ___ Python-bugs-list mailing li

[issue20699] Document that binary IO classes work with bytes-likes objects

2016-06-03 Thread Martin Panter
Martin Panter added the comment: I don’t see the point of mentioning array() objects at all. It’s hard to support array in a Python 2 implementation, as demonstrated by readinto(). And the special support for array('b') won’t help if you pass in array('B') with values 128–255. I see this as an

[issue20699] Document that binary IO classes work with bytes-likes objects

2016-06-03 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: array is supported explicitly in the Python implementation of readinto(). What if write not "usable with memoryview", but mention memoryview as an example? The object *b* should be a pre-allocated, writable array of bytes, such as :class:`bytearray`, :

[issue20699] Document that binary IO classes work with bytes-likes objects

2016-06-03 Thread Martin Panter
Martin Panter added the comment: Actually this bug report was opened because an implementation that lacked memoryview support was broken by 2.7. The point is to document that (a subset of) memoryview objects may be passed to custom implementations. Does this need a “changed in 2.7” notice? I a

[issue20699] Document that binary IO classes work with bytes-likes objects

2016-06-03 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: Since the _pyio implementation doesn't support general memoryview-like objects, I consider using the new buffer protocol in the C implementation an implementation detail. Other implementations can lack this support. I think it would be better to left the wor

[issue20699] Document that binary IO classes work with bytes-likes objects

2016-06-02 Thread Martin Panter
Martin Panter added the comment: I agree with avoiding the term “bytes-like object” in 2.7. It is easy to be specific when talking about concrete classes like BufferedWriter and BytesIO. But the harder question is what to specify for the abstract base classes. In patch v8, I propose to change

[issue20699] Document that binary IO classes work with bytes-likes objects

2016-05-27 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: Things are more complex in 2.7. Not all objects supporting old buffer protocol support new buffer protocol, and not all functions accepting old buffer protocol work with new buffer protocol. >>> buffer(array.array('I')) >>> memoryview(array.array('I')) Trac

[issue20699] Document that binary IO classes work with bytes-likes objects

2016-05-27 Thread Roundup Robot
Roundup Robot added the comment: New changeset bd41151a7429 by Martin Panter in branch '3.5': Issue #20699: Document that “io” methods accept bytes-like objects https://hg.python.org/cpython/rev/bd41151a7429 New changeset c1b40a29dc7a by Martin Panter in branch 'default': Issue #20699: Merge io

[issue20699] Document that binary IO classes work with bytes-likes objects

2016-05-27 Thread Martin Panter
Martin Panter added the comment: Porting this to Python 2 uncovered a few flaws that I am unsure how to best handle. In this patch I have added workarounds, but perhaps we can find better fixes. 1. The io.BytesIO.write() C implementation does not accept array.array() objects. I suspect it onl

[issue20699] Document that binary IO classes work with bytes-likes objects

2016-05-21 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: bytes-like-param.v6.patch LGTM. -- ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubs

[issue20699] Document that binary IO classes work with bytes-likes objects

2016-05-21 Thread Martin Panter
Martin Panter added the comment: I updated my patch thanks to Serhiy’s comments. Also omitted Arg Clinic generated code in this version to avoid future merge conflicts with the hashes. -- versions: +Python 3.6 -Python 3.4 Added file: http://bugs.python.org/file42934/bytes-like-param.v6.

[issue20699] Document that binary IO classes work with bytes-likes objects

2016-05-18 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: Added few minor comments on Rietveld. -- ___ Python tracker ___ ___ Python-bugs-list mailing list

[issue20699] Document that binary IO classes work with bytes-likes objects

2016-04-15 Thread Martin Panter
Martin Panter added the comment: Here is an updated patch merged with recent changes. I also added a sentence to the RawIOBase.write() and BufferedIOBase.write() documentation about access to the buffer after the method returns. And I added tests for this. -- Added file: http://bugs.py

[issue20699] Document that binary IO classes work with bytes-likes objects

2016-04-12 Thread Martin Panter
Martin Panter added the comment: After thinking about Issue 26720 (see also Issue 15994), I think it might be worth documenting not only that bytes-like objects may be passed, but in some cases the class should not be access the object after the method returns. This applies to at least RawIOBa

[issue20699] Document that binary IO classes work with bytes-likes objects

2015-02-22 Thread Martin Panter
Martin Panter added the comment: Posting bytes-like-param.v4.patch, with David’s suggested wording -- Added file: http://bugs.python.org/file38207/bytes-like-param.v4.patch ___ Python tracker __

[issue20699] Document that binary IO classes work with bytes-likes objects

2015-02-20 Thread R. David Murray
R. David Murray added the comment: How about "the length of b in bytes"? -- ___ Python tracker ___ ___ Python-bugs-list mailing list U

[issue20699] Document that binary IO classes work with bytes-likes objects

2015-02-20 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: Because it is not len(b). I fixed several bugs in Python code which called len() for bytes-like argument and failed with array.array or memoryview with non-byte items. The term "bytes-like object" is slightly misleading. In some cases it implies indexing an

[issue20699] Document that binary IO classes work with bytes-likes objects

2015-02-20 Thread Martin Panter
Martin Panter added the comment: Using len(b) is fine if b is a bytes() or bytearray() object, but a bytes-like object can be anything that you can pass to memoryview(). In general len(b) is not part of that protocol, so can return some other value, or even be unimplemented: >>> from array im

[issue20699] Document that binary IO classes work with bytes-likes objects

2015-02-20 Thread R. David Murray
R. David Murray added the comment: What is your objection to "len(b)"? When I read "len(b)" I know exactly what it means. When I read "the number of bytes in b", I have to think about it it, because it could mean "the number of bytes that that b is long" or "the number of bytes that have bee

[issue20699] Document that binary IO classes work with bytes-likes objects

2015-02-19 Thread Martin Panter
Martin Panter added the comment: Posting patch v3; thanks for the reviews! * Changed “buffer” → “object” * Made it clearer that the bytes-like object generalization only applies to method arguments, not return values * Minor fixes to wording -- Added file: http://bugs.python.org/file38

[issue20699] Document that binary IO classes work with bytes-likes objects

2015-02-12 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: The patch LGTM. But native speaker should check documentation part. -- title: Behavior of ZipFile with file-like object and BufferedWriter. -> Document that binary IO classes work with bytes-likes objects ___ Pytho