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
e5019d51
Kaydet (Commit)
e5019d51
authored
Eki 24, 2013
tarafından
Peter Moody
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
#17400: correct handling of 100.64.0.0/10, fixing the docs and updating NEWS
üst
a46079e8
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
27 additions
and
13 deletions
+27
-13
ipaddress.rst
Doc/library/ipaddress.rst
+6
-0
ipaddress.py
Lib/ipaddress.py
+15
-12
test_ipaddress.py
Lib/test/test_ipaddress.py
+3
-1
NEWS
Misc/NEWS
+3
-0
No files found.
Doc/library/ipaddress.rst
Dosyayı görüntüle @
e5019d51
...
...
@@ -158,6 +158,12 @@ write code that handles both IP versions correctly.
``True`` if the address is reserved for multicast use. See
:RFC:`3171` (for IPv4) or :RFC:`2373` (for IPv6).
.. attribute:: is_private
``True`` if the address is allocated for private networks. See
iana-ipv4-special-registry (for IPv4) or iana-ipv6-special-registry
(for IPv6).
.. attribute:: is_global
``True`` if the address is allocated for public networks. See
...
...
Lib/ipaddress.py
Dosyayı görüntüle @
e5019d51
...
...
@@ -1244,7 +1244,6 @@ class IPv4Address(_BaseV4, _BaseAddress):
"""
return
(
self
in
IPv4Network
(
'0.0.0.0/8'
)
or
self
in
IPv4Network
(
'10.0.0.0/8'
)
or
self
in
IPv4Network
(
'100.64.0.0/10'
)
or
self
in
IPv4Network
(
'127.0.0.0/8'
)
or
self
in
IPv4Network
(
'169.254.0.0/16'
)
or
self
in
IPv4Network
(
'172.16.0.0/12'
)
or
...
...
@@ -1258,17 +1257,6 @@ class IPv4Address(_BaseV4, _BaseAddress):
self
in
IPv4Network
(
'240.0.0.0/4'
)
or
self
in
IPv4Network
(
'255.255.255.255/32'
))
@property
def
is_global
(
self
):
"""Test if this address is allocated for public networks.
Returns:
A boolean, True if the address is not reserved per
iana-ipv4-special-registry.
"""
return
self
in
IPv4Network
(
'100.64.0.0/10'
)
or
not
self
.
is_private
@property
def
is_multicast
(
self
):
...
...
@@ -1501,6 +1489,21 @@ class IPv4Network(_BaseV4, _BaseNetwork):
if
self
.
_prefixlen
==
(
self
.
_max_prefixlen
-
1
):
self
.
hosts
=
self
.
__iter__
@property
@functools.lru_cache
()
def
is_global
(
self
):
"""Test if this address is allocated for public networks.
Returns:
A boolean, True if the address is not reserved per
iana-ipv4-special-registry.
"""
return
(
not
(
self
.
network_address
in
IPv4Network
(
'100.64.0.0/10'
)
and
self
.
broadcast_address
in
IPv4Network
(
'100.64.0.0/10'
))
and
not
self
.
is_private
)
class
_BaseV6
:
...
...
Lib/test/test_ipaddress.py
Dosyayı görüntüle @
e5019d51
...
...
@@ -1319,8 +1319,10 @@ class IpaddrUnitTest(unittest.TestCase):
self
.
assertEqual
(
True
,
ipaddress
.
ip_network
(
'127.42.0.0/16'
)
.
is_loopback
)
self
.
assertEqual
(
False
,
ipaddress
.
ip_network
(
'128.0.0.0'
)
.
is_loopback
)
self
.
assertEqual
(
True
,
ipaddress
.
ip_network
(
'100.64.0.0/10'
)
.
is_private
)
self
.
assertEqual
(
False
,
ipaddress
.
ip_network
(
'100.64.0.0/10'
)
.
is_private
)
self
.
assertEqual
(
False
,
ipaddress
.
ip_network
(
'100.64.0.0/10'
)
.
is_global
)
self
.
assertEqual
(
True
,
ipaddress
.
ip_network
(
'192.0.2.128/25'
)
.
is_private
)
self
.
assertEqual
(
True
,
...
...
Misc/NEWS
Dosyayı görüntüle @
e5019d51
...
...
@@ -19,6 +19,9 @@ Core and Builtins
Library
-------
- Issue #17400: New '
is_global
' attribute for ipaddress to tell if an address
is allocated by IANA for global or private networks.
- Issue #19350: Increasing the test coverage of macurl2path. Patch by Colin
Williams.
...
...
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