From 1ce6136018b6e1447368e1cc9ec3b70b0dd8729d Mon Sep 17 00:00:00 2001 From: Jack Diederich Date: Mon, 22 Feb 2010 19:55:22 +0000 Subject: fixes issue #1522237, bad init check in _threading_local --- Lib/_threading_local.py | 2 +- Lib/test/test_threading_local.py | 15 +++++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/Lib/_threading_local.py b/Lib/_threading_local.py index 243d84e..e953597 100644 --- a/Lib/_threading_local.py +++ b/Lib/_threading_local.py @@ -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 diff --git a/Lib/test/test_threading_local.py b/Lib/test/test_threading_local.py index 93ec12b..ab3b358 100644 --- a/Lib/test/test_threading_local.py +++ b/Lib/test/test_threading_local.py @@ -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() -- cgit v0.12