Incompatibility with netaddr-1.1.0

Bug #2054134 reported by Michał Górny
10
This bug affects 2 people
Affects Status Importance Assigned to Milestone
oslo.utils
New
Undecided
Unassigned

Bug Description

After upgrading netaddr to 1.1.0, I'm getting the follwoing test failures. I'm not sure if that's merely a test problem, or an actual incompatibility. I can reproduce with master as of 093f20df8da58f68dde9fe37783a97be49c47f68.

```
==============================
Failed 3 tests - output below:
==============================

oslo_utils.tests.test_netutils.NetworkUtilsTest.test_is_valid_ipv4
------------------------------------------------------------------

Captured traceback:
~~~~~~~~~~~~~~~~~~~
    Traceback (most recent call last):

      File "/usr/lib/python3.11/unittest/mock.py", line 1375, in patched
    return func(*newargs, **newkeywargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

      File "/tmp/oslo.utils/oslo_utils/tests/test_netutils.py", line 168, in test_is_valid_ipv4
    self.assertTrue(netutils.is_valid_ipv4('10'))

      File "/usr/lib/python3.11/unittest/case.py", line 715, in assertTrue
    raise self.failureException(msg)

    AssertionError: False is not true

oslo_utils.tests.test_netutils.NetworkUtilsTest.test_is_valid_ip
----------------------------------------------------------------

Captured traceback:
~~~~~~~~~~~~~~~~~~~
    Traceback (most recent call last):

      File "/tmp/oslo.utils/oslo_utils/tests/test_netutils.py", line 232, in test_is_valid_ip
    self.assertFalse(netutils.is_valid_ip(None))
                     ^^^^^^^^^^^^^^^^^^^^^^^^^^

      File "/tmp/oslo.utils/oslo_utils/netutils.py", line 298, in is_valid_ip
    return is_valid_ipv4(address) or is_valid_ipv6(address)
           ^^^^^^^^^^^^^^^^^^^^^^

      File "/tmp/oslo.utils/oslo_utils/netutils.py", line 111, in is_valid_ipv4
    if netaddr.valid_ipv4(address, flags=INET_PTON):
       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

      File "/tmp/oslo.utils/.tox/py311/lib/python3.11/site-packages/netaddr/strategy/ipv4.py", line 99, in valid_str
    str_to_int(addr, flags)

      File "/tmp/oslo.utils/.tox/py311/lib/python3.11/site-packages/netaddr/strategy/ipv4.py", line 119, in str_to_int
    elif pton_mode and any(len(p) > 1 and p.startswith('0') for p in addr.split('.')):
                                                                     ^^^^^^^^^^

    AttributeError: 'NoneType' object has no attribute 'split'

oslo_utils.tests.test_netutils.IPv6byEUI64TestCase.test_generate_IPv6_with_error_prefix_type
--------------------------------------------------------------------------------------------

Captured traceback:
~~~~~~~~~~~~~~~~~~~
    Traceback (most recent call last):

      File "/tmp/oslo.utils/oslo_utils/tests/test_netutils.py", line 404, in test_generate_IPv6_with_error_prefix_type
    self.assertRaises(TypeError, lambda:

      File "/tmp/oslo.utils/.tox/py311/lib/python3.11/site-packages/testtools/testcase.py", line 469, in assertRaises
    self.assertThat(our_callable, matcher)

      File "/tmp/oslo.utils/.tox/py311/lib/python3.11/site-packages/testtools/testcase.py", line 480, in assertThat
    mismatch_error = self._matchHelper(matchee, matcher, message, verbose)
                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

      File "/tmp/oslo.utils/.tox/py311/lib/python3.11/site-packages/testtools/testcase.py", line 532, in _matchHelper
    mismatch = matcher.match(matchee)
               ^^^^^^^^^^^^^^^^^^^^^^

      File "/tmp/oslo.utils/.tox/py311/lib/python3.11/site-packages/testtools/matchers/_exception.py", line 104, in match
    mismatch = self.exception_matcher.match(exc_info)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

      File "/tmp/oslo.utils/.tox/py311/lib/python3.11/site-packages/testtools/matchers/_higherorder.py", line 62, in match
    mismatch = matcher.match(matchee)
               ^^^^^^^^^^^^^^^^^^^^^^

      File "/tmp/oslo.utils/.tox/py311/lib/python3.11/site-packages/testtools/testcase.py", line 459, in match
    reraise(*matchee)

      File "/tmp/oslo.utils/.tox/py311/lib/python3.11/site-packages/testtools/compat.py", line 26, in reraise
    raise exc_obj.with_traceback(exc_tb)

      File "/tmp/oslo.utils/.tox/py311/lib/python3.11/site-packages/testtools/matchers/_exception.py", line 97, in match
    result = matchee()
             ^^^^^^^^^

      File "/tmp/oslo.utils/.tox/py311/lib/python3.11/site-packages/testtools/testcase.py", line 1041, in __call__
    return self._callable_object(*self._args, **self._kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

      File "/tmp/oslo.utils/oslo_utils/tests/test_netutils.py", line 405, in <lambda>
    netutils.get_ipv6_addr_by_EUI64(prefix, mac))
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

      File "/tmp/oslo.utils/oslo_utils/netutils.py", line 206, in get_ipv6_addr_by_EUI64
    if is_valid_ipv4(prefix):
       ^^^^^^^^^^^^^^^^^^^^^

      File "/tmp/oslo.utils/oslo_utils/netutils.py", line 111, in is_valid_ipv4
    if netaddr.valid_ipv4(address, flags=INET_PTON):
       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

      File "/tmp/oslo.utils/.tox/py311/lib/python3.11/site-packages/netaddr/strategy/ipv4.py", line 99, in valid_str
    str_to_int(addr, flags)

      File "/tmp/oslo.utils/.tox/py311/lib/python3.11/site-packages/netaddr/strategy/ipv4.py", line 119, in str_to_int
    elif pton_mode and any(len(p) > 1 and p.startswith('0') for p in addr.split('.')):
                                                                     ^^^^^^^^^^

    AttributeError: 'int' object has no attribute 'split'
```

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.