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

Make -P (pdb) work better with exceptions triggered from events #10634

Merged
merged 1 commit into from Jul 10, 2022

Conversation

jbms
Copy link
Contributor

@jbms jbms commented Jul 4, 2022

Feature or Bugfix

  • Bugfix

Purpose

Previously, if an exception was raised from an event listener, and the
-P option was specified, the debugger would be started not for the
original error but for the ExtensionError wrapping it that was
raised by EventManager.emit. That made it difficult to debug the
error.

With this change, when -P is specified, wrapping of errors in
ExtensionError is disabled, which allows pdb to debug the original
error.

@jbms jbms force-pushed the fix-events-pdb branch 2 times, most recently from 1af2f35 to 8d12970 Compare July 4, 2022 01:19
@AA-Turner
Copy link
Member

+1 on the idea.

Is it possible to implement this without adding a new attribute to Sphinx? The application object already has a really big API.

This would also need a CHANGES entry.

A

@AA-Turner AA-Turner added the type:enhancement enhance or introduce a new feature label Jul 4, 2022
@AA-Turner AA-Turner added this to the 5.1.0 milestone Jul 4, 2022
@jbms
Copy link
Contributor Author

jbms commented Jul 5, 2022

I think it is difficult to avoid making it a parameter to Sphinx.__init__, since some events are emitted by Sphinx.__init__ so it would be too late to enable it later. In principle it could be passed as a separate parameter to EventManager.__init__ by Sphinx.__init__, since currently the variable is only used by EventManager, though I'm not sure that is an improvement, and I think it is possible that we will find other code in Sphinx that is currently wrapping exceptions and needs to be changed (and will then need access to this variable).

Previously, if an exception was raised from an event listener, and the
`-P` option was specified, the debugger would be started not for the
original error but for the `ExtensionError` wrapping it that was
raised by `EventManager.emit`.  That made it difficult to debug the
error.

With this change, when `-P` is specified, wrapping of errors in
`ExtensionError` is disabled, which allows pdb to debug the original
error.
@jbms
Copy link
Contributor Author

jbms commented Jul 5, 2022

I added a changelog entry.

Copy link
Member

@tk0miya tk0miya left a comment

Choose a reason for hiding this comment

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

LGTM :-)

@tk0miya tk0miya merged commit 3db1844 into sphinx-doc:5.x Jul 10, 2022
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 10, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
type:enhancement enhance or introduce a new feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants