Discussion:
[Python-3000-checkins] r66126 - in python/branches/py3k: Doc/library/threading.rst Lib/test/test_threading.py Lib/threading.py Misc/NEWS
benjamin.peterson
2008-09-01 23:09:31 UTC
Permalink
Author: benjamin.peterson
Date: Tue Sep 2 01:09:31 2008
New Revision: 66126

Log:
remove the deprecation warnings for the old threading API; update the docs

Reviewer: Benjamin Peterson


Modified:
python/branches/py3k/Doc/library/threading.rst
python/branches/py3k/Lib/test/test_threading.py
python/branches/py3k/Lib/threading.py
python/branches/py3k/Misc/NEWS

Modified: python/branches/py3k/Doc/library/threading.rst
==============================================================================
--- python/branches/py3k/Doc/library/threading.rst (original)
+++ python/branches/py3k/Doc/library/threading.rst Tue Sep 2 01:09:31 2008
@@ -14,11 +14,9 @@

.. note::

- Some ``camelCase`` names have been converted to their underscored
- equivalents. Others have been replaced by properties. Using the old methods
- in 2.6 will trigger a :exc:`DeprecationWarning` when Python is run with the
- :option:`-3` flag and a full :exc:`DeprecationWarning` in 3.0. The old names
- will be removed early in the 3.x series.
+ While they are not listed below, the ``camelCase`` names used for some
+ methods and functions in this module in the Python 2.x series are still
+ supported by this module.

This module defines the following functions and objects:


Modified: python/branches/py3k/Lib/test/test_threading.py
==============================================================================
--- python/branches/py3k/Lib/test/test_threading.py (original)
+++ python/branches/py3k/Lib/test/test_threading.py Tue Sep 2 01:09:31 2008
@@ -323,44 +323,18 @@
msg=('%d references still around' %
sys.getrefcount(weak_raising_cyclic_object())))

- def test_pep8ified_threading(self):
- def check(_, w, msg):
- self.assertEqual(str(w.message), msg)
-
+ def test_old_threading_api(self):
+ # Just a quick sanity check to make sure the old method names are
+ # still present
t = threading.Thread()
- with catch_warning() as w:
- try:
- del threading.__warningregistry__
- except AttributeError:
- pass
- msg = "isDaemon() is deprecated in favor of the " \
- "Thread.daemon property"
- check(t.isDaemon(), w, msg)
- w.reset()
- msg = "setDaemon() is deprecated in favor of the " \
- "Thread.daemon property"
- check(t.setDaemon(True), w, msg)
- w.reset()
- msg = "getName() is deprecated in favor of the " \
- "Thread.name property"
- check(t.getName(), w, msg)
- w.reset()
- msg = "setName() is deprecated in favor of the " \
- "Thread.name property"
- check(t.setName("name"), w, msg)
- w.reset()
- msg = "isAlive() is deprecated in favor of is_alive()"
- check(t.isAlive(), w, msg)
- w.reset()
- e = threading.Event()
- msg = "isSet() is deprecated in favor of is_set()"
- check(e.isSet(), w, msg)
- w.reset()
- msg = "currentThread() is deprecated in favor of current_thread()"
- check(threading.currentThread(), w, msg)
- w.reset()
- msg = "activeCount() is deprecated in favor of active_count()"
- check(threading.activeCount(), w, msg)
+ t.isDaemon()
+ t.setDaemon(True)
+ t.getName()
+ t.setName("name")
+ t.isAlive()
+ e = threading.Event()
+ e.isSet()
+ threading.activeCount()


class ThreadJoinOnShutdown(unittest.TestCase):

Modified: python/branches/py3k/Lib/threading.py
==============================================================================
--- python/branches/py3k/Lib/threading.py (original)
+++ python/branches/py3k/Lib/threading.py Tue Sep 2 01:09:31 2008
@@ -2,12 +2,22 @@

import sys as _sys
import _thread
-import warnings

from time import time as _time, sleep as _sleep
from traceback import format_exc as _format_exc
from collections import deque

+# Note regarding PEP 8 compliant names
+# This threading model was originally inspired by Java, and inherited
+# the convention of camelCase function and method names from that
+# language. Those originaly names are not in any imminent danger of
+# being deprecated (even for Py3k),so this module provides them as an
+# alias for the PEP 8 compliant names
+# Note that using the new PEP 8 compliant names facilitates substitution
+# with the multiprocessing module, which doesn't provide the old
+# Java inspired names.
+
+
# Rename some stuff so "from threading import *" is safe
__all__ = ['active_count', 'Condition', 'current_thread', 'enumerate', 'Event',
'Lock', 'RLock', 'Semaphore', 'BoundedSemaphore', 'Thread',
@@ -262,6 +272,8 @@
def notify_all(self):
self.notify(len(self._waiters))

+ notifyAll = notify_all
+

def Semaphore(*args, **kwargs):
return _Semaphore(*args, **kwargs)
@@ -341,10 +353,7 @@
def is_set(self):
return self._flag

- def isSet(self):
- warnings.warn("isSet() is deprecated in favor of is_set()",
- DeprecationWarning)
- return self.is_set()
+ isSet = is_set

def set(self):
self._cond.acquire()
@@ -646,10 +655,7 @@
assert self._initialized, "Thread.__init__() not called"
return self._started.is_set() and not self._stopped

- def isAlive(self):
- warnings.warn("isAlive() is deprecated in favor of is_alive()",
- DeprecationWarning)
- return self.is_alive()
+ isAlive = is_alive

@property
def daemon(self):
@@ -665,23 +671,15 @@
self._daemonic = daemonic

def isDaemon(self):
- warnings.warn("isDaemon() is deprecated in favor of the " \
- "Thread.daemon property", DeprecationWarning)
return self.daemon

def setDaemon(self, daemonic):
- warnings.warn("setDaemon() is deprecated in favor of the " \
- "Thread.daemon property", DeprecationWarning)
self.daemon = daemonic

def getName(self):
- warnings.warn("getName() is deprecated in favor of the " \
- "Thread.name property", DeprecationWarning)
return self.name

def setName(self, name):
- warnings.warn("setName() is deprecated in favor of the " \
- "Thread.name property", DeprecationWarning)
self.name = name

# The timer class was contributed by Itamar Shtull-Trauring
@@ -790,9 +788,7 @@
##print "current_thread(): no current thread for", _get_ident()
return _DummyThread()

-def currentThread():
- warnings.warn("currentThread() is deprecated in favor of current_thread()",
- DeprecationWarning)
+currentThread = current_thread

def active_count():
_active_limbo_lock.acquire()
@@ -800,10 +796,7 @@
_active_limbo_lock.release()
return count

-def activeCount():
- warnings.warn("activeCount() is deprecated in favor of active_count()",
- DeprecationWarning)
- return active_count()
+activeCount = active_count

def enumerate():
_active_limbo_lock.acquire()

Modified: python/branches/py3k/Misc/NEWS
==============================================================================
--- python/branches/py3k/Misc/NEWS (original)
+++ python/branches/py3k/Misc/NEWS Tue Sep 2 01:09:31 2008
@@ -60,6 +60,8 @@
Library
-------

+- The deprecation warnings for the camelCase threading API names were removed.
+
Extension Modules
-----------------

Loading...