Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(21637)

Delta Between Two Patch Sets: Doc/library/mmap.rst

Issue 26335: Make mmap.write return the number of bytes written like other write methods
Left Patch Set: Created 3 years, 3 months ago
Right Patch Set: Created 3 years, 3 months ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
« no previous file with change/comment | « no previous file | Lib/test/test_mmap.py » ('j') | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
1 :mod:`mmap` --- Memory-mapped file support 1 :mod:`mmap` --- Memory-mapped file support
2 ========================================== 2 ==========================================
3 3
4 .. module:: mmap 4 .. module:: mmap
5 :synopsis: Interface to memory-mapped files for Unix and Windows. 5 :synopsis: Interface to memory-mapped files for Unix and Windows.
6 6
7 7
8 Memory-mapped file objects behave like both :class:`bytearray` and like 8 Memory-mapped file objects behave like both :class:`bytearray` and like
9 :term:`file objects <file object>`. You can use mmap objects in most places 9 :term:`file objects <file object>`. You can use mmap objects in most places
10 where :class:`bytearray` are expected; for example, you can use the :mod:`re` 10 where :class:`bytearray` are expected; for example, you can use the :mod:`re`
(...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after
256 256
257 257
258 .. method:: tell() 258 .. method:: tell()
259 259
260 Returns the current position of the file pointer. 260 Returns the current position of the file pointer.
261 261
262 262
263 .. method:: write(bytes) 263 .. method:: write(bytes)
264 264
265 Write the bytes in *bytes* into memory at the current position of the 265 Write the bytes in *bytes* into memory at the current position of the
266 file pointer and return the number of bytes written (never less than 266 file pointer and return the number of bytes written (never less than
berkerpeksag 2016/02/23 00:57:52 We also need a versionchanged directive to explain
267 len(bytes), since if the write fails a :exc:`ValueError` will be 267 len(bytes), since if the write fails a :exc:`ValueError` will be
268 raised). The file position is updated to point after the bytes that 268 raised). The file position is updated to point after the bytes that
269 were written. If the mmap was created with :const:`ACCESS_READ`, then 269 were written. If the mmap was created with :const:`ACCESS_READ`, then
270 writing to it will raise a :exc:`TypeError` exception. 270 writing to it will raise a :exc:`TypeError` exception.
271 271
272 .. versionchanged: 3.5 272 .. versionchanged: 3.5
273 Writable :term:`bytes-like object` is now accepted. 273 Writable :term:`bytes-like object` is now accepted.
274 274
275 .. versionchanged: 3.6
276 The number of bytes written is now returned (previously: *None*).
277
275 278
276 .. method:: write_byte(byte) 279 .. method:: write_byte(byte)
277 280
278 Write the integer *byte* into memory at the current 281 Write the integer *byte* into memory at the current
279 position of the file pointer; the file position is advanced by ``1``. If 282 position of the file pointer; the file position is advanced by ``1``. If
280 the mmap was created with :const:`ACCESS_READ`, then writing to it will 283 the mmap was created with :const:`ACCESS_READ`, then writing to it will
281 raise a :exc:`TypeError` exception. 284 raise a :exc:`TypeError` exception.
LEFTRIGHT

RSS Feeds Recent Issues | This issue
This is Rietveld 894c83f36cb7+