[issue15888] ipaddress HOWTO examples have some errors

New submission from Chris Jerdonek: The ipaddress HOWTO seems to have some errors in its interactive doctest examples. Below are the errors after running the doctests for it using the regrtest patch posted to issue 15629. (This is the first doc file for which I have used the modified script to open an issue.) The errors seem valid to me on casual inspection. Note that you need to add an initial ">>> import ipaddress" at the beginning of the first doctest example to have these actually run. ---------------------------------------------------------------------- File "Doc/howto/ipaddress.rst", line 146, in ipaddress.rst Failed example: ipaddress.ip_network('2001:db8::1/96') Exception raised: Traceback (most recent call last): File "Lib/doctest.py", line 1287, in __run compileflags, 1), test.globs) File "<doctest ipaddress.rst[15]>", line 1, in <module> ipaddress.ip_network('2001:db8::1/96') File "Lib/ipaddress.py", line 79, in ip_network return IPv6Network(address, strict) File "Lib/ipaddress.py", line 2056, in __init__ raise ValueError('%s has host bits set' % self) ValueError: 2001:db8::1/96 has host bits set ---------------------------------------------------------------------- File "Doc/howto/ipaddress.rst", line 181, in ipaddress.rst Failed example: net4.numhosts Exception raised: Traceback (most recent call last): File "Lib/doctest.py", line 1287, in __run compileflags, 1), test.globs) File "<doctest ipaddress.rst[25]>", line 1, in <module> net4.numhosts AttributeError: 'IPv4Network' object has no attribute 'numhosts' ---------------------------------------------------------------------- File "Doc/howto/ipaddress.rst", line 184, in ipaddress.rst Failed example: net6.numhosts Exception raised: Traceback (most recent call last): File "Lib/doctest.py", line 1287, in __run compileflags, 1), test.globs) File "<doctest ipaddress.rst[27]>", line 1, in <module> net6.numhosts AttributeError: 'IPv6Network' object has no attribute 'numhosts' ---------------------------------------------------------------------- File "Doc/howto/ipaddress.rst", line 190, in ipaddress.rst Failed example: for x in net4.hosts(): Exception raised: Traceback (most recent call last): File "Lib/doctest.py", line 1287, in __run compileflags, 1), test.globs) File "<doctest ipaddress.rst[29]>", line 1 for x in net4.hosts(): ^ SyntaxError: unexpected EOF while parsing ---------------------------------------------------------------------- File "Doc/howto/ipaddress.rst", line 219, in ipaddress.rst Failed example: addr6.exploded Expected: '2001:0db8:0000:0000:0000:0000:0000:0000' Got: '2001:0db8:0000:0000:0000:0000:0000:0001' ---------------------------------------------------------------------- File "Doc/howto/ipaddress.rst", line 221, in ipaddress.rst Failed example: addr6.compressed Expected: '2001:db8::' Got: '2001:db8::1' ---------------------------------------------------------------------- File "Doc/howto/ipaddress.rst", line 244, in ipaddress.rst Failed example: net6[1] Expected: IPv6Address('2001::1') Got: IPv6Address('2001:db8::1') ---------------------------------------------------------------------- File "Doc/howto/ipaddress.rst", line 246, in ipaddress.rst Failed example: net6[-1] Expected: IPv6Address('2001::ffff:ffff') Got: IPv6Address('2001:db8::ffff:ffff') ---------- assignee: docs@python components: Documentation keywords: easy messages: 170097 nosy: cjerdonek, docs@python, ncoghlan, pmoody priority: normal severity: normal stage: needs patch status: open title: ipaddress HOWTO examples have some errors type: behavior versions: Python 3.3 _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue15888> _______________________________________

