summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBenjamin Peterson <benjamin@python.org>2008-08-18 16:40:03 (GMT)
committerBenjamin Peterson <benjamin@python.org>2008-08-18 16:40:03 (GMT)
commitd8a8972ca955202cb895a48f6d78b17c37f1d1ce (patch)
tree8298f070379f419e516af905f0dfd31fad1c5619
parente5bdccc77b2a0da0b72f4a6ebbc2d9a1a9680dcd (diff)
downloadcpython-d8a8972ca955202cb895a48f6d78b17c37f1d1ce.zip
cpython-d8a8972ca955202cb895a48f6d78b17c37f1d1ce.tar.gz
cpython-d8a8972ca955202cb895a48f6d78b17c37f1d1ce.tar.bz2
change threading.getIdent to a property
This is new in 2.6 so now need to worry about backwards compatibility :)
-rw-r--r--Doc/library/threading.rst8
-rw-r--r--Lib/test/test_threading.py4
-rw-r--r--Lib/threading.py3
-rw-r--r--Misc/NEWS2
4 files changed, 9 insertions, 8 deletions
diff --git a/Doc/library/threading.rst b/Doc/library/threading.rst
index d02b76f..1d929fa 100644
--- a/Doc/library/threading.rst
+++ b/Doc/library/threading.rst
@@ -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
diff --git a/Lib/test/test_threading.py b/Lib/test/test_threading.py
index 44c3336..7c3d90b 100644
--- a/Lib/test/test_threading.py
+++ b/Lib/test/test_threading.py
@@ -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'
diff --git a/Lib/threading.py b/Lib/threading.py
index d88f1be..e1a0b2a 100644
--- a/Lib/threading.py
+++ b/Lib/threading.py
@@ -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
diff --git a/Misc/NEWS b/Misc/NEWS
index 09f1138..7a0838e 100644
--- 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
-------