Skip to content
Prev Previous commit
hexadecimal spelling =)
  • Loading branch information
gpshead committed Sep 2, 2022
commit c4aea14ea5e074bd0d6660f63002be525ce07905
6 changes: 3 additions & 3 deletions Doc/library/stdtypes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5470,7 +5470,7 @@ Integer string conversion length limitation

CPython has a global limit for converting between :class:`int` and :class:`str`
to mitigate denial of service attacks. This limit *only* applies to decimal or
other non-power-of-two number bases. Hexidecimal, octal, and binary conversions
other non-power-of-two number bases. Hexadecimal, octal, and binary conversions
are unlimited. The limit can be configured.

The :class:`int` type in CPython is an abitrary length number stored in binary
Expand Down Expand Up @@ -5507,7 +5507,7 @@ When an operation would exceed the limit, a :exc:`ValueError` is raised:
ValueError: Exceeds the limit (4300) for integer string conversion: value has 8599 digits.
>>> len(hex(i_squared))
7144
>>> assert int(hex(i_squared), base=16) == i*i # Hexidecimal is unlimited.
>>> assert int(hex(i_squared), base=16) == i*i # Hexadecimal is unlimited.

The default limit is 4300 digits as provided in
:data:`sys.int_info.default_max_str_digits <sys.int_info>`.
Expand Down Expand Up @@ -5592,7 +5592,7 @@ Information about the default and minimum can be found in :attr:`sys.int_info`:
encounter an error during parsing, usually at startup time or import time or
even at installation time - anytime an up to date ``.pyc`` does not already
exist for the code. A workaround for source that contains such large
constants is to convert them to ``0x`` hexidecimal form as it has no limit.
constants is to convert them to ``0x`` hexadecimal form as it has no limit.

Test your application thoroughly if you use a low limit. Ensure your tests
run with the limit set early via the environment or flag so that it applies
Expand Down
2 changes: 1 addition & 1 deletion Doc/whatsnew/3.11.rst
Original file line number Diff line number Diff line change
Expand Up @@ -441,7 +441,7 @@ Other CPython Implementation Changes
(Contributed by Éric Araujo in :issue:`46142`.)

* Converting between :class:`int` and :class:`str` in bases other than 2
(binary), 4, 8 (octal), 16 (hexidecimal), or 32 such as base 10 (decimal)
(binary), 4, 8 (octal), 16 (hexadecimal), or 32 such as base 10 (decimal)
now raises a :exc:`ValueError` if the number of digits in string form is
above a limit to avoid potential denial of service attacks due to the
algorithmic complexity. This is a mitigation for `CVE-2020-10735
Expand Down
2 changes: 1 addition & 1 deletion Lib/test/test_ast.py
Original file line number Diff line number Diff line change
Expand Up @@ -1136,7 +1136,7 @@ def test_literal_eval_str_int_limit(self):
with self.assertRaises(SyntaxError) as err_ctx:
ast.literal_eval('3'*4001)
self.assertIn('Exceeds the limit ', str(err_ctx.exception))
self.assertIn(' Consider hexidecimal ', str(err_ctx.exception))
self.assertIn(' Consider hexadecimal ', str(err_ctx.exception))

def test_literal_eval_complex(self):
# Issue #4907
Expand Down
2 changes: 1 addition & 1 deletion Lib/test/test_compile.py
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ def test_int_literals_too_long(self):
exc = err_ctx.exception
self.assertEqual(exc.lineno, 3)
self.assertIn('Exceeds the limit ', str(exc))
self.assertIn(' Consider hexidecimal ', str(exc))
self.assertIn(' Consider hexadecimal ', str(exc))

def test_unary_minus(self):
# Verify treatment of unary minus on negative numbers SF bug #660455
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Converting between :class:`int` and :class:`str` in bases other than 2
(binary), 4, 8 (octal), 16 (hexidecimal), or 32 such as base 10 (decimal) now
(binary), 4, 8 (octal), 16 (hexadecimal), or 32 such as base 10 (decimal) now
raises a :exc:`ValueError` if the number of digits in string form is above a
limit to avoid potential denial of service attacks due to the algorithmic
complexity. This is a mitigation for `CVE-2020-10735
Expand Down
2 changes: 1 addition & 1 deletion Parser/pegen.c
Original file line number Diff line number Diff line change
Expand Up @@ -669,7 +669,7 @@ _PyPegen_number_token(Parser *p)
p, PyExc_SyntaxError,
t->lineno, -1 /* col_offset */,
t->end_lineno, -1 /* end_col_offset */,
"%S - Consider hexidecimal for huge integer literals "
"%S - Consider hexadecimal for huge integer literals "
"to avoid decimal conversion limits.",
value);
Py_DECREF(value);
Expand Down