microsoft / debugpy

An implementation of the Debug Adapter Protocol for Python
https://pypi.org/project/debugpy/
Other
1.87k stars 139 forks source link

`super()`: no arguments #1732

Closed bersbersbers closed 2 weeks ago

bersbersbers commented 2 weeks ago

Environment data

Actual behavior

Cannot run super() in Debug Console

Expected behavior

Can run super() in Debug Console

Steps to reproduce:

class A:
    def method(self):
        print("super!")

class B(A):
    def method(self):
        super().method()

B().method()
  1. Set breakpoint in line super().method()
  2. Run file with debugger attached
  3. At breakpoint, run super().method() in Debug Console

Image

rchiodo commented 2 weeks ago

Thanks for the issue but that's by design. The debugger is just running what you type in a python eval call. super() isn't allowed in an eval call.

super() really means super(__class__, self). See this PEP: https://peps.python.org/pep-3135/

If you want this to work, you'd do this instead:

super(__class__, self).method()
bersbersbers commented 2 weeks ago

Thanks - learned something 😃