New submission from Jakub Stasiak:

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).

----------
components: IO, Library (Lib)
keywords: patch
messages: 260053
nosy: jstasiak
priority: normal
severity: normal
status: open
title: Make mmap.write return the number of bytes written like other write 
methods
type: enhancement
versions: Python 3.6
Added file: http://bugs.python.org/file41890/mmap_write_return_count.patch

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue26335>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to