Skip to content

Conversation

@minrk
Copy link
Member

@minrk minrk commented Jan 6, 2016

faulthandler requires access to C-level FD, which doesn't make sense for forwarded stdout/stderr. Patch default to be underlying __stderr__ instead of overridden stderr.

closes #91

@Carreau
Copy link
Member

Carreau commented Jan 6, 2016

Wouldn't that fail on Python 2 that have no fault handler module ?

@minrk
Copy link
Member Author

minrk commented Jan 6, 2016

Yup, forgot about Python 2.

@Carreau
Copy link
Member

Carreau commented Jan 6, 2016

+1.

@fperez
Copy link
Member

fperez commented Jan 7, 2016

The patch as it stands right now looks good, I just wonder if it wouldn't be a good idea to add a small test that makes the actual faultahndler.enable() call, to increase our chances of catching any errors in case the underlying API evolves in the future. Since we're basically adding a pass-through, our patch is sensitive to changes in that API.

Though given Python's lack of formal interface description and testing, we can't really catch forward changes, so perhaps there isn't that much value to it. They are unlikely to introduce backwards-incompatible changes, and short of adding a signature-inspection warning using inspect, this may be of little value.

Thoughts?

@minrk
Copy link
Member Author

minrk commented Jan 7, 2016

I thought about making it *args, **kwargs so it would be forward-compatible, but then the logic for handling file as positional or kwarg seemed like more complexity than it should have. I'm not sure how a test would cover the future change, though, since it would be a backward-compatible addition that's most likely to be missed, and a test wouldn't catch that.

@fperez
Copy link
Member

fperez commented Jan 7, 2016

Yes, that was exactly my concern, which is why I'm wondering if adding a test would be kind of a pointless exercise in putting in tests for their own sake.

Maybe we should just leave it as-is, and instead just add an explicit note as a comment in the code, just a simple:

# Warning: this is a monkeypatch of `faulthandler.enable`, watch for possible 
# updates to the upstream API and update accordingly: 
# https://docs.python.org/3/library/faulthandler.html#faulthandler.enable

Better than putting in code that isn't really adding value.

minrk added 2 commits January 8, 2016 10:21
fault handler requires access to C-level FD, which doesn't make sense for forwarded stdout/stderr.
Patch default to be underlying `__stderr__` instead of overridden `stderr`.
@minrk
Copy link
Member Author

minrk commented Jan 8, 2016

Added your comment, a smoke test, and passthrough of any added kwargs, which should cover it for a long time, at least.

@fperez
Copy link
Member

fperez commented Jan 10, 2016

OK, this is as much as we can reasonably do on this. Thanks! Merging.

fperez added a commit that referenced this pull request Jan 10, 2016
patch faulthandler defaults to underlying stderr.

This redirects faulthandler to a real file descriptor instead of a zmq socket, so that in the event of a hard C-level crash, traceback data can still get logged.

Closes #91.
@fperez fperez merged commit c555382 into ipython:master Jan 10, 2016
@minrk minrk modified the milestone: 4.3 Feb 25, 2016
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.

faulthandler.enable() fails with IOError

3 participants