Movatterモバイル変換


[0]ホーム

URL:


homepage

Issue33126

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:Some C buffer protocol APIs not documented
Type:behaviorStage:resolved
Components:DocumentationVersions:Python 3.8, Python 3.7, Python 3.6
process
Status:closedResolution:fixed
Dependencies:Superseder:
Assigned To: docs@pythonNosy List: docs@python, pitrou, skrah
Priority:normalKeywords:patch

Created on2018-03-23 16:49 bypitrou, last changed2022-04-11 14:58 byadmin. This issue is nowclosed.

Files
File nameUploadedDescriptionEdit
issue33126.diffskrah,2018-03-24 21:53
Pull Requests
URLStatusLinkedEdit
PR 6292mergedpitrou,2018-03-28 15:04
PR 6293mergedmiss-islington,2018-03-28 15:27
PR 6294mergedmiss-islington,2018-03-28 15:29
Messages (9)
msg314315 -(view)Author: Antoine Pitrou (pitrou)*(Python committer)Date: 2018-03-23 16:49
The following C functions are available for C code but not documented:- PyBuffer_ToContiguous()- PyBuffer_FromContiguous()- PyObject_CopyData()I am not sure how to describe those functions myself.
msg314387 -(view)Author: Stefan Krah (skrah)*(Python committer)Date: 2018-03-24 21:53
I fixed PyBuffer_ToContiguous() in 3.3, PyBuffer_FromContiguous() was broken until#23370.For a start, here's a doc patch for PyBuffer_ToContiguous().PyBuffer_FromContiguous() does the opposite and loads a contiguous bufferinto a possibly non-contiguous view.PyObject_CopyData() copies the data from exporter src to the writable exporter dest.I have never used the last two functions.
msg314388 -(view)Author: Antoine Pitrou (pitrou)*(Python committer)Date: 2018-03-24 22:37
Thanks.  The PyBuffer_ToContiguous() API is weird: why pass `len` if it cannot be anything other than `src->len`?Also, it would be nice to explain whether the actual buffer data is copied around (with a memory allocation?) or if it's just the Py_buffer struct.
msg314424 -(view)Author: Stefan Krah (skrah)*(Python committer)Date: 2018-03-25 18:18
Yes, the signatures are weird. In PyBuffer_FromContiguous(), "len" isthe size of "buf" in bytes.If "buf" contains 6 floats, but "view" only has space for 4, then only4 are copied into "view".To avoid that sort of thing, I changed PyBuffer_ToContiguous() tobe more restrictive in 3.3, but kept the len parameter.In PyBuffer_ToContiguous() it would not matter though if len(buf) > src->len, in which case buf would contain uninitialized bytes atthe end.TBH, I don't think these functions are used very often. :-)
msg314425 -(view)Author: Stefan Krah (skrah)*(Python committer)Date: 2018-03-25 18:32
And if view->len > len in PyBuffer_FromContiguous(), thenview will contain uninitialized bytes, which is bad.
msg314605 -(view)Author: Antoine Pitrou (pitrou)*(Python committer)Date: 2018-03-28 15:04
Ok, it seems only PyBuffer_ToContiguous() is worth documenting.
msg314608 -(view)Author: Antoine Pitrou (pitrou)*(Python committer)Date: 2018-03-28 15:26
New changesetaa50bf08e64f49d57917ab0b1aadf4308a3168a6 by Antoine Pitrou in branch 'master':bpo-33126: Document PyBuffer_ToContiguous() (#6292)https://github.com/python/cpython/commit/aa50bf08e64f49d57917ab0b1aadf4308a3168a6
msg314611 -(view)Author: Antoine Pitrou (pitrou)*(Python committer)Date: 2018-03-28 15:47
New changeset18fdc87207ea65b3906f07cb47c51a609e442f93 by Antoine Pitrou (Miss Islington (bot)) in branch '3.6':bpo-33126: Document PyBuffer_ToContiguous() (GH-6292) (GH-6293)https://github.com/python/cpython/commit/18fdc87207ea65b3906f07cb47c51a609e442f93
msg314612 -(view)Author: Antoine Pitrou (pitrou)*(Python committer)Date: 2018-03-28 15:50
New changeset6124d8ec0d1eb8016e5e54a4d341b8f4f995623c by Antoine Pitrou (Miss Islington (bot)) in branch '3.7':bpo-33126: Document PyBuffer_ToContiguous() (GH-6292) (GH-6294)https://github.com/python/cpython/commit/6124d8ec0d1eb8016e5e54a4d341b8f4f995623c
History
DateUserActionArgs
2022-04-11 14:58:58adminsetgithub: 77307
2018-03-28 15:50:58pitrousetstatus: open -> closed
resolution: fixed
stage: patch review -> resolved
2018-03-28 15:50:27pitrousetmessages: +msg314612
2018-03-28 15:47:36pitrousetmessages: +msg314611
2018-03-28 15:29:01miss-islingtonsetpull_requests: +pull_request6018
2018-03-28 15:27:55miss-islingtonsetpull_requests: +pull_request6017
2018-03-28 15:26:37pitrousetmessages: +msg314608
2018-03-28 15:04:53pitrousetmessages: +msg314605
2018-03-28 15:04:27pitrousetstage: needs patch -> patch review
pull_requests: +pull_request6016
2018-03-25 18:32:25skrahsetmessages: +msg314425
2018-03-25 18:18:51skrahsetmessages: +msg314424
2018-03-24 22:37:54pitrousetmessages: +msg314388
2018-03-24 21:53:19skrahsetfiles: +issue33126.diff
keywords: +patch
messages: +msg314387
2018-03-23 16:49:06pitroucreate
Supported byThe Python Software Foundation,
Powered byRoundup
Copyright © 1990-2022,Python Software Foundation
Legal Statements

[8]ページ先頭

©2009-2026 Movatter.jp