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

Remove last exception's references if any #59

Merged
merged 2 commits into from
Mar 18, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions AUTHORS.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ Authors
* Nir Soffer - http://nirs.freeshell.org
* Jesús Cea - https://github.com/jcea
* "honnix" - https://github.com/honnix
* Anton Ryzhov - https://github.com/anton-ryzhov
5 changes: 5 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@
Changelog
=========

dev
------------------

* Fixed memory leak via ``sys.last_type``, ``sys.last_value``, ``sys.last_traceback``

1.6.0 (2019-01-19)
------------------

Expand Down
9 changes: 8 additions & 1 deletion src/manhole/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,14 @@ def handle_repl(locals):
}
if locals:
namespace.update(locals)
ManholeConsole(namespace).interact()
try:
ManholeConsole(namespace).interact()
finally:
for attribute in ['last_type', 'last_value', 'last_traceback']:
try:
delattr(sys, attribute)
Copy link
Owner

Choose a reason for hiding this comment

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

Probably better to set to None instead? This would trigger AttributeErrors - afaik the python docs give the impression that these attributes would always be there.

Copy link
Owner

Choose a reason for hiding this comment

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

Copy link
Contributor Author

@anton-ryzhov anton-ryzhov Mar 15, 2021

Choose a reason for hiding this comment

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

Yes, they're not defined by default. So I'm reverting them to the original state

except AttributeError:
pass


class Logger(object):
Expand Down