From b6076fb13c6bf97f4fae76da478a26e0f4f24879 Mon Sep 17 00:00:00 2001 From: Serhiy Storchaka Date: Tue, 21 Apr 2015 21:09:48 +0300 Subject: [PATCH] Issue #23008: Fixed resolving attributes with boolean value is False in pydoc. --- Lib/pydoc.py | 2 +- Lib/test/test_pydoc.py | 8 ++++++++ Misc/NEWS | 2 ++ 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/Lib/pydoc.py b/Lib/pydoc.py index faaa8595356..0c7b60d98dd 100755 --- a/Lib/pydoc.py +++ b/Lib/pydoc.py @@ -1590,7 +1590,7 @@ def resolve(thing, forceload=0): """Given an object or a path to an object, get the object and its name.""" if isinstance(thing, str): object = locate(thing, forceload) - if not object: + if object is None: raise ImportError('no Python documentation found for %r' % thing) return object, thing else: diff --git a/Lib/test/test_pydoc.py b/Lib/test/test_pydoc.py index 83f2ec94881..0e990b62beb 100644 --- a/Lib/test/test_pydoc.py +++ b/Lib/test/test_pydoc.py @@ -1029,6 +1029,14 @@ class C(metaclass=M): print_diffs(expected_text, result) self.fail("outputs are not equal, see diff above") + def test_resolve_false(self): + # Issue #23008: pydoc enum.{,Int}Enum failed + # because bool(enum.Enum) is False. + with captured_stdout() as help_io: + pydoc.help('enum.Enum') + helptext = help_io.getvalue() + self.assertIn('class Enum', helptext) + @reap_threads def test_main(): diff --git a/Misc/NEWS b/Misc/NEWS index 183f7d19ca6..fb2ced1c57a 100644 --- a/Misc/NEWS +++ b/Misc/NEWS @@ -31,6 +31,8 @@ Core and Builtins Library ------- +- Issue #23008: Fixed resolving attributes with boolean value is False in pydoc. + - Fix asyncio issue 235: LifoQueue and PriorityQueue's put didn't increment unfinished tasks (this bug was introduced in 3.4.3 when JoinableQueue was merged with Queue).