This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author jstasiak
Recipients jstasiak
Date 2016-02-10.22:55:37
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1455144937.95.0.515520937166.issue26335@psf.upfronthosting.co.za>
In-reply-to
Content
Since mmap objects are said to "behave like both bytearray and like file objects" I believe it's appropriate for the mmap.write() method to return the number of bytes written like write() of other file objects/interfaces I could find in the standard library for consistency reasons:

https://docs.python.org/3/library/io.html#io.BufferedIOBase.write
https://docs.python.org/3/library/io.html#io.BufferedWriter.write
https://docs.python.org/3/library/io.html#io.RawIOBase.write
https://docs.python.org/3/library/io.html#io.TextIOBase.write

Why I believe this would be useful: code that writes to file objects and tests the number of bytes/characters written right now will likely fail when it's passed a mmap object because its write() method returns None. With this patch applied it'll work transparently.

Please find proposed patch attached, I included information about the exception type in the documentation as it seems fitting (apologies for generating the patch using Git, I'll generate using Mercurial if necessary).
History
Date User Action Args
2016-02-10 22:55:38jstasiaksetrecipients: + jstasiak
2016-02-10 22:55:37jstasiaksetmessageid: <1455144937.95.0.515520937166.issue26335@psf.upfronthosting.co.za>
2016-02-10 22:55:37jstasiaklinkissue26335 messages
2016-02-10 22:55:37jstasiakcreate