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

bpo-30125: disable faulthandler in ctypes test_SEH #1237

Merged
merged 1 commit into from
Apr 21, 2017
Merged

bpo-30125: disable faulthandler in ctypes test_SEH #1237

merged 1 commit into from
Apr 21, 2017

Conversation

vstinner
Copy link
Member

Disable faulthandler to run test_SEH() of test_ctypes to prevent the
following log with a traceback:

Windows fatal exception: access violation

@mention-bot
Copy link

@Haypo, thanks for your PR! By analyzing the history of the files in this pull request, we identified @zware, @theller and @serhiy-storchaka to be potential reviewers.

Copy link
Member

@zware zware left a comment

Choose a reason for hiding this comment

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

LGTM, but when could faulthandler be missing? I think you could use support.import_module to simplify things and still have protection from missing faulthandler if it's needed.

@vstinner
Copy link
Member Author

Wait... faulthandler.disable() is broken on Windows: I simply forgot to implement RemoveVectoredExceptionHandler()! I will write a second PR.

@vstinner
Copy link
Member Author

vstinner commented Apr 21, 2017

LGTM, but when could faulthandler be missing?

Other Python implementations may implement ctypes but not faulthandler.

Note: PyPy implements faulthandler, but I don't know if they implemented the Windows exception handler.

@vstinner
Copy link
Member Author

See #1240 for the faulthandler.disable() fix.

@vstinner
Copy link
Member Author

Oh, the first run of test_ctypes using -W failed:

======================================================================
ERROR: test_SEH (ctypes.test.test_win32.FunctionCallTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "C:\projects\cpython\lib\ctypes\test\test_win32.py", line 64, in test_SEH
    faulthandler.enable()
io.UnsupportedOperation: fileno
----------------------------------------------------------------------
Ran 465 tests in 0.922s

But the second run without -W succeeded.

I fixed my change to call enable() with file=sys.stderr.fileno() instead. I should now work in all cases. I also fixed enable() call: pass all_threads=True.

Since the code became more complex than expected, I moved it to a new helper in test.support.

I saw that test.support always import faulthandler, so I removed the try/except ImportError.

Disable faulthandler to run test_SEH() of test_ctypes to prevent the
following log with a traceback:

    Windows fatal exception: access violation

Add support.disable_faulthandler() context manager.
@vstinner vstinner merged commit a36e939 into python:master Apr 21, 2017
@vstinner vstinner deleted the test_SEH branch April 21, 2017 22:31
vstinner added a commit that referenced this pull request Apr 28, 2017
Disable faulthandler to run test_SEH() of test_ctypes to prevent the
following log with a traceback:

    Windows fatal exception: access violation

Add support.disable_faulthandler() context manager.
(cherry picked from commit a36e939)
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.

4 participants