summaryrefslogtreecommitdiffstats
path: root/Lib/test
diff options
context:
space:
mode:
authorTim Peters <tim.peters@gmail.com>2006-07-19 00:03:19 (GMT)
committerTim Peters <tim.peters@gmail.com>2006-07-19 00:03:19 (GMT)
commit112aad3630975da8a949291faaab5c578442e9d2 (patch)
tree895182e4ff00e18eeba021799b20aca92f5e0f7c /Lib/test
parent73a9eade1c864a5351c4a33cd20983f11dd79d94 (diff)
downloadcpython-112aad3630975da8a949291faaab5c578442e9d2.zip
cpython-112aad3630975da8a949291faaab5c578442e9d2.tar.gz
cpython-112aad3630975da8a949291faaab5c578442e9d2.tar.bz2
SF bug 1524317: configure --without-threads fails to build
Moved the code for _PyThread_CurrentFrames() up, so it's no longer in a huge "#ifdef WITH_THREAD" block (I didn't realize it /was/ in one). Changed test_sys's test_current_frames() so it passes with or without thread supported compiled in. Note that test_sys fails when Python is compiled without threads, but for an unrelated reason (the old test_exit() fails with an indirect ImportError on the `thread` module). There are also other unrelated compilation failures without threads, in extension modules (like ctypes); at least the core compiles again. Do we really support --without-threads? If so, there are several problems remaining.
Diffstat (limited to 'Lib/test')
-rw-r--r--Lib/test/test_sys.py22
1 files changed, 22 insertions, 0 deletions
diff --git a/Lib/test/test_sys.py b/Lib/test/test_sys.py
index bb86c88..9d4bbe7 100644
--- a/Lib/test/test_sys.py
+++ b/Lib/test/test_sys.py
@@ -239,6 +239,19 @@ class SysModuleTest(unittest.TestCase):
# sys._current_frames() is a CPython-only gimmick.
def test_current_frames(self):
+ have_threads = True
+ try:
+ import thread
+ except ImportError:
+ have_threads = False
+
+ if have_threads:
+ self.current_frames_with_threads()
+ else:
+ self.current_frames_without_threads()
+
+ # Test sys._current_frames() in a WITH_THREADS build.
+ def current_frames_with_threads(self):
import threading, thread
import traceback
@@ -298,6 +311,15 @@ class SysModuleTest(unittest.TestCase):
leave_g.set()
t.join()
+ # Test sys._current_frames() when thread support doesn't exist.
+ def current_frames_without_threads(self):
+ # Not much happens here: there is only one thread, with artificial
+ # "thread id" 0.
+ d = sys._current_frames()
+ self.assertEqual(len(d), 1)
+ self.assert_(0 in d)
+ self.assert_(d[0] is sys._getframe())
+
def test_attributes(self):
self.assert_(isinstance(sys.api_version, int))
self.assert_(isinstance(sys.argv, list))