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
e64e51bf
Commit
e64e51bf
authored
Jul 29, 2011
by
Éric Araujo
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make “pydoc somebuiltin.somemethod” work (#8887)
parent
158d7696
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
28 additions
and
6 deletions
+28
-6
Lib/pydoc.py
Lib/pydoc.py
+7
-6
Lib/test/test_pydoc.py
Lib/test/test_pydoc.py
+18
-0
Misc/NEWS
Misc/NEWS
+3
-0
No files found.
Lib/pydoc.py
View file @
e64e51bf
...
@@ -1482,13 +1482,14 @@ def locate(path, forceload=0):
...
@@ -1482,13 +1482,14 @@ def locate(path, forceload=0):
else
:
break
else
:
break
if
module
:
if
module
:
object
=
module
object
=
module
for
part
in
parts
[
n
:]:
try
:
object
=
getattr
(
object
,
part
)
except
AttributeError
:
return
None
return
object
else
:
else
:
if
hasattr
(
builtins
,
path
):
object
=
builtins
return
getattr
(
builtins
,
path
)
for
part
in
parts
[
n
:]:
try
:
object
=
getattr
(
object
,
part
)
except
AttributeError
:
return
None
return
object
# --------------------------------------- interactive interpreter interface
# --------------------------------------- interactive interpreter interface
...
...
Lib/test/test_pydoc.py
View file @
e64e51bf
import
os
import
os
import
sys
import
sys
import
builtins
import
difflib
import
difflib
import
inspect
import
inspect
import
pydoc
import
pydoc
...
@@ -419,6 +420,23 @@ class TestDescriptions(unittest.TestCase):
...
@@ -419,6 +420,23 @@ class TestDescriptions(unittest.TestCase):
expected
=
'C in module %s object'
%
__name__
expected
=
'C in module %s object'
%
__name__
self
.
assertIn
(
expected
,
pydoc
.
render_doc
(
c
))
self
.
assertIn
(
expected
,
pydoc
.
render_doc
(
c
))
def
test_builtin
(
self
):
for
name
in
(
'str'
,
'str.translate'
,
'builtins.str'
,
'builtins.str.translate'
):
# test low-level function
self
.
assertIsNotNone
(
pydoc
.
locate
(
name
))
# test high-level function
try
:
pydoc
.
render_doc
(
name
)
except
ImportError
:
self
.
fail
(
'finding the doc of {!r} failed'
.
format
(
o
))
for
name
in
(
'notbuiltins'
,
'strrr'
,
'strr.translate'
,
'str.trrrranslate'
,
'builtins.strrr'
,
'builtins.str.trrranslate'
):
self
.
assertIsNone
(
pydoc
.
locate
(
name
))
self
.
assertRaises
(
ImportError
,
pydoc
.
render_doc
,
name
)
@
unittest
.
skipUnless
(
threading
,
'Threading required for this test.'
)
@
unittest
.
skipUnless
(
threading
,
'Threading required for this test.'
)
class
PydocServerTest
(
unittest
.
TestCase
):
class
PydocServerTest
(
unittest
.
TestCase
):
...
...
Misc/NEWS
View file @
e64e51bf
...
@@ -41,6 +41,9 @@ Core and Builtins
...
@@ -41,6 +41,9 @@ Core and Builtins
Library
Library
-------
-------
- Issue #8887: "pydoc somebuiltin.somemethod" (or help('somebuiltin.somemethod')
in Python code) now finds the doc of the method.
- Issue #12603: Fix pydoc.synopsis() on files with non-negative st_mtime.
- Issue #12603: Fix pydoc.synopsis() on files with non-negative st_mtime.
- Issue #12514: Use try/finally to assure the timeit module restores garbage
- Issue #12514: Use try/finally to assure the timeit module restores garbage
...
...
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