🌐 AI搜索 & 代理 主页
Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
hexadecimal spelling =)
  • Loading branch information
gpshead committed Sep 2, 2022
commit 8acc89182b87c4ef95de7767f5ddcfc28bb06342
6 changes: 3 additions & 3 deletions Doc/library/stdtypes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4884,7 +4884,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 @@ -4921,7 +4921,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 @@ -5006,7 +5006,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.8.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2330,7 +2330,7 @@ Notable security feature in 3.8.14
==================================

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 @@ -891,7 +891,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 @@ -200,7 +200,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 Python/ast.c
Original file line number Diff line number Diff line change
Expand Up @@ -2472,7 +2472,7 @@ ast_for_atom(struct compiling *c, const node *n)
Py_XDECREF(tb);
Py_DECREF(type);
ast_error(c, ch,
"%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