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
d749c7ae
Kaydet (Commit)
d749c7ae
authored
Ock 04, 2014
tarafından
Eric Snow
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Issue #19927: Add __eq__ to path-based loaders in importlib.
üst
78194cd4
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
39 additions
and
2 deletions
+39
-2
_bootstrap.py
Lib/importlib/_bootstrap.py
+14
-0
test_loader.py
Lib/test/test_importlib/extension/test_loader.py
+9
-0
test_file_loader.py
Lib/test/test_importlib/source/test_file_loader.py
+13
-0
test_api.py
Lib/test/test_importlib/test_api.py
+1
-2
NEWS
Misc/NEWS
+2
-0
importlib.h
Python/importlib.h
+0
-0
No files found.
Lib/importlib/_bootstrap.py
Dosyayı görüntüle @
d749c7ae
...
...
@@ -1559,6 +1559,13 @@ class FileLoader:
self
.
name
=
fullname
self
.
path
=
path
def
__eq__
(
self
,
other
):
return
(
self
.
__class__
==
other
.
__class__
and
self
.
__dict__
==
other
.
__dict__
)
def
__hash__
(
self
):
return
hash
(
self
.
name
)
^
hash
(
self
.
path
)
@_check_name
def
load_module
(
self
,
fullname
):
"""Load a module from a file."""
...
...
@@ -1653,6 +1660,13 @@ class ExtensionFileLoader:
self
.
name
=
name
self
.
path
=
path
def
__eq__
(
self
,
other
):
return
(
self
.
__class__
==
other
.
__class__
and
self
.
__dict__
==
other
.
__dict__
)
def
__hash__
(
self
):
return
hash
(
self
.
name
)
^
hash
(
self
.
path
)
@_check_name
def
load_module
(
self
,
fullname
):
"""Load an extension module."""
...
...
Lib/test/test_importlib/extension/test_loader.py
Dosyayı görüntüle @
d749c7ae
...
...
@@ -28,6 +28,15 @@ class LoaderTests(abc.LoaderTests):
with
self
.
assertRaises
(
ImportError
):
self
.
load_module
(
'XXX'
)
def
test_equality
(
self
):
other
=
self
.
machinery
.
ExtensionFileLoader
(
ext_util
.
NAME
,
ext_util
.
FILEPATH
)
self
.
assertEqual
(
self
.
loader
,
other
)
def
test_inequality
(
self
):
other
=
self
.
machinery
.
ExtensionFileLoader
(
'_'
+
ext_util
.
NAME
,
ext_util
.
FILEPATH
)
self
.
assertNotEqual
(
self
.
loader
,
other
)
def
test_module
(
self
):
with
util
.
uncache
(
ext_util
.
NAME
):
...
...
Lib/test/test_importlib/source/test_file_loader.py
Dosyayı görüntüle @
d749c7ae
...
...
@@ -27,6 +27,11 @@ class SimpleTest(abc.LoaderTests):
"""
def
setUp
(
self
):
self
.
name
=
'spam'
self
.
filepath
=
os
.
path
.
join
(
'ham'
,
self
.
name
+
'.py'
)
self
.
loader
=
self
.
machinery
.
SourceFileLoader
(
self
.
name
,
self
.
filepath
)
def
test_load_module_API
(
self
):
class
Tester
(
self
.
abc
.
FileLoader
):
def
get_source
(
self
,
_
):
return
'attr = 42'
...
...
@@ -53,6 +58,14 @@ class SimpleTest(abc.LoaderTests):
with
self
.
assertRaises
(
ImportError
):
loader
.
get_filename
(
name
+
'XXX'
)
def
test_equality
(
self
):
other
=
self
.
machinery
.
SourceFileLoader
(
self
.
name
,
self
.
filepath
)
self
.
assertEqual
(
self
.
loader
,
other
)
def
test_inequality
(
self
):
other
=
self
.
machinery
.
SourceFileLoader
(
'_'
+
self
.
name
,
self
.
filepath
)
self
.
assertNotEqual
(
self
.
loader
,
other
)
# [basic]
def
test_module
(
self
):
with
source_util
.
create_modules
(
'_temp'
)
as
mapping
:
...
...
Lib/test/test_importlib/test_api.py
Dosyayı görüntüle @
d749c7ae
...
...
@@ -288,8 +288,7 @@ class FindSpecTests:
self
.
assertNotIn
(
name
,
sorted
(
sys
.
modules
))
# Ensure successive calls behave the same.
spec_again
=
self
.
init
.
find_spec
(
fullname
,
[
pkg_dir
])
# XXX Once #19927 is resolved, uncomment this line.
#self.assertEqual(spec_again, spec)
self
.
assertEqual
(
spec_again
,
spec
)
def
test_find_submodule_missing_path
(
self
):
name
=
'spam'
...
...
Misc/NEWS
Dosyayı görüntüle @
d749c7ae
...
...
@@ -203,6 +203,8 @@ Library
no exception detail exists (no colon following the exception'
s
name
,
or
a
colon
does
follow
but
no
text
follows
the
colon
).
-
Issue
#
19927
:
Add
__eq__
to
path
-
based
loaders
in
importlib
.
-
Issue
#
19827
:
On
UNIX
,
setblocking
()
and
settimeout
()
methods
of
socket
.
socket
can
now
avoid
a
second
syscall
if
the
ioctl
()
function
can
be
used
,
or
if
the
non
-
blocking
flag
of
the
socket
is
unchanged
.
...
...
Python/importlib.h
Dosyayı görüntüle @
d749c7ae
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