File 0001-netutils-Explicitly-require-INET_ATON.patch of Package python-oslo.utils

From a14bc13ad069870ab58263d28af9424c305c8bd8 Mon Sep 17 00:00:00 2001
From: Takashi Kajinami <kajinamit@oss.nttdata.com>
Date: Sun, 18 Feb 2024 01:52:12 +0900
Subject: [PATCH] netutils: Explicitly require INET_ATON

netaddr 1.0.0 changed the default parsing mode from INET_ATON to
INET_PTON[1]. To keep the consistent behavior over that change, set
the flag to INET_ATON explicitly when strictness is not required.

[1] https://netaddr.readthedocs.io/en/latest/changes.html#release-1-0-0

Change-Id: Iee6d73e7fc7af5c5be4cc439469d4ea58944abfb
---
 oslo_utils/netutils.py | 5 +++--
 requirements.txt       | 2 +-
 2 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/oslo_utils/netutils.py b/oslo_utils/netutils.py
index ecbe779..017a416 100644
--- a/oslo_utils/netutils.py
+++ b/oslo_utils/netutils.py
@@ -24,6 +24,7 @@ import socket
 from urllib import parse
 
 import netaddr
+from netaddr.core import INET_ATON
 from netaddr.core import INET_PTON
 import netifaces
 
@@ -100,7 +101,7 @@ def is_valid_ipv4(address, strict=None):
        (``a.b.c.d``, ``a.b.c``, ``a.b``, ``a``).
     """
     if strict is not None:
-        flag = INET_PTON if strict else 0
+        flag = INET_PTON if strict else INET_ATON
         try:
             return netaddr.valid_ipv4(address, flags=flag)
         except netaddr.AddrFormatError:
@@ -111,7 +112,7 @@ def is_valid_ipv4(address, strict=None):
         if netaddr.valid_ipv4(address, flags=INET_PTON):
             return True
         else:
-            if netaddr.valid_ipv4(address):
+            if netaddr.valid_ipv4(address, flags=INET_ATON):
                 LOG.warning(
                     'Converting in non strict mode is deprecated. '
                     'You should pass strict=False if you want to '
diff --git a/requirements.txt b/requirements.txt
index be2c366..07fe867 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -6,7 +6,7 @@
 iso8601>=0.1.11 # MIT
 oslo.i18n>=3.15.3 # Apache-2.0
 pytz>=2013.6;python_version<"3.9" # MIT
-netaddr>=0.7.18 # BSD
+netaddr>=0.10.0 # BSD
 netifaces>=0.10.4 # MIT
 debtcollector>=1.2.0 # Apache-2.0
 pyparsing>=2.1.0 # MIT
-- 
2.45.1

openSUSE Build Service is sponsored by