#14638: pydoc now treats non-str __name__ as None instead of raising

Original patch by Peter Otten.
This commit is contained in:
R David Murray 2012-04-23 13:23:57 -04:00
parent 88ec6209cf
commit c43125a05c
3 changed files with 16 additions and 1 deletions

View file

@ -282,6 +282,17 @@ class PydocDocTest(unittest.TestCase):
result, doc_loc = get_pydoc_text(xml.etree)
self.assertEqual(doc_loc, "", "MODULE DOCS incorrectly includes a link")
def test_non_str_name(self):
# issue14638
# Treat illegal (non-str) name like no name
class A:
__name__ = 42
class B:
pass
adoc = pydoc.render_doc(A())
bdoc = pydoc.render_doc(B())
self.assertEqual(adoc.replace("A", "B"), bdoc)
def test_not_here(self):
missing_module = "test.i_am_not_here"
result = str(run_pydoc(missing_module), 'ascii')