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
9a9c28ce
Kaydet (Commit)
9a9c28ce
authored
Tem 07, 2012
tarafından
Nick Coghlan
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Issue 14814: Correctly return NotImplemented from ipaddress._BaseNetwork.__eq__
üst
d46f7d20
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
25 additions
and
7 deletions
+25
-7
ipaddress.py
Lib/ipaddress.py
+6
-6
test_ipaddress.py
Lib/test/test_ipaddress.py
+16
-1
NEWS
Misc/NEWS
+3
-0
No files found.
Lib/ipaddress.py
Dosyayı görüntüle @
9a9c28ce
...
...
@@ -651,12 +651,12 @@ class _BaseNetwork(_IPAddressBase):
return
not
lt
def
__eq__
(
self
,
other
):
if
not
isinstance
(
other
,
_BaseNetwork
)
:
r
aise
TypeError
(
'
%
s and
%
s are not of the same type'
%
(
self
,
other
))
return
(
self
.
_version
==
other
.
_version
and
self
.
network_address
==
other
.
network_address
and
int
(
self
.
netmask
)
==
int
(
other
.
netmask
))
try
:
r
eturn
(
self
.
_version
==
other
.
_version
and
self
.
network_address
==
other
.
network_address
and
int
(
self
.
netmask
)
==
int
(
other
.
netmask
))
except
AttributeError
:
return
NotImplemented
def
__ne__
(
self
,
other
):
eq
=
self
.
__eq__
(
other
)
...
...
Lib/test/test_ipaddress.py
Dosyayı görüntüle @
9a9c28ce
...
...
@@ -462,7 +462,6 @@ class IpaddrUnitTest(unittest.TestCase):
self
.
assertEqual
(
128
,
ipaddress
.
_count_righthand_zero_bits
(
0
,
128
))
self
.
assertEqual
(
"IPv4Network('1.2.3.0/24')"
,
repr
(
self
.
ipv4_network
))
self
.
assertEqual
(
'0x1020318'
,
hex
(
self
.
ipv4_network
))
self
.
assertRaises
(
TypeError
,
self
.
ipv4_network
.
__eq__
,
object
())
def
testMissingAddressVersion
(
self
):
class
Broken
(
ipaddress
.
_BaseAddress
):
...
...
@@ -496,6 +495,22 @@ class IpaddrUnitTest(unittest.TestCase):
self
.
assertEqual
(
str
(
self
.
ipv6_network
.
hostmask
),
'::ffff:ffff:ffff:ffff'
)
def
testEqualityChecks
(
self
):
# __eq__ should never raise TypeError directly
other
=
object
()
def
assertEqualityNotImplemented
(
instance
):
self
.
assertEqual
(
instance
.
__eq__
(
other
),
NotImplemented
)
self
.
assertEqual
(
instance
.
__ne__
(
other
),
NotImplemented
)
self
.
assertFalse
(
instance
==
other
)
self
.
assertTrue
(
instance
!=
other
)
assertEqualityNotImplemented
(
self
.
ipv4_address
)
assertEqualityNotImplemented
(
self
.
ipv4_network
)
assertEqualityNotImplemented
(
self
.
ipv4_interface
)
assertEqualityNotImplemented
(
self
.
ipv6_address
)
assertEqualityNotImplemented
(
self
.
ipv6_network
)
assertEqualityNotImplemented
(
self
.
ipv6_interface
)
def
testBadVersionComparison
(
self
):
# These should always raise TypeError
v4addr
=
ipaddress
.
ip_address
(
'1.1.1.1'
)
...
...
Misc/NEWS
Dosyayı görüntüle @
9a9c28ce
...
...
@@ -23,6 +23,9 @@ Core and Builtins
Library
-------
- Issue #14814: ipaddress network objects correctly return NotImplemented
when compared to arbitrary objects instead of raising TypeError
- Issue #14990: Correctly fail with SyntaxError on invalid encoding
declaration.
...
...
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