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
bf341fb5
Kaydet (Commit)
bf341fb5
authored
May 21, 2015
tarafından
Yury Selivanov
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Issue 23898: Fix inspect.classify_class_attrs() to work with __eq__
üst
0978b5cd
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
21 additions
and
3 deletions
+21
-3
inspect.py
Lib/inspect.py
+3
-3
test_inspect.py
Lib/test/test_inspect.py
+15
-0
NEWS
Misc/NEWS
+3
-0
No files found.
Lib/inspect.py
Dosyayı görüntüle @
bf341fb5
...
...
@@ -380,7 +380,7 @@ def classify_class_attrs(cls):
# first look in the classes
for
srch_cls
in
class_bases
:
srch_obj
=
getattr
(
srch_cls
,
name
,
None
)
if
srch_obj
==
get_obj
:
if
srch_obj
is
get_obj
:
last_cls
=
srch_cls
# then check the metaclasses
for
srch_cls
in
metamro
:
...
...
@@ -388,7 +388,7 @@ def classify_class_attrs(cls):
srch_obj
=
srch_cls
.
__getattr__
(
cls
,
name
)
except
AttributeError
:
continue
if
srch_obj
==
get_obj
:
if
srch_obj
is
get_obj
:
last_cls
=
srch_cls
if
last_cls
is
not
None
:
homecls
=
last_cls
...
...
@@ -402,7 +402,7 @@ def classify_class_attrs(cls):
# unable to locate the attribute anywhere, most likely due to
# buggy custom __dir__; discard and move on
continue
obj
=
get_obj
or
dict_obj
obj
=
get_obj
if
get_obj
is
not
None
else
dict_obj
# Classify the object or its descriptor.
if
isinstance
(
dict_obj
,
staticmethod
):
kind
=
"static method"
...
...
Lib/test/test_inspect.py
Dosyayı görüntüle @
bf341fb5
...
...
@@ -782,6 +782,21 @@ class TestClassesAndFunctions(unittest.TestCase):
should_find_ga
=
inspect
.
Attribute
(
'ham'
,
'data'
,
Meta
,
'spam'
)
self
.
assertIn
(
should_find_ga
,
inspect
.
classify_class_attrs
(
VA
))
def
test_classify_overrides_bool
(
self
):
class
NoBool
(
object
):
def
__eq__
(
self
,
other
):
return
NoBool
()
def
__bool__
(
self
):
raise
NotImplementedError
(
"This object does not specify a boolean value"
)
class
HasNB
(
object
):
dd
=
NoBool
()
should_find_attr
=
inspect
.
Attribute
(
'dd'
,
'data'
,
HasNB
,
HasNB
.
dd
)
self
.
assertIn
(
should_find_attr
,
inspect
.
classify_class_attrs
(
HasNB
))
def
test_classify_metaclass_class_attribute
(
self
):
class
Meta
(
type
):
fish
=
'slap'
...
...
Misc/NEWS
Dosyayı görüntüle @
bf341fb5
...
...
@@ -260,6 +260,9 @@ Library
- asyncio: async() function is deprecated in favour of ensure_future().
- Issue 23898: Fix inspect.classify_class_attrs() to support attributes
with overloaded __eq__ and __bool__. Patch by Mike Bayer.
Tests
-----
...
...
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