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
3a62d14b
Commit
3a62d14b
authored
Jan 06, 2014
by
Eric Snow
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Issue #19703: Update pydoc to use the new importer APIs.
parent
3192eac6
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
17 additions
and
4 deletions
+17
-4
Lib/pydoc.py
Lib/pydoc.py
+13
-4
Lib/test/test_pydoc.py
Lib/test/test_pydoc.py
+2
-0
Misc/NEWS
Misc/NEWS
+2
-0
No files found.
Lib/pydoc.py
View file @
3a62d14b
...
...
@@ -246,8 +246,12 @@ def synopsis(filename, cache={}):
else
:
# Must be a binary module, which has to be imported.
loader
=
loader_cls
(
'__temp__'
,
filename
)
# XXX We probably don't need to pass in the loader here.
spec
=
importlib
.
util
.
spec_from_file_location
(
'__temp__'
,
filename
,
loader
=
loader
)
_spec
=
importlib
.
_bootstrap
.
_SpecMethods
(
spec
)
try
:
module
=
loader
.
load_module
(
'__temp__'
)
module
=
_spec
.
load
(
)
except
:
return
None
del
sys
.
modules
[
'__temp__'
]
...
...
@@ -277,8 +281,11 @@ def importfile(path):
loader
=
importlib
.
_bootstrap
.
SourcelessFileLoader
(
name
,
path
)
else
:
loader
=
importlib
.
_bootstrap
.
SourceFileLoader
(
name
,
path
)
# XXX We probably don't need to pass in the loader here.
spec
=
importlib
.
util
.
spec_from_file_location
(
name
,
path
,
loader
=
loader
)
_spec
=
importlib
.
_bootstrap
.
_SpecMethods
(
spec
)
try
:
return
loader
.
load_module
(
name
)
return
_spec
.
load
(
)
except
:
raise
ErrorDuringImport
(
path
,
sys
.
exc_info
())
...
...
@@ -2008,10 +2015,11 @@ class ModuleScanner:
callback
(
None
,
modname
,
''
)
else
:
try
:
loader
=
importer
.
find_module
(
modname
)
spec
=
pkgutil
.
_get_spec
(
importer
,
modname
)
except
SyntaxError
:
# raised by tests for bad coding cookies or BOM
continue
loader
=
spec
.
loader
if
hasattr
(
loader
,
'get_source'
):
try
:
source
=
loader
.
get_source
(
modname
)
...
...
@@ -2025,8 +2033,9 @@ class ModuleScanner:
else
:
path
=
None
else
:
_spec
=
importlib
.
_bootstrap
.
_SpecMethods
(
spec
)
try
:
module
=
loader
.
load_module
(
modname
)
module
=
_spec
.
load
(
)
except
ImportError
:
if
onerror
:
onerror
(
modname
)
...
...
Lib/test/test_pydoc.py
View file @
3a62d14b
...
...
@@ -649,8 +649,10 @@ class PydocImportTest(PydocBaseTest):
def
test_importfile
(
self
):
loaded_pydoc
=
pydoc
.
importfile
(
pydoc
.
__file__
)
self
.
assertIsNot
(
loaded_pydoc
,
pydoc
)
self
.
assertEqual
(
loaded_pydoc
.
__name__
,
'pydoc'
)
self
.
assertEqual
(
loaded_pydoc
.
__file__
,
pydoc
.
__file__
)
self
.
assertEqual
(
loaded_pydoc
.
__spec__
,
pydoc
.
__spec__
)
class
TestDescriptions
(
unittest
.
TestCase
):
...
...
Misc/NEWS
View file @
3a62d14b
...
...
@@ -287,6 +287,8 @@ Library
-
Issue
#
19708
:
Update
pkgutil
to
use
the
new
importer
APIs
.
-
Issue
#
19703
:
Update
pydoc
to
use
the
new
importer
APIs
.
-
Issue
#
19851
:
Fixed
a
regression
in
reloading
sub
-
modules
.
-
ssl
.
create_default_context
()
sets
OP_NO_COMPRESSION
to
prevent
CRIME
.
...
...
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