]> granicus.if.org Git - python/commitdiff
fixes issue #1522237, bad init check in _threading_local
authorJack Diederich <jackdied@gmail.com>
Mon, 22 Feb 2010 19:55:22 +0000 (19:55 +0000)
committerJack Diederich <jackdied@gmail.com>
Mon, 22 Feb 2010 19:55:22 +0000 (19:55 +0000)
Lib/_threading_local.py
Lib/test/test_threading_local.py

index 243d84ef7caf08fa14c083045e993dc8bf812332..e953597005eba7fd9312d7a6e098ee160d2ab95f 100644 (file)
@@ -155,7 +155,7 @@ class _localbase(object):
         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
index 93ec12ba418e4df13830d3bfc59a2539e7b9d28f..ab3b358245b54ac7b1ba5b48991be119b50208a1 100644 (file)
@@ -105,6 +105,21 @@ class ThreadingLocalTest(unittest.TestCase):
 
         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()