Skip to content

Remember the source of interactively defined functions - #515

Merged
sebastinas merged 3 commits into
bpython:masterfrom
michaelmulley:feature/remember-console-code
Mar 26, 2015
Merged

Remember the source of interactively defined functions#515
sebastinas merged 3 commits into
bpython:masterfrom
michaelmulley:feature/remember-console-code

Conversation

@michaelmulley

Copy link
Copy Markdown
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
Comment thread bpython/history.py Outdated

Copy link
Copy Markdown
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
Copy Markdown
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