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
ce8ff413
Commit
ce8ff413
authored
Jun 11, 2013
by
Brett Cannon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Issue #18157: stop using imp.load_module() in imp.
parent
b8f06cc1
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
14 additions
and
12 deletions
+14
-12
Lib/pydoc.py
Lib/pydoc.py
+12
-12
Misc/NEWS
Misc/NEWS
+2
-0
No files found.
Lib/pydoc.py
View file @
ce8ff413
...
...
@@ -53,6 +53,7 @@ Richard Chamberlain, for the first implementation of textdoc.
import
builtins
import
imp
import
importlib._bootstrap
import
importlib.machinery
import
inspect
import
io
...
...
@@ -269,18 +270,17 @@ def importfile(path):
"""Import a Python source file or compiled file given its path."""
magic
=
imp
.
get_magic
()
with
open
(
path
,
'rb'
)
as
file
:
if
file
.
read
(
len
(
magic
))
==
magic
:
kind
=
imp
.
PY_COMPILED
else
:
kind
=
imp
.
PY_SOURCE
file
.
seek
(
0
)
filename
=
os
.
path
.
basename
(
path
)
name
,
ext
=
os
.
path
.
splitext
(
filename
)
try
:
module
=
imp
.
load_module
(
name
,
file
,
path
,
(
ext
,
'r'
,
kind
))
except
:
raise
ErrorDuringImport
(
path
,
sys
.
exc_info
())
return
module
is_bytecode
=
magic
==
file
.
read
(
len
(
magic
))
filename
=
os
.
path
.
basename
(
path
)
name
,
ext
=
os
.
path
.
splitext
(
filename
)
if
is_bytecode
:
loader
=
importlib
.
_bootstrap
.
SourcelessFileLoader
(
name
,
path
)
else
:
loader
=
importlib
.
_bootstrap
.
SourceFileLoader
(
name
,
path
)
try
:
return
loader
.
load_module
(
name
)
except
:
raise
ErrorDuringImport
(
path
,
sys
.
exc_info
())
def
safeimport
(
path
,
forceload
=
0
,
cache
=
{}):
"""Import a module; handle errors; return None if the module isn't found.
...
...
Misc/NEWS
View file @
ce8ff413
...
...
@@ -120,6 +120,8 @@ Core and Builtins
Library
-------
-
Issue
#
18157
:
Stop
using
imp
.
load_module
()
in
pydoc
.
-
Issue
#
16102
:
Make
uuid
.
_netbios_getnode
()
work
again
on
Python
3.
-
Issue
#
17134
:
Add
ssl
.
enum_cert_store
()
as
interface
to
Windows
' cert store.
...
...
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