diff --git a/Lib/urllib.py b/Lib/urllib.py index 70900cd211e..da4f56ed898 100644 --- a/Lib/urllib.py +++ b/Lib/urllib.py @@ -1375,8 +1375,13 @@ if sys.platform == 'darwin': continue base = ip2num(m.group(1)) - mask = int(m.group(2)[1:]) - mask = 32 - mask + mask = m.group(2) + if mask is None: + mask = 8 * (m.group(1).count('.') + 1) + + else: + mask = int(mask[1:]) + mask = 32 - mask if (hostIP >> mask) == (base >> mask): return True