[issue11634] misleading comment on PyBytes_FromStringAndSize
New submission from Eli Bendersky <eliben@gmail.com>: The comment string above the implementation of _PyBytes_FromStringAndSize in Objects/bytesobject.c starts with: /* For both PyBytes_FromString() and PyBytes_FromStringAndSize(), the parameter `size' denotes number of characters to allocate, not counting any null terminating character. This is misleading since PyBytes_FromString() has no 'size' parameter. The problem also exists for PyString in Python 2.x ---------- assignee: docs@python components: Documentation keywords: easy messages: 131750 nosy: docs@python, eli.bendersky priority: low severity: normal status: open title: misleading comment on PyBytes_FromStringAndSize versions: Python 3.2, Python 3.3 _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue11634> _______________________________________
STINNER Victor <victor.stinner@haypocalc.com> added the comment: Could you write a patch to fix this comment? ---------- nosy: +haypo _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue11634> _______________________________________
Eli Bendersky <eliben@gmail.com> added the comment: Sure, I just wanted confirmation from another dev that it's indeed an error and I'm not missing anything. I suppose the fix is just replace "for both PyBytes_FromString() and PyBytes_FromStringAndSize()" with just "for PyBytes_FromStringAndSize()". I'll commit the change to all relevant branches. ---------- _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue11634> _______________________________________
STINNER Victor <victor.stinner@haypocalc.com> added the comment: PyObject * PyBytes_FromString(const char *str) { register size_t size; ... size = strlen(str); ... } PyBytes_FromString() does compute the input string size using strlen(). ---------- _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue11634> _______________________________________
Eli Bendersky <eliben@gmail.com> added the comment: Yes it does, but the comment says something about "parameter 'size'" which is clearly absent from the function signature of PyBytes_FromString. ---------- _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue11634> _______________________________________
Eli Bendersky <eliben@gmail.com> added the comment: I propose the attached patch (for the latest default branch). It simply removes the first paragraph of that comment, since it's misleading and redundant. The *last* paragraph explains the same thing just in a clear and correct way (except that it also has a small typo the patch fixes :-) ---------- _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue11634> _______________________________________
Changes by Eli Bendersky <eliben@gmail.com>: ---------- keywords: +patch Added file: http://bugs.python.org/file21354/issue11634.1.patch _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue11634> _______________________________________
Roundup Robot <devnull@devnull> added the comment: New changeset a729dfdbd24b by Eli Bendersky in branch 'default': Issue #11634: Remove misleading paragraph from a comment http://hg.python.org/cpython/rev/a729dfdbd24b ---------- nosy: +python-dev _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue11634> _______________________________________
Roundup Robot <devnull@devnull> added the comment: New changeset 44749e501982 by Eli Bendersky in branch '2.7': Issue #11634: Remove misleading paragraph from a comment http://hg.python.org/cpython/rev/44749e501982 ---------- _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue11634> _______________________________________
Eli Bendersky <eliben@gmail.com> added the comment: Patch reviewed by Nick Coghlan and committed ---------- resolution: -> fixed status: open -> closed versions: +Python 2.7 -Python 3.2 _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue11634> _______________________________________
participants (3)
-
Eli Bendersky
-
Roundup Robot
-
STINNER Victor