Skip to content

Commit

Permalink
Add error handling for Repr.indent
Browse files Browse the repository at this point in the history
  • Loading branch information
finefoot authored May 14, 2022
1 parent f8a2db1 commit 721357c
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions Lib/reprlib.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,12 @@ def _join(self, pieces, level):
if not pieces:
return ''
indent = self.indent
if not isinstance(indent, str):
if not isinstance(indent, int) or indent < 0:
raise ValueError(
"Repr.indent must be None, str or non-negative int, not "
+ repr(indent)
)
if isinstance(indent, int):
indent *= ' '
sep = ',\n' + (self.maxlevel - level + 1) * indent
Expand Down

0 comments on commit 721357c

Please sign in to comment.