@@ -488,7 +488,7 @@ def _prefix_from_prefix_string(cls, prefixlen_str):
488
488
"""
489
489
# int allows a leading +/- as well as surrounding whitespace,
490
490
# 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 () ):
492
492
cls ._report_invalid_netmask (prefixlen_str )
493
493
try :
494
494
prefixlen = int (prefixlen_str )
@@ -1076,7 +1076,6 @@ class _BaseV4:
1076
1076
_version = 4
1077
1077
# Equivalent to 255.255.255.255 or 32 bits of 1's.
1078
1078
_ALL_ONES = (2 ** IPV4LENGTH ) - 1
1079
- _DECIMAL_DIGITS = frozenset ('0123456789' )
1080
1079
1081
1080
# the valid octets for host and netmasks. only useful for IPv4.
1082
1081
_valid_mask_octets = frozenset ({255 , 254 , 252 , 248 , 240 , 224 , 192 , 128 , 0 })
@@ -1156,7 +1155,7 @@ def _parse_octet(cls, octet_str):
1156
1155
if not octet_str :
1157
1156
raise ValueError ("Empty octet not permitted" )
1158
1157
# 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 () ):
1160
1159
msg = "Only decimal digits permitted in %r"
1161
1160
raise ValueError (msg % octet_str )
1162
1161
# We do the length check second, since the invalid character error
0 commit comments