From c7fc2e3b92fd2ad317bb8c8738959658695454f4 Mon Sep 17 00:00:00 2001 From: Kelly Brazil Date: Sun, 28 Aug 2022 11:58:51 -0700 Subject: [PATCH] fix for older python versions that don't provide the netmask attribute when a decimal ip is used --- jc/parsers/ip_address.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/jc/parsers/ip_address.py b/jc/parsers/ip_address.py index 7789e552..1b807dde 100644 --- a/jc/parsers/ip_address.py +++ b/jc/parsers/ip_address.py @@ -573,7 +573,12 @@ def parse( hostmask_ipobj = ipaddress.ip_address(hostmask_string) - netmask_string = str(interface.with_netmask).split('/')[1] + # older versions of python (e.g. 3.6) don't provide netmask when a decimal IP is entered + try: + netmask_string = str(interface.netmask) + except AttributeError: + netmask_string = '255.255.255.255' + netmask_ipobj = ipaddress.ip_address(netmask_string) bare_ip_string = str(interface.ip)