[issue26401] Error in documentation for "compile" built-in function
New submission from Raúl Núñez de Arenas: According to the documentation, if the 'compile' built-in function encounters NUL bytes in the compiled source, it raises TypeError, but this is not true:
source = '\u0000' compile(source, '', 'single') Traceback (most recent call last): File "<stdin>", line 1, in <module> ValueError: source code string cannot contain null bytes
It raises ValueError, not TypeError. And IMHO, it's the proper exception to raise... ---------- assignee: docs@python components: Documentation messages: 260613 nosy: Raúl Núñez de Arenas, docs@python priority: normal severity: normal status: open title: Error in documentation for "compile" built-in function type: enhancement versions: Python 3.5 _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue26401> _______________________________________
SilentGhost added the comment: Here is the patch. ---------- keywords: +patch nosy: +SilentGhost versions: +Python 3.6 Added file: http://bugs.python.org/file41985/issue26401.diff _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue26401> _______________________________________
Berker Peksag added the comment: It would be good to add a versionchanged note. Something like: .. versionchanged:: 3.5 Previously, a :exc:`TypeError` was raised [...] ---------- nosy: +berker.peksag stage: -> patch review _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue26401> _______________________________________
Raúl Núñez de Arenas added the comment: I checked the sources at github and the change was introduced back in 2010, if I recall correctly, so maybe this change happened in 3.2? I can check again and try to determine the exact date and if at all possible the version. ---------- _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue26401> _______________________________________
SilentGhost added the comment: TypeError is raised in 3.4 ---------- _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue26401> _______________________________________
Raúl Núñez de Arenas added the comment: I checked the Mercurial repository directly, and the change was introduced in 2014: http://bugs.python.org/issue22215 So, yes, looks like a 3.5 change and the versionchanged note suggested by Berker is a great idea! ---------- _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue26401> _______________________________________
SilentGhost added the comment: Updated patch. ---------- Added file: http://bugs.python.org/file41989/issue26401_2.diff _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue26401> _______________________________________
Roundup Robot added the comment: New changeset 0cfac9efd895 by Berker Peksag in branch '3.5': Issue #26401: Fix compile() documentation https://hg.python.org/cpython/rev/0cfac9efd895 New changeset 45cf82f424ce by Berker Peksag in branch 'default': Issue #26401: Fix compile() documentation https://hg.python.org/cpython/rev/45cf82f424ce ---------- nosy: +python-dev _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue26401> _______________________________________
Berker Peksag added the comment: Thanks! ---------- resolution: -> fixed stage: patch review -> resolved status: open -> closed _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue26401> _______________________________________
Raúl Núñez de Arenas added the comment: Thanks to you, Berker, and SilentGhost, for applying and preparing the patch! ---------- _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue26401> _______________________________________
participants (4)
-
Berker Peksag
-
Raúl Núñez de Arenas
-
Roundup Robot
-
SilentGhost