Skip to content

Commit

Permalink
Remove possible RecursionError in ASTBaseBase.__repr__()
Browse files Browse the repository at this point in the history
  • Loading branch information
AA-Turner committed Nov 22, 2024
1 parent fc503d4 commit 697da6e
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions sphinx/util/cfamily.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ def clone(self) -> Any:
return deepcopy(self)

def _stringify(self, transform: StringifyTransform) -> str:
raise NotImplementedError(repr(self))
raise NotImplementedError

def __str__(self) -> str:
return self._stringify(str)
Expand All @@ -124,7 +124,9 @@ def get_display_string(self) -> str:
return self._stringify(lambda ast: ast.get_display_string())

def __repr__(self) -> str:
return f'<{self.__class__.__name__}: {self._stringify(repr)}>'
if repr_string := self._stringify(repr):
return f'<{self.__class__.__name__}: {repr_string}>'
return f'<{self.__class__.__name__}>'


################################################################################
Expand Down

0 comments on commit 697da6e

Please sign in to comment.