This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: ipaddress.IPv4Address.is_global not implemented
Type: behavior Stage: resolved
Components: Library (Lib) Versions: Python 3.6, Python 3.5
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: berker.peksag, eric.smith, ncoghlan, pmoody, python-dev, r.david.murray, rluethi, santoso.wijaya
Priority: normal Keywords: patch

Created on 2014-04-29 11:35 by rluethi, last changed 2022-04-11 14:58 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
ipv4addr_global.diff rluethi, 2014-04-29 11:35
ipv4addr_global2-hg.diff rluethi, 2014-05-18 14:36
issue21386_v3.diff berker.peksag, 2016-06-10 22:07 review
Messages (8)
msg217511 - (view) Author: Roger Luethi (rluethi) * Date: 2014-04-29 11:35
Lib/ipaddress.py does not implement is_global for IPv4Address, in contrast to the documentation which states for IPv4Address.is_global: "True if the address is allocated for public networks."

A patch like the one attached to this report should fix that.
msg218701 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2014-05-17 13:26
The patch looks correct to me, but we also need tests.
msg218744 - (view) Author: Roger Luethi (rluethi) * Date: 2014-05-18 14:36
New patch includes tests.

Lightly tested with Python 3.4 (because trunk doesn't build for me right now): tests fail without patch, pass with patch.

Patch re-diffed against trunk.
msg219017 - (view) Author: Berker Peksag (berker.peksag) * (Python committer) Date: 2014-05-24 01:14
+    @property
+    def is_global(self):
+        return (not self in IPv4Network('100.64.0.0/10') and

Can IPv4Network('100.64.0.0/10') moved to the _IPv4Constants class (e.g. _IPv4Constants._global_network = IPv4Network('100.64.0.0/10')) after http://hg.python.org/cpython/rev/e5d963cb6afc (see also issue 21513)

+                not self.is_private)
msg219861 - (view) Author: Roger Luethi (rluethi) * Date: 2014-06-06 06:26
Seeing that the patch merged for issue 21513 left the existing test for 100.64.0.0 (IPv4 network) untouched, I think it would make more sense to make that address a constant everywhere in a separate patch (if that is indeed desirable).
msg268162 - (view) Author: Berker Peksag (berker.peksag) * (Python committer) Date: 2016-06-10 22:07
Here is an updated patch that uses my proposal in msg219017. Since this is already documented at https://docs.python.org/3.5/library/ipaddress.html#ipaddress.IPv4Address.is_global I think it should also go into 3.5.
msg268252 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2016-06-11 19:12
New changeset d65191861599 by Berker Peksag in branch '3.5':
Issue #21386: Implement missing IPv4Address.is_global property
https://hg.python.org/cpython/rev/d65191861599

New changeset 1519ca772e54 by Berker Peksag in branch 'default':
Issue #21386: Merge from 3.5
https://hg.python.org/cpython/rev/1519ca772e54
msg268253 - (view) Author: Berker Peksag (berker.peksag) * (Python committer) Date: 2016-06-11 19:13
Thanks Roger!
History
Date User Action Args
2022-04-11 14:58:02adminsetgithub: 65585
2016-06-11 19:13:06berker.peksagsetstatus: open -> closed
type: enhancement -> behavior
messages: + msg268253

resolution: fixed
stage: patch review -> resolved
2016-06-11 19:12:31python-devsetnosy: + python-dev
messages: + msg268252
2016-06-10 22:07:32berker.peksagsetfiles: + issue21386_v3.diff

messages: + msg268162
versions: + Python 3.6
2014-06-06 06:26:12rluethisetmessages: + msg219861
2014-05-24 01:14:34berker.peksagsetversions: - Python 3.4
nosy: + berker.peksag

messages: + msg219017

stage: patch review
2014-05-19 22:38:22santoso.wijayasetnosy: + santoso.wijaya
type: enhancement
2014-05-18 14:36:10rluethisetfiles: + ipv4addr_global2-hg.diff

messages: + msg218744
2014-05-17 13:26:21r.david.murraysetnosy: + r.david.murray
messages: + msg218701
2014-04-29 12:24:41eric.smithsetnosy: + ncoghlan, eric.smith, pmoody
2014-04-29 11:35:35rluethicreate