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

Check for custom_exceptions only once #1742

Merged
merged 2 commits into from May 31, 2012

Conversation

takluyver
Copy link
Member

As reported on the mailing list, setting a custom exception handler which does something before displaying the default traceback leads to unexpected recursion.

We already catch custom exceptions in run_code and call the custom handler, but we were checking for them again in showtraceback. This just removes the second check, so custom exception handlers can safely call showtraceback().

This is a slight API change - previously, calling showtraceback would dispatch the custom exception handler if the exception type exactly matched one of those specified (not a subclass). Now it will ignore custom exception handlers. However, I think this change is more intuitive (Min's example code on the mailing list assumed it would work this way), and the use case is reasonable.

I'll look at adding a test for this later.

@minrk
Copy link
Member

minrk commented May 31, 2012

Is there an easy way to test?

@takluyver
Copy link
Member Author

Good point, I've added a test.

@takluyver
Copy link
Member Author

Test results for commit 67f2d22 merged into master
Platform: linux2

  • python2.7: OK (libraries not available: pymongo wx wx.aui)
  • python3.2: OK (libraries not available: pymongo wx wx.aui)

Not available for testing: python2.6, python3.1

minrk added a commit that referenced this pull request May 31, 2012
Check for custom_exceptions only once


We already catch custom exceptions in run_code and call the custom handler, but we were checking for them again in showtraceback. This just removes the second check, so custom exception handlers can safely call showtraceback().
@minrk minrk merged commit de0b095 into ipython:master May 31, 2012
mattvonrocketstein pushed a commit to mattvonrocketstein/ipython that referenced this pull request Nov 3, 2014
Check for custom_exceptions only once


We already catch custom exceptions in run_code and call the custom handler, but we were checking for them again in showtraceback. This just removes the second check, so custom exception handlers can safely call showtraceback().
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.

None yet

2 participants