Chris Jerdonek added the comment: While we are here, the corresponding Python file also has a couple errors in one of its doctest examples. File "Lib/ipaddress.py", line 209, in ipaddress.summarize_address_range Failed example: summarize_address_range(IPv4Address('192.0.2.0'), Exception raised: Traceback (most recent call last): File "Lib/doctest.py", line 1287, in __run compileflags, 1), test.globs) File "<doctest ipaddress.summarize_address_range[0]>", line 1 summarize_address_range(IPv4Address('192.0.2.0'), ^ SyntaxError: unexpected EOF while parsing ---------- _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue15888> _______________________________________

Chris Jerdonek added the comment: And also the main doc file Lib/ipaddress.rst (along with some formatting issues, and after adding needed imports): File "Doc/library/ipaddress.rst", line 115, in ipaddress.rst Failed example: ipaddress.IPv4Address(3221225985) Expected: IPv4Address('192.168.0.1') Got: IPv4Address('192.0.2.1') ---------- title: ipaddress HOWTO examples have some errors -> ipaddress doctest examples have some errors _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue15888> _______________________________________

Chris Jerdonek added the comment: I will prepare a patch for these three files. ---------- _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue15888> _______________________________________

Chris Jerdonek added the comment: Attaching patch. The doctests for these three files now all pass (using a newer version of the patch I uploaded to issue 15629). ---------- keywords: +patch Added file: http://bugs.python.org/file27161/issue-15888-1.patch _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue15888> _______________________________________

Chris Jerdonek added the comment: Adding Eli to this because he did some work on the HOWTO for this module in issue 14814. ---------- nosy: +eli.bendersky _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue15888> _______________________________________

Changes by Ezio Melotti <ezio.melotti@gmail.com>: ---------- nosy: +ezio.melotti stage: needs patch -> patch review _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue15888> _______________________________________

Chris Jerdonek added the comment: Attaching an updated patch that does not render the import statements in the final HTML, so that it renders the same as before. ---------- Added file: http://bugs.python.org/file27227/issue-15888-2.patch _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue15888> _______________________________________

Changes by Chris Jerdonek <chris.jerdonek@gmail.com>: ---------- assignee: docs@python -> chris.jerdonek _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue15888> _______________________________________

Eli Bendersky added the comment: Thanks, Chris. I'll take a look ---------- _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue15888> _______________________________________

Roundup Robot added the comment: New changeset 81ad910d75a9 by Eli Bendersky in branch '3.3': Issue #15888: fixing problems in ipaddress doctests. Patch by Chris Jerdonek http://hg.python.org/cpython/rev/81ad910d75a9 ---------- nosy: +python-dev _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue15888> _______________________________________

Eli Bendersky added the comment: Pushed to 3.3 and 3.4 Thanks for the report and patch ---------- resolution: -> fixed stage: patch review -> committed/rejected status: open -> closed _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue15888> _______________________________________

Chris Jerdonek added the comment: While we are here, the corresponding Python file also has a couple errors in one of its doctest examples. File "Lib/ipaddress.py", line 209, in ipaddress.summarize_address_range Failed example: summarize_address_range(IPv4Address('192.0.2.0'), Exception raised: Traceback (most recent call last): File "Lib/doctest.py", line 1287, in __run compileflags, 1), test.globs) File "<doctest ipaddress.summarize_address_range[0]>", line 1 summarize_address_range(IPv4Address('192.0.2.0'), ^ SyntaxError: unexpected EOF while parsing ---------- _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue15888> _______________________________________

Chris Jerdonek added the comment: And also the main doc file Lib/ipaddress.rst (along with some formatting issues, and after adding needed imports): File "Doc/library/ipaddress.rst", line 115, in ipaddress.rst Failed example: ipaddress.IPv4Address(3221225985) Expected: IPv4Address('192.168.0.1') Got: IPv4Address('192.0.2.1') ---------- title: ipaddress HOWTO examples have some errors -> ipaddress doctest examples have some errors _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue15888> _______________________________________

Chris Jerdonek added the comment: I will prepare a patch for these three files. ---------- _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue15888> _______________________________________

Chris Jerdonek added the comment: Attaching patch. The doctests for these three files now all pass (using a newer version of the patch I uploaded to issue 15629). ---------- keywords: +patch Added file: http://bugs.python.org/file27161/issue-15888-1.patch _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue15888> _______________________________________

Chris Jerdonek added the comment: Adding Eli to this because he did some work on the HOWTO for this module in issue 14814. ---------- nosy: +eli.bendersky _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue15888> _______________________________________

Changes by Ezio Melotti <ezio.melotti@gmail.com>: ---------- nosy: +ezio.melotti stage: needs patch -> patch review _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue15888> _______________________________________

Chris Jerdonek added the comment: Attaching an updated patch that does not render the import statements in the final HTML, so that it renders the same as before. ---------- Added file: http://bugs.python.org/file27227/issue-15888-2.patch _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue15888> _______________________________________

Changes by Chris Jerdonek <chris.jerdonek@gmail.com>: ---------- assignee: docs@python -> chris.jerdonek _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue15888> _______________________________________

Eli Bendersky added the comment: Thanks, Chris. I'll take a look ---------- _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue15888> _______________________________________

Roundup Robot added the comment: New changeset 81ad910d75a9 by Eli Bendersky in branch '3.3': Issue #15888: fixing problems in ipaddress doctests. Patch by Chris Jerdonek http://hg.python.org/cpython/rev/81ad910d75a9 ---------- nosy: +python-dev _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue15888> _______________________________________

Eli Bendersky added the comment: Pushed to 3.3 and 3.4 Thanks for the report and patch ---------- resolution: -> fixed stage: patch review -> committed/rejected status: open -> closed _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue15888> _______________________________________
participants (4)
-
Chris Jerdonek
-
Eli Bendersky
-
Ezio Melotti
-
Roundup Robot