Issue1522237
Created on 2006-07-14 00:52 by tony_nelson, last changed 2009-03-30 16:04 by gvanrossum.
| File name |
Uploaded |
Description |
Edit |
Remove |
|
localbase.patch
|
amaury.forgeotdarc,
2009-03-30 13:20
|
|
|
|
|
msg60941 - (view) |
Author: Tony Nelson (tony_nelson) |
Date: 2006-07-14 00:52 |
|
I don't understand _threading_local.py, but I think
that parens are needed below in class _localbase __new__().
if args or kw and (cls.__init__ is object.__init__):
raise TypeError...
should be "(args or kw)", I think, looking at the
related test in _patch().
I'm not quite sure if this is python 2.5, but it is in
trunk.
|
|
msg84507 - (view) |
Author: Daniel Diniz (ajaksu2) |
Date: 2009-03-30 05:07 |
|
It isn't obvious to me that this issue is valid.
Some more context:
class _localbase(object):
__slots__ = '_local__key', '_local__args', '_local__lock'
def __new__(cls, *args, **kw):
self = object.__new__(cls)
key = '_local__key', 'thread.local.' + str(id(self))
object.__setattr__(self, '_local__key', key)
object.__setattr__(self, '_local__args', (args, kw))
object.__setattr__(self, '_local__lock', RLock())
if args or kw and (cls.__init__ is object.__init__):
raise TypeError("Initialization arguments are not supported")
|
|
msg84543 - (view) |
Author: Amaury Forgeot d'Arc (amaury.forgeotdarc) |
Date: 2009-03-30 13:20 |
|
It is still valid:
>>> class MyLocal(local):
... def __init__(self, *args, **kwargs):
... self.args = args
... self.kwargs = kwargs
...
>>> MyLocal(1)
This works when local is thread._local (from thread import _local as
local), but fails when imported from _threading_local (from
_threading_local import local)
See attached patch for the test case (and the fix of course)
|
|
msg84566 - (view) |
Author: Tony Nelson (tony_nelson) |
Date: 2009-03-30 15:40 |
|
Thanks, Amaury. The new test works here on Python2.6.1, failing without
the fix and passing with it. (Passing MyLocal(a=1) and failing
MyLocal(1), as expected.) With the fix, _threading_local.py supports
positional arguments to subclass __init__, as well as keyword arguments.
|
|
msg84571 - (view) |
Author: Guido van Rossum (gvanrossum) |
Date: 2009-03-30 16:04 |
|
Looks good to me. Amaury, can you make sure this lands in 2.6, 2.7, 3.0
and 3.1?
|
|
| Date |
User |
Action |
Args |
| 2009-03-30 16:04:08 | gvanrossum | set | nosy:
+ gvanrossum messages:
+ msg84571
assignee: amaury.forgeotdarc resolution: accepted |
| 2009-03-30 15:40:36 | tony_nelson | set | messages:
+ msg84566 |
| 2009-03-30 13:20:10 | amaury.forgeotdarc | set | files:
+ localbase.patch
nosy:
+ amaury.forgeotdarc messages:
+ msg84543
keywords:
+ needs review, patch |
| 2009-03-30 05:07:44 | ajaksu2 | set | versions:
+ Python 2.6, - Python 2.5 nosy:
+ ajaksu2
messages:
+ msg84507
type: behavior stage: test needed |
| 2006-07-14 00:52:48 | tony_nelson | create | |
|