[Python-checkins] r78336 - in python/trunk/Lib: _threading_local.py test/test_threading_local.py
jack.diederich
python-checkins at python.org
Mon Feb 22 20:55:22 CET 2010
Author: jack.diederich
Date: Mon Feb 22 20:55:22 2010
New Revision: 78336
Log:
fixes issue #1522237, bad init check in _threading_local
Modified:
python/trunk/Lib/_threading_local.py
python/trunk/Lib/test/test_threading_local.py
Modified: python/trunk/Lib/_threading_local.py
==============================================================================
--- python/trunk/Lib/_threading_local.py (original)
+++ python/trunk/Lib/_threading_local.py Mon Feb 22 20:55:22 2010
@@ -155,7 +155,7 @@
object.__setattr__(self, '_local__args', (args, kw))
object.__setattr__(self, '_local__lock', RLock())
- if args or kw and (cls.__init__ is object.__init__):
+ if (args or kw) and (cls.__init__ is object.__init__):
raise TypeError("Initialization arguments are not supported")
# We need to create the thread dict in anticipation of
Modified: python/trunk/Lib/test/test_threading_local.py
==============================================================================
--- python/trunk/Lib/test/test_threading_local.py (original)
+++ python/trunk/Lib/test/test_threading_local.py Mon Feb 22 20:55:22 2010
@@ -105,6 +105,21 @@
self.assertTrue(passed[0])
+ def test_arguments(self):
+ # Issue 1522237
+ from thread import _local as local
+ from _threading_local import local as py_local
+
+ for cls in (local, py_local):
+ class MyLocal(cls):
+ def __init__(self, *args, **kwargs):
+ pass
+
+ MyLocal(a=1)
+ MyLocal(1)
+ self.assertRaises(TypeError, cls, a=1)
+ self.assertRaises(TypeError, cls, 1)
+
def test_main():
suite = unittest.TestSuite()
More information about the Python-checkins
mailing list