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
df960682
Commit
df960682
authored
Jun 15, 2013
by
Brett Cannon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Issue #17177: Stop using imp with py_compile
parent
fc06443c
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
6 additions
and
5 deletions
+6
-5
Lib/py_compile.py
Lib/py_compile.py
+4
-3
Lib/test/test_py_compile.py
Lib/test/test_py_compile.py
+2
-2
No files found.
Lib/py_compile.py
View file @
df960682
...
...
@@ -3,9 +3,9 @@
This module has intimate knowledge of the format of .pyc files.
"""
import
imp
import
importlib._bootstrap
import
importlib.machinery
import
importlib.util
import
os
import
os.path
import
sys
...
...
@@ -105,9 +105,10 @@ def compile(file, cfile=None, dfile=None, doraise=False, optimize=-1):
"""
if
cfile
is
None
:
if
optimize
>=
0
:
cfile
=
imp
.
cache_from_source
(
file
,
debug_override
=
not
optimize
)
cfile
=
importlib
.
util
.
cache_from_source
(
file
,
debug_override
=
not
optimize
)
else
:
cfile
=
imp
.
cache_from_source
(
file
)
cfile
=
imp
ortlib
.
util
.
cache_from_source
(
file
)
if
os
.
path
.
islink
(
cfile
):
msg
=
(
'{} is a symlink and will be changed into a regular file if '
'import writes a byte-compiled file to it'
)
...
...
Lib/test/test_py_compile.py
View file @
df960682
import
imp
import
imp
ortlib.util
import
os
import
py_compile
import
shutil
...
...
@@ -14,7 +14,7 @@ class PyCompileTests(unittest.TestCase):
self
.
directory
=
tempfile
.
mkdtemp
()
self
.
source_path
=
os
.
path
.
join
(
self
.
directory
,
'_test.py'
)
self
.
pyc_path
=
self
.
source_path
+
'c'
self
.
cache_path
=
imp
.
cache_from_source
(
self
.
source_path
)
self
.
cache_path
=
imp
ortlib
.
util
.
cache_from_source
(
self
.
source_path
)
self
.
cwd_drive
=
os
.
path
.
splitdrive
(
os
.
getcwd
())[
0
]
# In these tests we compute relative paths. When using Windows, the
# current working directory path and the 'self.source_path' might be
...
...
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