]> granicus.if.org Git - python/commitdiff
change threading.getIdent to a property
authorBenjamin Peterson <benjamin@python.org>
Mon, 18 Aug 2008 16:40:03 +0000 (16:40 +0000)
committerBenjamin Peterson <benjamin@python.org>
Mon, 18 Aug 2008 16:40:03 +0000 (16:40 +0000)
This is new in 2.6 so now need to worry about backwards compatibility :)

Doc/library/threading.rst
Lib/test/test_threading.py
Lib/threading.py
Misc/NEWS

index d02b76f47b6c6cf31de20a5f8dae099fa01112bc..1d929faac665308c7008e70e21f4c81622422c70 100644 (file)
@@ -661,12 +661,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.
 
    .. versionadded:: 2.6
index 44c3336b0af5b419749b3c9129a5ee7641f5cf5c..7c3d90bdd6c5b7fa2d681442b3117217d7ff2b25 100644 (file)
@@ -73,7 +73,7 @@ class ThreadTests(unittest.TestCase):
         for i in range(NUMTASKS):
             t = TestThread("<thread %d>"%i, self, sema, mutex, numrunning)
             threads.append(t)
-            self.failUnlessEqual(t.get_ident(), None)
+            self.failUnlessEqual(t.ident, None)
             self.assert_(re.match('<TestThread\(.*, initial\)>', repr(t)))
             t.start()
 
@@ -82,7 +82,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('<TestThread\(.*, \w+ -?\d+\)>', repr(t)))
         if verbose:
             print 'all tasks done'
index d88f1be4ea37d48a2d069e17a22fe643f1d26888..e1a0b2a73fc8809e4a7de3312c77529a68ec280f 100644 (file)
@@ -663,7 +663,8 @@ class Thread(_Verbose):
 
     setName = _old_api(set_name, "setName")
 
-    def get_ident(self):
+    @property
+    def ident(self):
         assert self.__initialized, "Thread.__init__() not called"
         return self.__ident
 
index 09f1138689802c2d339de12631523004b0e112d9..7a0838e01a23646d51c76ec0d1b05ddb78bd2c15 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -422,7 +422,7 @@ Extension Modules
 
 - Issue #2870: cmathmodule.c compile error.
 
-- Added a threading.Thread.getIdent() method.
+- Added a threading.Thread.ident property.
 
 Library
 -------