You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Since bug bpo-1006219 was fixed, inspect.getsource(func) has returned the source of a function including any decorators on the function. But doing the same with a class, the returned source doesn't include decorators.
With functions, the co_firstlineno attribute of the code object points to the start of the decorators. With classes, that's not possible, so it's likely that a bit more regex trickery will be needed to scan back to decorators.
I've confirmed the same thing happens in 3.2 and 2.7, and looking at the code of inspect.py in trunk, it looks like it will do the same thing.
This should be resolved by bpo-35113 . I have rewritten the getsource function for classes to use AST to deal with nested classes. The PR adds support for showing the decorator in the source. I would propose closing this as a duplicate of the other issue.
New changeset 696136b by Karthikeyan Singaravelan in branch 'master': bpo-35113: Fix inspect.getsource to return correct source for inner classes (bpo-10307) 696136b
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: