Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
c43125a0
Commit
c43125a0
authored
Apr 23, 2012
by
R David Murray
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
#14638: pydoc now treats non-str __name__ as None instead of raising
Original patch by Peter Otten.
parent
88ec6209
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
16 additions
and
1 deletion
+16
-1
Lib/pydoc.py
Lib/pydoc.py
+2
-1
Lib/test/test_pydoc.py
Lib/test/test_pydoc.py
+11
-0
Misc/NEWS
Misc/NEWS
+3
-0
No files found.
Lib/pydoc.py
View file @
c43125a0
...
...
@@ -1525,7 +1525,8 @@ def resolve(thing, forceload=0):
raise
ImportError
(
'no Python documentation found for %r'
%
thing
)
return
object
,
thing
else
:
return
thing
,
getattr
(
thing
,
'__name__'
,
None
)
name
=
getattr
(
thing
,
'__name__'
,
None
)
return
thing
,
name
if
isinstance
(
name
,
str
)
else
None
def
render_doc
(
thing
,
title
=
'Python Library Documentation: %s'
,
forceload
=
0
,
renderer
=
None
):
...
...
Lib/test/test_pydoc.py
View file @
c43125a0
...
...
@@ -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'
)
...
...
Misc/NEWS
View file @
c43125a0
...
...
@@ -50,6 +50,9 @@ Core and Builtins
Library
-------
- Issue #14638: pydoc now treats non-string __name__ values as if they
were missing, instead of raising an error.
- Issue #13684: Fix httplib tunnel issue of infinite loops for certain sites
which send EOF without trailing \r\n.
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment