From 773c17b3e107a23c131974f71d3e2f145ee5203d Mon Sep 17 00:00:00 2001 From: Benjamin Peterson Date: Mon, 18 Aug 2008 16:45:31 +0000 Subject: [PATCH] Merged revisions 65818 via svnmerge from svn+ssh://pythondev@svn.python.org/python/trunk ........ r65818 | benjamin.peterson | 2008-08-18 11:40:03 -0500 (Mon, 18 Aug 2008) | 4 lines change threading.getIdent to a property This is new in 2.6 so now need to worry about backwards compatibility :) ........ --- Doc/library/threading.rst | 8 ++++---- Lib/test/test_threading.py | 4 ++-- Lib/threading.py | 3 ++- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/Doc/library/threading.rst b/Doc/library/threading.rst index 3c5fefd4753..9e41412b52a 100644 --- a/Doc/library/threading.rst +++ b/Doc/library/threading.rst @@ -643,12 +643,12 @@ impossible to detect the termination of alien threads. constructor. -.. method:: Thread.get_ident() +.. attribute:: Thread.ident - Return the 'thread identifier' of this thread or None if the thread has not - been started. This is a nonzero integer. See the :func:`thread.get_ident()` + The 'thread identifier' of this thread or ``None`` if the thread has not been + started. This is a nonzero integer. See the :func:`thread.get_ident()` function. Thread identifiers may be recycled when a thread exits and another - thread is created. The identifier is returned even after the thread has + thread is created. The identifier is available even after the thread has exited. diff --git a/Lib/test/test_threading.py b/Lib/test/test_threading.py index 1abc63f5af4..0a492974d9d 100644 --- a/Lib/test/test_threading.py +++ b/Lib/test/test_threading.py @@ -74,7 +74,7 @@ class ThreadTests(unittest.TestCase): for i in range(NUMTASKS): t = TestThread(""%i, self, sema, mutex, numrunning) threads.append(t) - self.failUnlessEqual(t.get_ident(), None) + self.failUnlessEqual(t.ident, None) self.assert_(re.match('', repr(t))) t.start() @@ -83,7 +83,7 @@ class ThreadTests(unittest.TestCase): for t in threads: t.join(NUMTASKS) self.assert_(not t.is_alive()) - self.failIfEqual(t.get_ident(), 0) + self.failIfEqual(t.ident, 0) self.assert_(re.match('', repr(t))) if verbose: print('all tasks done') diff --git a/Lib/threading.py b/Lib/threading.py index 48321014c2c..ccbd67e7c6b 100644 --- a/Lib/threading.py +++ b/Lib/threading.py @@ -629,7 +629,8 @@ class Thread(_Verbose): assert self._initialized, "Thread.__init__() not called" self._name = str(name) - def get_ident(self): + @property + def ident(self): assert self._initialized, "Thread.__init__() not called" return self._ident