Issue1667

classification
Title: thread.local subclasses with constructor params fail
Type: behaviour Severity: normal
Components: Core Versions: 2.5.2b1
Milestone:
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: kellyc2702, otmarhumbel, pjenvey, zyasoft
Priority: Keywords: patch

Created on 2010-10-22.03:12:42 by kellyc2702, last changed 2011-01-21.01:19:40 by pjenvey.

Files
File name Uploaded Description Edit Remove
thread_local_test.py kellyc2702, 2010-10-22.03:12:40
issue1667.patch kellyc2702, 2010-10-22.16:26:36 Patch
thread_local_test.py kellyc2702, 2010-10-22.16:27:26 Improved test case
thread_local_test.py kellyc2702, 2010-10-22.16:43:40 Test case version 3
issue1667.patch kellyc2702, 2010-10-22.19:52:15 Updated patch
1667-patch.txt otmarhumbel, 2011-01-20.21:45:54 fix and unit test
Messages
msg6197 (view) Author: Kelly Campbell (kellyc2702) Date: 2010-10-22.03:12:40
Attached test case passes on python, fails with exception on jython 2.5.2rc1:

Exception in thread Thread:Traceback (most recent call last):
  File "/opt/jython/jython2.5.2rc1/Lib/threading.py", line 179, in _Thread__bootstrap
    self.run()
  File "thread_local_test.py", line 16, in run
    self.stuff.stuff = self.name
TypeError: __init__() takes at least 2 arguments (1 given)

It doesn't have the exception if you remove the call to local.__init__(self) on line 5. So the args within PyLocal are getting reset to empty during that call.
msg6198 (view) Author: Kelly Campbell (kellyc2702) Date: 2010-10-22.16:26:35
Here's a patch. This patch also removes the unnecessary synchronization.
msg6199 (view) Author: Kelly Campbell (kellyc2702) Date: 2010-10-22.16:27:26
And here's an improved test case.
msg6200 (view) Author: Kelly Campbell (kellyc2702) Date: 2010-10-22.16:43:40
Sorry, found an issue. Ignore the patch. The test case wasn't complete enough and I didn't fully understand how python thread locals differ from java's. New test case which fails with my patch attached.
msg6201 (view) Author: Kelly Campbell (kellyc2702) Date: 2010-10-22.19:52:15
I think this new patch handles the issue correctly now.
msg6312 (view) Author: Kelly Campbell (kellyc2702) Date: 2011-01-05.20:01:43
ping? this is a simple bug with test case and patch.
msg6328 (view) Author: Oti Humbel (otmarhumbel) Date: 2011-01-20.21:45:54
1667-patch.txt contains Kelly's fix and test (transformed into a unit test)
msg6330 (view) Author: Philip Jenvey (pjenvey) Date: 2011-01-21.01:19:39
I committed a different fix for this in r7186

the orig. patch still caused this.keywords to be overwritten with bad values. oddly enough that didn't break the tests but I think it could have broken something at some point

Instead I moved the __init__ code into __new__ which is what CPython does
History
Date User Action Args
2011-01-21 01:19:40pjenveysetstatus: open -> closed
nosy: + pjenvey, zyasoft
resolution: fixed
messages: + msg6330
2011-01-20 21:45:55otmarhumbelsetfiles: + 1667-patch.txt
nosy: + otmarhumbel
messages: + msg6328
2011-01-05 20:01:43kellyc2702setmessages: + msg6312
2010-10-22 19:52:16kellyc2702setfiles: + issue1667.patch
messages: + msg6201
2010-10-22 16:43:40kellyc2702setfiles: + thread_local_test.py
messages: + msg6200
2010-10-22 16:27:26kellyc2702setfiles: + thread_local_test.py
messages: + msg6199
2010-10-22 16:26:36kellyc2702setfiles: + issue1667.patch
keywords: + patch
messages: + msg6198
2010-10-22 03:12:42kellyc2702create