diff options
author | Victor Stinner <victor.stinner@haypocalc.com> | 2011-04-30 12:53:09 (GMT) |
---|---|---|
committer | Victor Stinner <victor.stinner@haypocalc.com> | 2011-04-30 12:53:09 (GMT) |
commit | d5c355ccc70d011ef2010537838d9a82e24b2b80 (patch) | |
tree | 93cd12a87150e673d0a8b16c04ffcaff16fea3aa /Lib | |
parent | fab6c70770c7c895a4dbd898a963e2c52da72c04 (diff) | |
download | cpython-d5c355ccc70d011ef2010537838d9a82e24b2b80.zip cpython-d5c355ccc70d011ef2010537838d9a82e24b2b80.tar.gz cpython-d5c355ccc70d011ef2010537838d9a82e24b2b80.tar.bz2 |
Issue #11223: Replace threading._info() by sys.thread_info
Diffstat (limited to 'Lib')
-rw-r--r-- | Lib/_dummy_thread.py | 3 | ||||
-rw-r--r-- | Lib/test/test_os.py | 13 | ||||
-rw-r--r-- | Lib/test/test_sys.py | 8 | ||||
-rw-r--r-- | Lib/test/test_threading.py | 12 | ||||
-rw-r--r-- | Lib/test/test_threadsignals.py | 5 | ||||
-rw-r--r-- | Lib/threading.py | 3 |
6 files changed, 16 insertions, 28 deletions
diff --git a/Lib/_dummy_thread.py b/Lib/_dummy_thread.py index f2465a9..13b1f26 100644 --- a/Lib/_dummy_thread.py +++ b/Lib/_dummy_thread.py @@ -149,6 +149,3 @@ def interrupt_main(): else: global _interrupt _interrupt = True - -def info(): - return {'name': 'dummy'} diff --git a/Lib/test/test_os.py b/Lib/test/test_os.py index 5432412..aa9ff5d 100644 --- a/Lib/test/test_os.py +++ b/Lib/test/test_os.py @@ -27,15 +27,10 @@ except ImportError: # and unmaintained) linuxthreads threading library. There's an issue # when combining linuxthreads with a failed execv call: see # http://bugs.python.org/issue4970. -USING_LINUXTHREADS = False -if threading: - info = threading._info() - try: - pthread_version = info['pthread_version'] - except KeyError: - pass - else: - USING_LINUXTHREADS = pthread_version.startswith("linuxthreads") +if hasattr(sys, 'thread_info') and sys.thread_info.version: + USING_LINUXTHREADS = sys.thread_info.version.startswith("linuxthreads") +else: + USING_LINUXTHREADS = False # Tests creating TESTFN class FileTests(unittest.TestCase): diff --git a/Lib/test/test_sys.py b/Lib/test/test_sys.py index e18019c..61b2676 100644 --- a/Lib/test/test_sys.py +++ b/Lib/test/test_sys.py @@ -474,6 +474,14 @@ class SysModuleTest(unittest.TestCase): if not sys.platform.startswith('win'): self.assertIsInstance(sys.abiflags, str) + @unittest.skipUnless(hasattr(sys, 'thread_info'), + 'Threading required for this test.') + def test_thread_info(self): + info = sys.thread_info + self.assertTrue(len(info), 3) + self.assertIn(info.name, ('nt', 'os2', 'pthread', 'solaris', None)) + self.assertIn(info.lock, ('semaphore', 'mutex+cond', None)) + def test_43581(self): # Can't use sys.stdout, as this is a StringIO object when # the test runs under regrtest. diff --git a/Lib/test/test_threading.py b/Lib/test/test_threading.py index fd63d39..66a04c8 100644 --- a/Lib/test/test_threading.py +++ b/Lib/test/test_threading.py @@ -719,16 +719,6 @@ class BarrierTests(lock_tests.BarrierTests): barriertype = staticmethod(threading.Barrier) -class MiscTests(unittest.TestCase): - def test_info(self): - info = threading._info() - self.assertIn(info['name'], - 'nt os2 pthread solaris'.split()) - if info['name'] == 'pthread': - self.assertIn(info['lock_implementation'], - ('semaphore', 'mutex+cond')) - - def test_main(): test.support.run_unittest(LockTests, PyRLockTests, CRLockTests, EventTests, ConditionAsRLockTests, ConditionTests, @@ -736,7 +726,7 @@ def test_main(): ThreadTests, ThreadJoinOnShutdown, ThreadingExceptionTests, - BarrierTests, MiscTests, + BarrierTests, ) if __name__ == "__main__": diff --git a/Lib/test/test_threadsignals.py b/Lib/test/test_threadsignals.py index b0bc607..f975a75 100644 --- a/Lib/test/test_threadsignals.py +++ b/Lib/test/test_threadsignals.py @@ -14,9 +14,8 @@ if sys.platform[:3] in ('win', 'os2') or sys.platform=='riscos': process_pid = os.getpid() signalled_all=thread.allocate_lock() -info = thread.info() -USING_PTHREAD_COND = (info['name'] == 'pthread' - and info['lock_implementation'] == 'mutex+cond') +USING_PTHREAD_COND = (sys.thread_info.name == 'pthread' + and sys.thread_info.lock == 'mutex+cond') def registerSignals(for_usr1, for_usr2, for_alrm): usr1 = signal.signal(signal.SIGUSR1, for_usr1) diff --git a/Lib/threading.py b/Lib/threading.py index 28c2146..fafe779 100644 --- a/Lib/threading.py +++ b/Lib/threading.py @@ -19,7 +19,7 @@ from collections import deque __all__ = ['active_count', 'Condition', 'current_thread', 'enumerate', 'Event', 'Lock', 'RLock', 'Semaphore', 'BoundedSemaphore', 'Thread', 'Barrier', - 'Timer', 'setprofile', 'settrace', 'local', 'stack_size', '_info'] + 'Timer', 'setprofile', 'settrace', 'local', 'stack_size'] # Rename some stuff so "from threading import *" is safe _start_new_thread = _thread.start_new_thread @@ -31,7 +31,6 @@ try: except AttributeError: _CRLock = None TIMEOUT_MAX = _thread.TIMEOUT_MAX -_info = _thread.info del _thread |