aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHaibo Huang <hhb@google.com>2019-10-21 16:03:07 -0700
committerandroid-build-merger <android-build-merger@google.com>2019-10-21 16:03:07 -0700
commitecd2315d45ff33094935cc7bda76f8d3b0f08914 (patch)
treee9fb14bd73b8f85c9c77b77ad76e7870a356acf0
parent2458372292f3098ed1a8665077692de16a63ba5d (diff)
parent6a1ca2ef8394aa5607160443433368722eb8d2c9 (diff)
downloadipaddress-ecd2315d45ff33094935cc7bda76f8d3b0f08914.tar.gz
Upgrade python/ipaddress to v1.0.23
am: 6a1ca2ef83 Change-Id: I3146c483b3b75dcf8e82991b44ca063d8e2ffca9
-rw-r--r--.dockerignore3
-rw-r--r--.travis.yml7
-rw-r--r--METADATA12
-rw-r--r--Makefile22
-rw-r--r--OTHER_BACKPORTS.md10
-rw-r--r--README.md4
-rw-r--r--ipaddress.py5
-rw-r--r--setup.py2
-rw-r--r--test-python2.6.Dockerfile8
-rw-r--r--test-python2.7.Dockerfile11
-rw-r--r--test-python3.2.Dockerfile8
-rw-r--r--test-python3.3.Dockerfile8
-rw-r--r--test_ipaddress.py17
13 files changed, 93 insertions, 24 deletions
diff --git a/.dockerignore b/.dockerignore
new file mode 100644
index 0000000..c778784
--- /dev/null
+++ b/.dockerignore
@@ -0,0 +1,3 @@
+build
+dist
+ipaddress.egg-info
diff --git a/.travis.yml b/.travis.yml
index ddc269c..72393f7 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -1,3 +1,4 @@
+dist: "trusty"
language: python
python:
- "2.6"
@@ -7,11 +8,11 @@ python:
- "pypy"
- "pypy3"
install:
- - "pip install flake8"
+ - "if python --version 2>&1 | grep -q ' 2\.7\.'; then pip install flake8 ; fi"
script:
- "make test"
- - "make lint"
+ - "make lint-if-2.7"
notifications:
email:
- phihag@phihag.de
-sudo: false \ No newline at end of file
+sudo: false
diff --git a/METADATA b/METADATA
index b1bd95f..9377dc3 100644
--- a/METADATA
+++ b/METADATA
@@ -1,7 +1,5 @@
name: "ipaddress"
-description:
- "Port of the 3.3+ ipaddress module to 2.6, 2.7, 3.2"
-
+description: "Port of the 3.3+ ipaddress module to 2.6, 2.7, 3.2"
third_party {
url {
type: HOMEPAGE
@@ -11,7 +9,11 @@ third_party {
type: GIT
value: "https://github.com/phihag/ipaddress"
}
- version: "v1.0.22"
- last_upgrade_date { year: 2019 month: 5 day: 2 }
+ version: "v1.0.23"
license_type: NOTICE
+ last_upgrade_date {
+ year: 2019
+ month: 10
+ day: 17
+ }
}
diff --git a/Makefile b/Makefile
index e799f11..604fd05 100644
--- a/Makefile
+++ b/Makefile
@@ -4,7 +4,10 @@ test:
python test_ipaddress.py
lint:
- @(python --version 2>&1 | grep -q ' 2\.6\.') || flake8 ipaddress.py test_ipaddress.py
+ flake8 *.py
+
+lint-if-2.7:
+ @if python --version 2>&1 | grep -q ' 2\.7\.'; then $(MAKE) lint ; fi
pypi:
python setup.py sdist bdist_wheel upload
@@ -17,11 +20,26 @@ release:
git add ipaddress.py setup.py
git commit -m "release ${VERSION}"
git tag "v${VERSION}"
+ git push
git push --tags
$(MAKE) pypi
+docker-test-all: docker-test-2.6 docker-test-2.7 docker-test-3.2 docker-test-3.3
+
+docker-test-2.6:
+ docker build -t ipaddress-python2.6 . -f test-python2.6.Dockerfile
+
+docker-test-2.7:
+ docker build -t ipaddress-python2.7 . -f test-python2.7.Dockerfile
+
+docker-test-3.2:
+ docker build -t ipaddress-python3.2 . -f test-python3.2.Dockerfile
+
+docker-test-3.3:
+ docker build -t ipaddress-python3.3 . -f test-python3.3.Dockerfile
+
clean:
rm -rf -- build dist ipaddress.egg-info
-.PHONY: default test clean pypi lint
+.PHONY: default test clean pypi lint docker-test-all docker-test-2.6 docker-test-2.7 docker-test-3.2 docker-test-3.3 lint-if-2.7
diff --git a/OTHER_BACKPORTS.md b/OTHER_BACKPORTS.md
index 67f57ac..c9a8f9b 100644
--- a/OTHER_BACKPORTS.md
+++ b/OTHER_BACKPORTS.md
@@ -1,16 +1,16 @@
There are three backports of ipaddress in the wild:
-phihag/ipaddress ([ipaddress on PyPi](https://pypi.python.org/pypi/ipaddress)):
+phihag/ipaddress ([ipaddress on PyPI](https://pypi.org/project/ipaddress/)):
> First commit: 2013-02-03<br>
> First release: 2013-02-04<br>
-> Latest commit: 2017-01-11
+> Latest commit: 2018-06-10 (as of June 2018)
-kwi/py2-ipaddress ([py2-ipaddress on PyPi](https://pypi.python.org/pypi/py2-ipaddress))
+kwi/py2-ipaddress ([py2-ipaddress on PyPI](https://pypi.org/project/py2-ipaddress/))
> First commit: 2013-08-08<br>
> First release: 2013-08-08<br>
> Latest commit: 2015-07-14
-sk-/backport_ipaddress ([backport_ipaddress on PyPi](https://pypi.python.org/pypi/backport_ipaddress))
+sk-/backport_ipaddress ([backport_ipaddress on PyPI](https://pypi.org/project/backport_ipaddress/))
> First commit: 2014-08-15<br>
> First release: 2014-09-01<br>
> Latest commit: 2014-08-16 (!)
@@ -19,7 +19,7 @@ In addition, judging by http://pypi-ranking.info/search/ipaddress/ , this backpo
sk-/backport_ipaddress is a fork of kwi/py2-ipaddress. As you can see from the above dates, the project has basically never been updated after being released. So I'm just going to focus on my ipaddress vs py2-ipaddress. Mine has nearly 40x the download count.
-As you can also see from the above stats, py2-ipaddress has not been updated for over a year. Sure, it's a backport and thus does not necessitate frequent updating, but for instance cPython has fixed a couple of bugs just recently, and they are certainly still present in py2-ipaddress. In contrast, I can and do regularly sync. Upstream cPython code is in the upstream branch and just gets merged, so you can sync if you need the bleeding-edge ipaddress code (but a pull request or issue would be fine too if that's what you need).
+As you can also see from the above stats, py2-ipaddress has not been updated for over two years. Sure, it's a backport and thus does not necessitate frequent updating, but for instance cPython has fixed a couple of bugs just recently, and they are certainly still present in py2-ipaddress. In contrast, I can and do regularly sync. Upstream cPython code is in the upstream branch and just gets merged, so you can sync if you need the bleeding-edge ipaddress code (but a pull request or issue would be fine too if that's what you need).
But I don't think it's even necessary to argument from metadata, when the technical facts speak for themselves:
diff --git a/README.md b/README.md
index 77471c6..0a12bc0 100644
--- a/README.md
+++ b/README.md
@@ -3,7 +3,9 @@ ipaddress
Python 3.3+'s [ipaddress](http://docs.python.org/dev/library/ipaddress) for Python 2.6, 2.7, 3.2.
-Note that as in Python 3.3+ you must use character strings and not byte strings for textual IP address representations:
+This repository tracks the latest version from cpython, e.g. ipaddress from cpython 3.8 as of writing.
+
+Note that just like in Python 3.3+ you must use character strings and not byte strings for textual IP address representations:
```python
>>> from __future__ import unicode_literals
diff --git a/ipaddress.py b/ipaddress.py
index f2d0766..3e6f9e4 100644
--- a/ipaddress.py
+++ b/ipaddress.py
@@ -14,7 +14,7 @@ from __future__ import unicode_literals
import itertools
import struct
-__version__ = '1.0.22'
+__version__ = '1.0.23'
# Compatibility functions
_compat_int_types = (int,)
@@ -1103,7 +1103,8 @@ class _BaseNetwork(_IPAddressBase):
try:
# Always false if one is v4 and the other is v6.
if a._version != b._version:
- raise TypeError("%s and %s are not of the same version" (a, b))
+ raise TypeError(
+ "%s and %s are not of the same version" % (a, b))
return (b.network_address <= a.network_address and
b.broadcast_address >= a.broadcast_address)
except AttributeError:
diff --git a/setup.py b/setup.py
index eba10de..7e99280 100644
--- a/setup.py
+++ b/setup.py
@@ -8,7 +8,7 @@ except ImportError:
settings = {
'name': 'ipaddress',
- 'version': '1.0.22',
+ 'version': '1.0.23',
'description': 'IPv4/IPv6 manipulation library',
'long_description': 'Port of the 3.3+ ipaddress module to 2.6, 2.7, 3.2',
'author': 'Philipp Hagemeister',
diff --git a/test-python2.6.Dockerfile b/test-python2.6.Dockerfile
new file mode 100644
index 0000000..5e16329
--- /dev/null
+++ b/test-python2.6.Dockerfile
@@ -0,0 +1,8 @@
+FROM lovato/python-2.6.6
+# Dockerfile to run tests under python2.6
+
+# docker build -t ipaddress-python2.6 . -f test-python2.6.Dockerfile
+
+ADD . .
+RUN python test_ipaddress.py
+CMD python test_ipaddress.py
diff --git a/test-python2.7.Dockerfile b/test-python2.7.Dockerfile
new file mode 100644
index 0000000..9c58f6b
--- /dev/null
+++ b/test-python2.7.Dockerfile
@@ -0,0 +1,11 @@
+FROM python:2.7-alpine
+# Dockerfile to run tests under python2.7
+
+# docker build -t ipaddress-python2.7 . -f test-python2.7.Dockerfile
+RUN apk add make
+RUN pip install flake8
+
+ADD . .
+RUN python test_ipaddress.py
+RUN make lint
+CMD python test_ipaddress.py
diff --git a/test-python3.2.Dockerfile b/test-python3.2.Dockerfile
new file mode 100644
index 0000000..56d2b46
--- /dev/null
+++ b/test-python3.2.Dockerfile
@@ -0,0 +1,8 @@
+FROM python:3.2-slim
+# Dockerfile to run tests under python3.2
+
+# docker build -t ipaddress-python3.2 . -f test-python3.2.Dockerfile
+
+ADD . .
+RUN python test_ipaddress.py
+CMD python test_ipaddress.py
diff --git a/test-python3.3.Dockerfile b/test-python3.3.Dockerfile
new file mode 100644
index 0000000..87c504e
--- /dev/null
+++ b/test-python3.3.Dockerfile
@@ -0,0 +1,8 @@
+FROM python:3.3-alpine
+# Dockerfile to run tests under python3.3
+
+# docker build -t ipaddress-python3.3 . -f test-python3.3.Dockerfile
+
+ADD . .
+RUN python test_ipaddress.py
+CMD python test_ipaddress.py
diff --git a/test_ipaddress.py b/test_ipaddress.py
index 2cbe36a..a1721b8 100644
--- a/test_ipaddress.py
+++ b/test_ipaddress.py
@@ -862,9 +862,9 @@ class IpaddrUnitTest(unittest.TestCase):
self.ipv6_network = ipaddress.IPv6Network('2001:658:22a:cafe::/64')
def testRepr(self):
- self.assertTrue(re.match("IPv4Interface\(u?'1.2.3.4/32'\)",
+ self.assertTrue(re.match(r"IPv4Interface\(u?'1.2.3.4/32'\)",
repr(ipaddress.IPv4Interface('1.2.3.4'))))
- self.assertTrue(re.match("IPv6Interface\(u?'::1/128'\)",
+ self.assertTrue(re.match(r"IPv6Interface\(u?'::1/128'\)",
repr(ipaddress.IPv6Interface('::1'))))
# issue #16531: constructing IPv4Network from an (address, mask) tuple
@@ -1014,7 +1014,8 @@ class IpaddrUnitTest(unittest.TestCase):
[(ip1, ip3)])
self.assertEqual(128, ipaddress._count_righthand_zero_bits(0, 128))
self.assertTrue(
- re.match("IPv4Network\(u?'1.2.3.0/24'\)", repr(self.ipv4_network)))
+ re.match(r"IPv4Network\(u?'1.2.3.0/24'\)",
+ repr(self.ipv4_network)))
def testMissingAddressVersion(self):
class Broken(ipaddress._BaseAddress):
@@ -2161,7 +2162,7 @@ if not hasattr(BaseTestCase, 'assertRaisesRegex'):
expected_regex = self.expected_regex
if not expected_regex.search(str(exc_value)):
- raise AssertionError('"{}" does not match "{}"'.format(
+ raise AssertionError('"{0}" does not match "{1}"'.format(
expected_regex.pattern, str(exc_value)))
return True
@@ -2212,7 +2213,7 @@ class CompatTest(unittest.TestCase):
self.assertEqual(ipaddress._compat_bit_length(4), 3)
-class SingleIssuesTest(unittest.TestCase):
+class SingleIssuesTest(BaseTestCase):
# https://github.com/phihag/ipaddress/issues/14
def test_issue_14(self):
self.assertTrue(ipaddress.ip_address('127.0.0.1').is_private)
@@ -2225,6 +2226,12 @@ class SingleIssuesTest(unittest.TestCase):
self.assertTrue(net2.subnet_of(net1))
self.assertFalse(net2.supernet_of(net1))
+ def test_issue_48(self):
+ v6net = ipaddress.ip_network('::/0')
+ v4net = ipaddress.ip_network('1.2.3.0/24')
+ with self.assertRaisesRegex(TypeError, r'are not of the same version'):
+ v6net.subnet_of(v4net)
+
if __name__ == '__main__':
unittest.main()