]> 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:46 +0000 (19:55 +0000)
committerJack Diederich <jackdied@gmail.com>
Mon, 22 Feb 2010 19:55:46 +0000 (19:55 +0000)
Lib/_threading_local.py
Lib/test/test_threading_local.py

index 6e8a8d85a796ef8813b2187f064733eca88dbc94..b0edc031cc8c546254fafccd905f91ee90613942 100644 (file)
@@ -154,7 +154,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 f72119bd9c1e55f40fab8fb1883aa786c6822d9f..cd2bed980835ca9718a8f1ee0f6d2484d1ea5bf1 100644 (file)
@@ -106,6 +106,21 @@ class ThreadingLocalTest(unittest.TestCase):
 
         self.assertTrue(passed)
 
+    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()