@@ -488,7 +488,7 @@ def _prefix_from_prefix_string(cls, prefixlen_str):
488488 """
489489 # int allows a leading +/- as well as surrounding whitespace,
490490 # so we ensure that isn't the case
491- if not _BaseV4 . _DECIMAL_DIGITS . issuperset ( prefixlen_str ):
491+ if not ( prefixlen_str . isascii () and prefixlen_str . isdigit () ):
492492 cls ._report_invalid_netmask (prefixlen_str )
493493 try :
494494 prefixlen = int (prefixlen_str )
@@ -1076,7 +1076,6 @@ class _BaseV4:
10761076 _version = 4
10771077 # Equivalent to 255.255.255.255 or 32 bits of 1's.
10781078 _ALL_ONES = (2 ** IPV4LENGTH ) - 1
1079- _DECIMAL_DIGITS = frozenset ('0123456789' )
10801079
10811080 # the valid octets for host and netmasks. only useful for IPv4.
10821081 _valid_mask_octets = frozenset ({255 , 254 , 252 , 248 , 240 , 224 , 192 , 128 , 0 })
@@ -1156,7 +1155,7 @@ def _parse_octet(cls, octet_str):
11561155 if not octet_str :
11571156 raise ValueError ("Empty octet not permitted" )
11581157 # Whitelist the characters, since int() allows a lot of bizarre stuff.
1159- if not cls . _DECIMAL_DIGITS . issuperset ( octet_str ):
1158+ if not ( octet_str . isascii () and octet_str . isdigit () ):
11601159 msg = "Only decimal digits permitted in %r"
11611160 raise ValueError (msg % octet_str )
11621161 # We do the length check second, since the invalid character error
0 commit comments