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
7e5d5570
Kaydet (Commit)
7e5d5570
authored
Tem 06, 2013
tarafından
Brett Cannon
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Sade Fark
merge for issue #18351.
üst
98054b4c
a53cca3f
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
44 additions
and
6 deletions
+44
-6
_bootstrap.py
Lib/importlib/_bootstrap.py
+4
-6
test_import.py
Lib/test/test_import.py
+36
-0
ACKS
Misc/ACKS
+1
-0
NEWS
Misc/NEWS
+3
-0
importlib.h
Python/importlib.h
+0
-0
No files found.
Lib/importlib/_bootstrap.py
Dosyayı görüntüle @
7e5d5570
...
...
@@ -443,16 +443,14 @@ def _get_sourcefile(bytecode_path):
"""
if
len
(
bytecode_path
)
==
0
:
return
None
rest
,
_
,
extension
=
bytecode_path
.
rparition
(
'.'
)
if
not
rest
or
extension
.
lower
()[
-
3
:
-
1
]
!=
'
.
py'
:
rest
,
_
,
extension
=
bytecode_path
.
rpar
t
ition
(
'.'
)
if
not
rest
or
extension
.
lower
()[
-
3
:
-
1
]
!=
'py'
:
return
bytecode_path
try
:
source_path
=
source_from_cache
(
bytecode_path
)
except
(
NotImplementedError
,
ValueError
):
source_path
=
bytcode_path
[
-
1
:]
return
source_path
if
_path_isfile
(
source_stats
)
else
bytecode_path
source_path
=
bytecode_path
[:
-
1
]
return
source_path
if
_path_isfile
(
source_path
)
else
bytecode_path
def
_calc_mode
(
path
):
...
...
Lib/test/test_import.py
Dosyayı görüntüle @
7e5d5570
# We import importlib *ASAP* in order to test #15386
import
importlib
import
importlib.util
from
importlib._bootstrap
import
_get_sourcefile
import
builtins
from
test.test_importlib.import_
import
util
as
importlib_util
import
marshal
...
...
@@ -11,6 +12,7 @@ import random
import
stat
import
sys
import
unittest
import
unittest.mock
as
mock
import
textwrap
import
errno
import
shutil
...
...
@@ -851,6 +853,40 @@ class ImportlibBootstrapTests(unittest.TestCase):
self
.
assertIs
(
machinery
.
FileFinder
,
mod
.
FileFinder
)
@cpython_only
class
GetSourcefileTests
(
unittest
.
TestCase
):
"""Test importlib._bootstrap._get_sourcefile() as used by the C API.
Because of the peculiarities of the need of this function, the tests are
knowingly whitebox tests.
"""
def
test_get_sourcefile
(
self
):
# Given a valid bytecode path, return the path to the corresponding
# source file if it exists.
with
mock
.
patch
(
'importlib._bootstrap._path_isfile'
)
as
_path_isfile
:
_path_isfile
.
return_value
=
True
;
path
=
TESTFN
+
'.pyc'
expect
=
TESTFN
+
'.py'
self
.
assertEqual
(
_get_sourcefile
(
path
),
expect
)
def
test_get_sourcefile_no_source
(
self
):
# Given a valid bytecode path without a corresponding source path,
# return the original bytecode path.
with
mock
.
patch
(
'importlib._bootstrap._path_isfile'
)
as
_path_isfile
:
_path_isfile
.
return_value
=
False
;
path
=
TESTFN
+
'.pyc'
self
.
assertEqual
(
_get_sourcefile
(
path
),
path
)
def
test_get_sourcefile_bad_ext
(
self
):
# Given a path with an invalid bytecode extension, return the
# bytecode path passed as the argument.
path
=
TESTFN
+
'.bad_ext'
self
.
assertEqual
(
_get_sourcefile
(
path
),
path
)
class
ImportTracebackTests
(
unittest
.
TestCase
):
def
setUp
(
self
):
...
...
Misc/ACKS
Dosyayı görüntüle @
7e5d5570
...
...
@@ -808,6 +808,7 @@ Laura Matson
Graham Matthews
Dieter Maurer
Daniel May
Madison May
Lucas Maystre
Arnaud Mazin
Rebecca McCreary
...
...
Misc/NEWS
Dosyayı görüntüle @
7e5d5570
...
...
@@ -542,6 +542,9 @@ Documentation
C-API
-----
- Issue #18351: Fix various issues in a function in importlib provided to help
PyImport_ExecCodeModuleWithPathnames() (and thus by extension PyImport_ExecCodeModule() and PyImport_ExecCodeModuleEx()).
- Issue #9369: The types of `char*` arguments of PyObject_CallFunction() and
PyObject_CallMethod() now changed to `const char*`. Based on patches by
Jörg Müller and Lars Buitinck.
...
...
Python/importlib.h
Dosyayı görüntüle @
7e5d5570
This source diff could not be displayed because it is too large. You can
view the blob
instead.
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