Skip to content

Commit 813ab8c

Browse files
committed
update comment
1 parent 4ac21bb commit 813ab8c

2 files changed

Lines changed: 3 additions & 4 deletions

File tree

Lib/reprlib.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -192,9 +192,8 @@ def repr_int(self, x, level):
192192
# are rendered differently as their repr() raises a ValueError.
193193
# See https://github.com/python/cpython/issues/135487.
194194
k = 1 + int(math.log10(abs(x)))
195-
# When math.log10(abs(x)) is overestimated or underestimated,
196-
# the number of digits should be k - 1 or k + 1 respectively.
197-
# For simplicity, we do not compute the exact number of digits.
195+
# Note: math.log10(abs(x)) may be overestimated or underestimated,
196+
# but for simplicity, we do not compute the exact number of digits.
198197
max_digits = sys.get_int_max_str_digits()
199198
return (f'<{x.__class__.__name__} instance with roughly {k} '
200199
f'digits (limit at {max_digits}) at 0x{id(x):x}>')

Lib/test/test_reprlib.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ def re_msg(n, d):
179179
self.assertRegex(r(n), re_msg(n, k + 1))
180180
with self.subTest(f'10 ** {k} - 1', k=k):
181181
n = 10 ** k - 1
182-
# For k >> 1, since math.log10(n) == math.log10(n-1),
182+
# Here, since math.log10(n) == math.log10(n-1),
183183
# the number of digits of n - 1 is overestimated.
184184
self.assertRaises(ValueError, repr, n)
185185
self.assertRegex(r(n), re_msg(n, k + 1))

0 commit comments

Comments
 (0)