summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@gmail.com>2012-07-31 00:55:49 (GMT)
committerVictor Stinner <victor.stinner@gmail.com>2012-07-31 00:55:49 (GMT)
commitd5698cbbcade36d49bb32e797499d1190c38558a (patch)
tree4c743f1ff57018f73dc118ebb08b97edbd83b260 /Lib
parent60622ed12aed572573a95b88428f654e88b8e470 (diff)
downloadcpython-d5698cbbcade36d49bb32e797499d1190c38558a.zip
cpython-d5698cbbcade36d49bb32e797499d1190c38558a.tar.gz
cpython-d5698cbbcade36d49bb32e797499d1190c38558a.tar.bz2
Fix initialization of the faulthandler module
faulthandler requires the importlib if "-X faulthandler" option is present on the command line, so initialize faulthandler after importlib. Add also an unit test.
Diffstat (limited to 'Lib')
-rw-r--r--Lib/test/test_faulthandler.py15
1 files changed, 15 insertions, 0 deletions
diff --git a/Lib/test/test_faulthandler.py b/Lib/test/test_faulthandler.py
index 1138f8f..8c12b21 100644
--- a/Lib/test/test_faulthandler.py
+++ b/Lib/test/test_faulthandler.py
@@ -7,6 +7,7 @@ import signal
import subprocess
import sys
from test import support, script_helper
+from test.script_helper import assert_python_ok
import tempfile
import unittest
@@ -256,6 +257,20 @@ faulthandler._read_null()
finally:
sys.stderr = orig_stderr
+ def test_disabled_by_default(self):
+ # By default, the module should be disabled
+ code = "import faulthandler; print(faulthandler.is_enabled())"
+ rc, stdout, stderr = assert_python_ok("-c", code)
+ stdout = (stdout + stderr).strip()
+ self.assertEqual(stdout, b"False")
+
+ def test_sys_xoptions(self):
+ # Test python -X faulthandler
+ code = "import faulthandler; print(faulthandler.is_enabled())"
+ rc, stdout, stderr = assert_python_ok("-X", "faulthandler", "-c", code)
+ stdout = (stdout + stderr).strip()
+ self.assertEqual(stdout, b"True")
+
def check_dump_traceback(self, filename):
"""
Explicitly call dump_traceback() function and check its output.