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
6fd8feee
Commit
6fd8feee
authored
Feb 01, 2009
by
Brett Cannon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Expose source_path and bytecode_path on _PyFileLoader.
parent
45fac793
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
13 additions
and
11 deletions
+13
-11
Lib/importlib/NOTES
Lib/importlib/NOTES
+1
-2
Lib/importlib/_bootstrap.py
Lib/importlib/_bootstrap.py
+12
-9
No files found.
Lib/importlib/NOTES
View file @
6fd8feee
...
...
@@ -3,8 +3,7 @@ to do
* API simplification?
+ read_source -> get_data/source_path
+ read_bytecode -> get_data/bytecode_path
+ Use *_path() along with get_data
+ write_bytecode -> complete set of bytes for bytecode instead of
individual arguments.
...
...
Lib/importlib/_bootstrap.py
View file @
6fd8feee
...
...
@@ -341,13 +341,15 @@ class _PyFileLoader(object):
else
:
return
None
def
_source_path
(
self
):
@
check_name
def
source_path
(
self
,
fullname
):
"""Return the path to an existing source file for the module, or None
if one cannot be found."""
# Not a property so that it is easy to override.
return
self
.
_find_path
(
imp
.
PY_SOURCE
)
def
_bytecode_path
(
self
):
@
check_name
def
bytecode_path
(
self
,
fullname
):
"""Return the path to a bytecode file, or None if one does not
exist."""
# Not a property for easy overriding.
...
...
@@ -357,8 +359,9 @@ class _PyFileLoader(object):
@
get_module
def
load_module
(
self
,
module
):
"""Load a Python source or bytecode module."""
source_path
=
self
.
_source_path
()
bytecode_path
=
self
.
_bytecode_path
()
name
=
module
.
__name__
source_path
=
self
.
source_path
(
name
)
bytecode_path
=
self
.
bytecode_path
(
name
)
code_object
=
self
.
get_code
(
module
.
__name__
)
module
.
__file__
=
source_path
if
source_path
else
bytecode_path
module
.
__loader__
=
self
...
...
@@ -376,7 +379,7 @@ class _PyFileLoader(object):
def
source_mtime
(
self
,
name
):
"""Return the modification time of the source for the specified
module."""
source_path
=
self
.
_source_path
(
)
source_path
=
self
.
source_path
(
name
)
if
not
source_path
:
return
None
return
int
(
_os
.
stat
(
source_path
).
st_mtime
)
...
...
@@ -389,7 +392,7 @@ class _PyFileLoader(object):
laoder cannot handle the specified module.
"""
source_path
=
self
.
_source_path
()
source_path
=
self
.
_source_path
(
name
)
if
source_path
is
None
:
return
None
import
tokenize
...
...
@@ -407,7 +410,7 @@ class _PyFileLoader(object):
The returned path is used by 'compile' for error messages.
"""
source_path
=
self
.
_source_path
(
)
source_path
=
self
.
source_path
(
fullname
)
if
source_path
is
None
:
return
None
with
closing
(
_fileio
.
_FileIO
(
source_path
,
'r'
))
as
bytes_file
:
...
...
@@ -422,7 +425,7 @@ class _PyFileLoader(object):
the module. Returns None if there is no bytecode.
"""
path
=
self
.
_bytecode_path
(
)
path
=
self
.
bytecode_path
(
name
)
if
path
is
None
:
return
None
file
=
_fileio
.
_FileIO
(
path
,
'r'
)
...
...
@@ -443,7 +446,7 @@ class _PyFileLoader(object):
cannot be handled by the loader.
"""
bytecode_path
=
self
.
_bytecode_path
(
)
bytecode_path
=
self
.
bytecode_path
(
name
)
if
not
bytecode_path
:
bytecode_path
=
self
.
_base_path
+
suffix_list
(
imp
.
PY_COMPILED
)[
0
]
file
=
_fileio
.
_FileIO
(
bytecode_path
,
'w'
)
...
...
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