Skip to content

Remember the source of interactively defined functions #515

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

Merged

Conversation

michaelmulley
Copy link
Contributor

  • Patches the linecache module to achieve this
  • inspect.getsource() works for functions defined on the console
  • tracebacks show code for frames inside interactively defined functions

fixes #229

- Patches the linecache module to achieve this
- inspect.getsource() works for functions defined on the console
- tracebacks show code for frames inside interactively defined functions
fixes bpython#229
to also remember (in an unerasable way) bpython console input."""

def __init__(self, *args, **kwargs):
dict.__init__(self, *args, **kwargs)
Copy link
Contributor

Choose a reason for hiding this comment

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

dict is new style class, isn't it? Please use super instead.

@michaelmulley
Copy link
Contributor Author

Sure, moved things to a separate file.

The motivation for catching AttributeErrors is if some other code also patches the same object -- if that happens, better to just no longer have inspect.getsource() work for interactively-defined functions than to raise an exception.

@sebastinas sebastinas merged commit 92e9b0b into bpython:master Mar 26, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

patch inspect.getsource so that I can get the source of interactively defined functions
2 participants