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
e59ec1b0
Kaydet (Commit)
e59ec1b0
authored
Nis 13, 2019
tarafından
Rémi Lapeyre
Kaydeden (comit)
Inada Naoki
Nis 13, 2019
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
bpo-35734: ipaddress: remove unused methods (GH-11591)
üst
c88feceb
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
1 addition
and
71 deletions
+1
-71
ipaddress.py
Lib/ipaddress.py
+0
-55
test_ipaddress.py
Lib/test/test_ipaddress.py
+1
-16
No files found.
Lib/ipaddress.py
Dosyayı görüntüle @
e59ec1b0
...
@@ -1077,9 +1077,6 @@ class _BaseV4:
...
@@ -1077,9 +1077,6 @@ class _BaseV4:
# Equivalent to 255.255.255.255 or 32 bits of 1's.
# Equivalent to 255.255.255.255 or 32 bits of 1's.
_ALL_ONES
=
(
2
**
IPV4LENGTH
)
-
1
_ALL_ONES
=
(
2
**
IPV4LENGTH
)
-
1
# the valid octets for host and netmasks. only useful for IPv4.
_valid_mask_octets
=
frozenset
({
255
,
254
,
252
,
248
,
240
,
224
,
192
,
128
,
0
})
_max_prefixlen
=
IPV4LENGTH
_max_prefixlen
=
IPV4LENGTH
# There are only a handful of valid v4 netmasks, so we cache them all
# There are only a handful of valid v4 netmasks, so we cache them all
# when constructed (see _make_netmask()).
# when constructed (see _make_netmask()).
...
@@ -1182,58 +1179,6 @@ class _BaseV4:
...
@@ -1182,58 +1179,6 @@ class _BaseV4:
"""
"""
return
'.'
.
join
(
map
(
str
,
ip_int
.
to_bytes
(
4
,
'big'
)))
return
'.'
.
join
(
map
(
str
,
ip_int
.
to_bytes
(
4
,
'big'
)))
def
_is_valid_netmask
(
self
,
netmask
):
"""Verify that the netmask is valid.
Args:
netmask: A string, either a prefix or dotted decimal
netmask.
Returns:
A boolean, True if the prefix represents a valid IPv4
netmask.
"""
mask
=
netmask
.
split
(
'.'
)
if
len
(
mask
)
==
4
:
try
:
for
x
in
mask
:
if
int
(
x
)
not
in
self
.
_valid_mask_octets
:
return
False
except
ValueError
:
# Found something that isn't an integer or isn't valid
return
False
for
idx
,
y
in
enumerate
(
mask
):
if
idx
>
0
and
y
>
mask
[
idx
-
1
]:
return
False
return
True
try
:
netmask
=
int
(
netmask
)
except
ValueError
:
return
False
return
0
<=
netmask
<=
self
.
_max_prefixlen
def
_is_hostmask
(
self
,
ip_str
):
"""Test if the IP string is a hostmask (rather than a netmask).
Args:
ip_str: A string, the potential hostmask.
Returns:
A boolean, True if the IP string is a hostmask.
"""
bits
=
ip_str
.
split
(
'.'
)
try
:
parts
=
[
x
for
x
in
map
(
int
,
bits
)
if
x
in
self
.
_valid_mask_octets
]
except
ValueError
:
return
False
if
len
(
parts
)
!=
len
(
bits
):
return
False
if
parts
[
0
]
<
parts
[
-
1
]:
return
True
return
False
def
_reverse_pointer
(
self
):
def
_reverse_pointer
(
self
):
"""Return the reverse DNS pointer name for the IPv4 address.
"""Return the reverse DNS pointer name for the IPv4 address.
...
...
Lib/test/test_ipaddress.py
Dosyayı görüntüle @
e59ec1b0
...
@@ -1040,27 +1040,12 @@ class IpaddrUnitTest(unittest.TestCase):
...
@@ -1040,27 +1040,12 @@ class IpaddrUnitTest(unittest.TestCase):
ipv4_zero_netmask
=
ipaddress
.
IPv4Interface
(
'1.2.3.4/0'
)
ipv4_zero_netmask
=
ipaddress
.
IPv4Interface
(
'1.2.3.4/0'
)
self
.
assertEqual
(
int
(
ipv4_zero_netmask
.
network
.
netmask
),
0
)
self
.
assertEqual
(
int
(
ipv4_zero_netmask
.
network
.
netmask
),
0
)
self
.
assertEqual
(
ipv4_zero_netmask
.
_prefix_from_prefix_string
(
'0'
),
0
)
self
.
assertEqual
(
ipv4_zero_netmask
.
_prefix_from_prefix_string
(
'0'
),
0
)
self
.
assertTrue
(
ipv4_zero_netmask
.
_is_valid_netmask
(
'0'
))
self
.
assertTrue
(
ipv4_zero_netmask
.
_is_valid_netmask
(
'0.0.0.0'
))
self
.
assertFalse
(
ipv4_zero_netmask
.
_is_valid_netmask
(
'invalid'
))
ipv6_zero_netmask
=
ipaddress
.
IPv6Interface
(
'::1/0'
)
ipv6_zero_netmask
=
ipaddress
.
IPv6Interface
(
'::1/0'
)
self
.
assertEqual
(
int
(
ipv6_zero_netmask
.
network
.
netmask
),
0
)
self
.
assertEqual
(
int
(
ipv6_zero_netmask
.
network
.
netmask
),
0
)
self
.
assertEqual
(
ipv6_zero_netmask
.
_prefix_from_prefix_string
(
'0'
),
0
)
self
.
assertEqual
(
ipv6_zero_netmask
.
_prefix_from_prefix_string
(
'0'
),
0
)
def
testIPv4NetAndHostmasks
(
self
):
def
testIPv4Net
(
self
):
net
=
self
.
ipv4_network
self
.
assertFalse
(
net
.
_is_valid_netmask
(
'invalid'
))
self
.
assertTrue
(
net
.
_is_valid_netmask
(
'128.128.128.128'
))
self
.
assertFalse
(
net
.
_is_valid_netmask
(
'128.128.128.127'
))
self
.
assertFalse
(
net
.
_is_valid_netmask
(
'128.128.128.255'
))
self
.
assertTrue
(
net
.
_is_valid_netmask
(
'255.128.128.128'
))
self
.
assertFalse
(
net
.
_is_hostmask
(
'invalid'
))
self
.
assertTrue
(
net
.
_is_hostmask
(
'128.255.255.255'
))
self
.
assertFalse
(
net
.
_is_hostmask
(
'255.255.255.255'
))
self
.
assertFalse
(
net
.
_is_hostmask
(
'1.2.3.4'
))
net
=
ipaddress
.
IPv4Network
(
'127.0.0.0/0.0.0.255'
)
net
=
ipaddress
.
IPv4Network
(
'127.0.0.0/0.0.0.255'
)
self
.
assertEqual
(
net
.
prefixlen
,
24
)
self
.
assertEqual
(
net
.
prefixlen
,
24
)
...
...
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