Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
C
cpython
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
Batuhan Osman TASKAYA
cpython
Commits
ba96f0f8
Kaydet (Commit)
ba96f0f8
authored
Şub 01, 2009
tarafından
Brett Cannon
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Ditch read_source() and read_bytecode() and replace with *_path() and
get_data().
üst
51c50268
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
8 additions
and
40 deletions
+8
-40
NOTES
Lib/importlib/NOTES
+0
-1
_bootstrap.py
Lib/importlib/_bootstrap.py
+8
-39
No files found.
Lib/importlib/NOTES
Dosyayı görüntüle @
ba96f0f8
...
...
@@ -3,7 +3,6 @@ to do
* API simplification?
+ Use *_path() along with get_data
+ write_bytecode -> complete set of bytes for bytecode instead of
individual arguments.
...
...
Lib/importlib/_bootstrap.py
Dosyayı görüntüle @
ba96f0f8
...
...
@@ -402,40 +402,6 @@ class _PyFileLoader(object):
# anything other than UTF-8.
return
open
(
source_path
,
encoding
=
encoding
)
.
read
()
@check_name
def
read_source
(
self
,
fullname
):
"""Return the source for the specified module as bytes along with the
path where the source came from.
The returned path is used by 'compile' for error messages.
"""
source_path
=
self
.
source_path
(
fullname
)
if
source_path
is
None
:
return
None
with
closing
(
_fileio
.
_FileIO
(
source_path
,
'r'
))
as
bytes_file
:
return
bytes_file
.
read
(),
source_path
@check_name
def
read_bytecode
(
self
,
name
):
"""Return the magic number, timestamp, and the module bytecode for the
module.
Raises ImportError (just like get_source) if the laoder cannot handle
the module. Returns None if there is no bytecode.
"""
path
=
self
.
bytecode_path
(
name
)
if
path
is
None
:
return
None
file
=
_fileio
.
_FileIO
(
path
,
'r'
)
try
:
with
closing
(
file
)
as
bytecode_file
:
data
=
bytecode_file
.
read
()
return
data
[:
4
],
marshal
.
_r_long
(
data
[
4
:
8
]),
data
[
8
:]
except
AttributeError
:
return
None
@check_name
def
write_bytecode
(
self
,
name
,
magic
,
timestamp
,
data
):
"""Write out 'data' for the specified module using the specific
...
...
@@ -462,7 +428,6 @@ class _PyFileLoader(object):
else
:
raise
# XXX Take an optional argument to flag whether to write bytecode?
@check_name
def
get_code
(
self
,
name
):
"""Return the code object for the module.
...
...
@@ -492,9 +457,12 @@ class _PyFileLoader(object):
# number is bad?
source_timestamp
=
self
.
source_mtime
(
name
)
# Try to use bytecode if it is available.
bytecode_tuple
=
self
.
read_bytecode
(
name
)
if
bytecode_tuple
:
magic
,
pyc_timestamp
,
bytecode
=
bytecode_tuple
bytecode_path
=
self
.
bytecode_path
(
name
)
if
bytecode_path
:
data
=
self
.
get_data
(
bytecode_path
)
magic
=
data
[:
4
]
pyc_timestamp
=
marshal
.
_r_long
(
data
[
4
:
8
])
bytecode
=
data
[
8
:]
try
:
# Verify that the magic number is valid.
if
imp
.
get_magic
()
!=
magic
:
...
...
@@ -519,7 +487,8 @@ class _PyFileLoader(object):
raise
ImportError
(
"no source or bytecode available to create code "
"object for {0!r}"
.
format
(
name
))
# Use the source.
source
,
source_path
=
self
.
read_source
(
name
)
source_path
=
self
.
source_path
(
name
)
source
=
self
.
get_data
(
source_path
)
# Convert to universal newlines.
line_endings
=
b
'
\n
'
for
index
,
c
in
enumerate
(
source
):
...
...
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