[python-netaddr/f14] Do not traceback on invalid IPNetwork input

Jakub Hrozek jhrozek at fedoraproject.org
Tue Jun 7 14:01:41 UTC 2011


commit badd265aae945038485daec166d0092c4fb428ed
Author: Jakub Hrozek <jhrozek at redhat.com>
Date:   Mon May 30 08:51:41 2011 +0200

    Do not traceback on invalid IPNetwork input
    
    (upstream issues #2, #6, #5, #8)

 ...-Fixed-github-Issue-no.-2.-Thanks-keesbos.patch |   65 ++++++++++++++++++++
 python-netaddr.spec                                |   11 +++-
 2 files changed, 75 insertions(+), 1 deletions(-)
---
diff --git a/0001-Fixed-github-Issue-no.-2.-Thanks-keesbos.patch b/0001-Fixed-github-Issue-no.-2.-Thanks-keesbos.patch
new file mode 100644
index 0000000..28d4d61
--- /dev/null
+++ b/0001-Fixed-github-Issue-no.-2.-Thanks-keesbos.patch
@@ -0,0 +1,65 @@
+From 80071f4450261b70b70f537bc2b54d2c97d9f562 Mon Sep 17 00:00:00 2001
+From: "David P. D. Moss" <drkjam at gmail.com>
+Date: Thu, 25 Nov 2010 08:53:49 +0000
+Subject: [PATCH] Fixed github Issue no. 2. Thanks keesbos.
+
+---
+ netaddr/ip/__init__.py               |    2 ++
+ netaddr/tests/2.x/ip/constructor.txt |   11 +++++++++++
+ netaddr/tests/3.x/ip/constructor.txt |   11 +++++++++++
+ 3 files changed, 24 insertions(+), 0 deletions(-)
+
+diff --git a/netaddr/ip/__init__.py b/netaddr/ip/__init__.py
+index 0179c38..e4a6b7b 100644
+--- a/netaddr/ip/__init__.py
++++ b/netaddr/ip/__init__.py
+@@ -779,6 +779,8 @@ def parse_ip_network(module, addr, implicit_prefix=False, flags=0):
+                 #   Try a partial IPv4 network address...
+                 expanded_addr = _ipv4.expand_partial_address(val1)
+                 ip = IPAddress(expanded_addr, module.version, flags=INET_PTON)
++            else:
++                raise AddrFormatError('invalid IPNetwork address %s!' % addr)
+         value = ip._value
+ 
+         try:
+diff --git a/netaddr/tests/2.x/ip/constructor.txt b/netaddr/tests/2.x/ip/constructor.txt
+index f67f5e4..5a9e978 100644
+--- a/netaddr/tests/2.x/ip/constructor.txt
++++ b/netaddr/tests/2.x/ip/constructor.txt
+@@ -209,3 +209,14 @@ IPNetwork('172.24.0.0/16')
+ 
+ 
+ }}}
++
++Negative testing
++
++{{{
++
++>>> IPNetwork('foo')
++Traceback (most recent call last):
++...
++AddrFormatError: invalid IPNetwork foo
++
++}}}
+diff --git a/netaddr/tests/3.x/ip/constructor.txt b/netaddr/tests/3.x/ip/constructor.txt
+index 2ec47c0..35a5cd6 100644
+--- a/netaddr/tests/3.x/ip/constructor.txt
++++ b/netaddr/tests/3.x/ip/constructor.txt
+@@ -209,3 +209,14 @@ IPNetwork('172.24.0.0/16')
+ 
+ 
+ }}}
++
++Negative testing
++
++{{{
++
++>>> IPNetwork('foo')
++Traceback (most recent call last):
++...
++netaddr.core.AddrFormatError: invalid IPNetwork foo
++
++}}}
+-- 
+1.7.5.2
+
diff --git a/python-netaddr.spec b/python-netaddr.spec
index 51111a4..aa0a9ff 100644
--- a/python-netaddr.spec
+++ b/python-netaddr.spec
@@ -4,7 +4,7 @@
 
 Name:           python-netaddr
 Version:        0.7.5
-Release:        1%{?dist}
+Release:        2%{?dist}
 Summary:        A pure Python network address representation and manipulation library
 
 Group:          Development/Libraries
@@ -16,6 +16,8 @@ BuildRoot:      %(mktemp -ud %{_tmppath}/%{name}-%{version}-%{release}-XXXXXX)
 BuildArch:      noarch
 BuildRequires:  python-devel >= 2.4
 
+Patch0:         0001-Fixed-github-Issue-no.-2.-Thanks-keesbos.patch
+
 
 %description
 A pure Python network address representation and manipulation library.
@@ -48,6 +50,7 @@ API documentation for the latest release is available here :-
 
 %prep
 %setup -q -n netaddr-%{version}
+%patch0 -p1 -b .invalid_ip_network
 
 # Make rpmlint happy, get rid of DOS line endings
 %{__sed} -i 's/\r//' netaddr/*.py
@@ -59,6 +62,8 @@ API documentation for the latest release is available here :-
 find netaddr -name "*.py" | \
   xargs %{__perl} -ni -e 'print unless /usr\/bin\/python|env\s+python/'
 
+# Make rpmlint happy, fix permissions on documentation files
+chmod 0644 README AUTHORS CHANGELOG COPYRIGHT INSTALL LICENSE PKG-INFO
 
 %build
 %{__python} setup.py build
@@ -84,6 +89,10 @@ rm -rf %{buildroot}
 %{_bindir}/netaddr
 
 %changelog
+* Tue Jun 7 2011 Jakub Hrozek <jhrozek at redhat.com> - 0.7.5-2
+- Do not traceback on invalid IPNetwork input (upstream issues #2, #6, #5, #8)
+- Remove executable bit from documentation files to make rpmlint happy
+
 * Tue Oct 05 2010 John Eckersberg <jeckersb at redhat.com> - 0.7.5-1
 - New upstream release 0.7.5
 - Updated summary and description to match upstream README


More information about the scm-commits mailing list