Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Remove recursive repr call #29314

Merged
merged 2 commits into from
Jun 21, 2024
Merged

Conversation

jessie-ross
Copy link
Contributor

@jessie-ross jessie-ross commented Jun 20, 2024

SUMMARY

This repr call is recursive:

  File \"/opt/superset/lib/python3.11/site-packages/superset/commands/exceptions.py\", line 31, in __repr__
    return repr(self)
           ^^^^^^^^^^
  File \"/opt/superset/lib/python3.11/site-packages/superset/commands/exceptions.py\", line 31, in __repr__
    return repr(self)
           ^^^^^^^^^^
  File \"/opt/superset/lib/python3.11/site-packages/superset/commands/exceptions.py\", line 31, in __repr__
    return repr(self)
           ^^^^^^^^^^
  [Previous line repeated 321 more times]"}

Causing the error not to be printed.

TESTING INSTRUCTIONS

Demonstration:

>>> class Parent():
...     def __init__(self, x):
...         self.x = x
...     def __repr__(self):
...         return 'Parent: ' + self.x
>>> Parent('0')
Parent: 0

>>> class Child(Parent):
...     def __repr__(self):
...         return repr(self)
>>> Child('1')
Traceback (most recent call last):
  File "<stdin>", line 3, in __repr__
  File "<stdin>", line 3, in __repr__
  File "<stdin>", line 3, in __repr__
  [Previous line repeated 2495 more times]
RecursionError: maximum recursion depth exceeded


>>> class Child(Parent):
...     def __repr__(self):
...         return super().__repr__()
>>> Child('2')
Parent: 2

ADDITIONAL INFORMATION

  • Has associated issue:
  • Required feature flags:
  • Changes UI
  • Includes DB Migration (follow approval process in SIP-59)
    • Migration is atomic, supports rollback & is backwards-compatible
    • Confirm DB migration upgrade and downgrade tested
    • Runtime estimates and downtime expectations provided
  • Introduces new feature or API
  • Removes existing feature or API

@@ -28,7 +28,7 @@ class CommandException(SupersetException):
def __repr__(self) -> str:
if self._exception:
return repr(self._exception)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this line also be updated?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This isn't recursive, as it is calling repr on a separate object

@villebro
Copy link
Member

@jessie-ross thanks for the illustrative example in the description! ❤️ LGTM

@villebro villebro merged commit 9444c6b into apache:master Jun 21, 2024
37 checks passed
@michael-s-molina michael-s-molina added the v4.0 Label added by the release manager to track PRs to be included in the 4.0 branch label Jun 21, 2024
michael-s-molina pushed a commit that referenced this pull request Jun 26, 2024
@mistercrunch mistercrunch added 🍒 4.0.2 🏷️ bot A label used by `supersetbot` to keep track of which PR where auto-tagged with release labels labels Jul 24, 2024
eschutho pushed a commit that referenced this pull request Jul 24, 2024
irublev pushed a commit to HighviewPower/superset that referenced this pull request Oct 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🏷️ bot A label used by `supersetbot` to keep track of which PR where auto-tagged with release labels size/XS v4.0 Label added by the release manager to track PRs to be included in the 4.0 branch 🍒 4.0.2
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants