mirror of
https://github.com/python/cpython.git
synced 2024-11-27 11:55:13 +08:00
fixes issue #1522237, bad init check in _threading_local
This commit is contained in:
parent
dc8c2adad6
commit
561d5aa47f
@ -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
|
||||
|
@ -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()
|
||||
|
Loading…
Reference in New Issue
Block a user