Movatterモバイル変換


[0]ホーム

URL:


homepage

Issue26335

This issue trackerhas been migrated toGitHub, and is currentlyread-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title:Make mmap.write return the number of bytes written like other write methods
Type:enhancementStage:resolved
Components:Extension ModulesVersions:Python 3.6
process
Status:closedResolution:fixed
Dependencies:Superseder:
Assigned To:Nosy List: berker.peksag, jstasiak, martin.panter, python-dev, twouters
Priority:normalKeywords:patch

Created on2016-02-10 22:55 byjstasiak, last changed2022-04-11 14:58 byadmin. This issue is nowclosed.

Files
File nameUploadedDescriptionEdit
mmap_write_return_count.patchjstasiak,2016-02-10 22:55review
mmap_write_return_count2.patchjstasiak,2016-02-23 23:39review
mmap_write_return_count3.patchjstasiak,2016-02-25 10:05
Messages (8)
msg260053 -(view)Author: Jakub Stasiak (jstasiak)*Date: 2016-02-10 22:55
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.writehttps://docs.python.org/3/library/io.html#io.BufferedWriter.writehttps://docs.python.org/3/library/io.html#io.RawIOBase.writehttps://docs.python.org/3/library/io.html#io.TextIOBase.writeWhy 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).
msg260706 -(view)Author: Berker Peksag (berker.peksag)*(Python committer)Date: 2016-02-23 00:02
Thanks for the patch, Jakub. I don't use mmap module much so I don't have an opinion about the feature, but it sounds reasonable.I left some review comments on Rietveld:http://bugs.python.org/review/26335/
msg260750 -(view)Author: Jakub Stasiak (jstasiak)*Date: 2016-02-23 23:39
Oops, sorry for the silliness in the C code, thanks for reviewing. I modified as suggested, please find the new patch attached.
msg260759 -(view)Author: Martin Panter (martin.panter)*(Python committer)Date: 2016-02-24 02:28
Patch looks okay to me. I guess it would be good to write a What’s New entry as well.
msg260847 -(view)Author: Jakub Stasiak (jstasiak)*Date: 2016-02-25 10:05
Thank you. I didn't know whether to add an entry toDoc/whatsnew/3.6.rst,Misc/NEWS or both so I chose both, feel free to modify/remove as needed.The new patch also doesn't have a typo in the versionchanged directive present in the version 2. I noticed more typos like this (single colon instead of double colon), I'll create a separate issue.
msg261128 -(view)Author: Roundup Robot (python-dev)(Python triager)Date: 2016-03-02 17:29
New changesetba71aecec943 by Berker Peksag in branch 'default':Issue#26335: Make mmap.write() return the number of bytes written likehttps://hg.python.org/cpython/rev/ba71aecec943
msg261129 -(view)Author: Berker Peksag (berker.peksag)*(Python committer)Date: 2016-03-02 17:31
Thanks for the patch, Jakub!
msg261143 -(view)Author: Jakub Stasiak (jstasiak)*Date: 2016-03-03 00:02
Glad I could help, thanks for merging!
History
DateUserActionArgs
2022-04-11 14:58:27adminsetgithub: 70523
2016-03-03 00:02:26jstasiaksetmessages: +msg261143
2016-03-02 17:31:09berker.peksagsetstatus: open -> closed
resolution: fixed
messages: +msg261129

stage: patch review -> resolved
2016-03-02 17:29:56python-devsetnosy: +python-dev
messages: +msg261128
2016-02-25 10:05:33jstasiaksetfiles: +mmap_write_return_count3.patch

messages: +msg260847
2016-02-24 02:28:37martin.pantersetnosy: +martin.panter
messages: +msg260759
2016-02-23 23:39:34jstasiaksetfiles: +mmap_write_return_count2.patch

messages: +msg260750
2016-02-23 00:02:13berker.peksagsetnosy: +berker.peksag
messages: +msg260706

components: + Extension Modules, - Library (Lib), IO
stage: patch review
2016-02-12 23:23:45terry.reedysetnosy: +twouters
2016-02-10 22:55:37jstasiakcreate
Supported byThe Python Software Foundation,
Powered byRoundup
Copyright © 1990-2022,Python Software Foundation
Legal Statements

[8]ページ先頭

©2009-2026 Movatter.jp