This issue tracker has been migrated to GitHub ,
and is currently read-only.
For more information,
see the GitHub FAQs in the Python's Developer Guide.
Created on 2012年02月09日 15:07 by Dima.Tisnek, last changed 2022年04月11日 14:57 by admin. This issue is now closed.
| Messages (2) | |||
|---|---|---|---|
| msg152947 - (view) | Author: Dima Tisnek (Dima.Tisnek) * | Date: 2012年02月09日 15:07 | |
import threading
import pprint
class A:
def __init__(self, **kw):
pprint.pprint("a")
super(A, self).__init__()
class B(threading.local, A):
def __init__(self, **kw):
pprint.pprint("b")
super(B, self).__init__()
if __name__ == "__main__":
B()
breaks (prints only b) in python 2. tested 2.7.2
works (prints b, a) in python 3, tested 3.2.2
threading.local is before A on purpose, to have different A attribute in different threads, not shown in the example.
caveat implementor: it may be impossible to support both super().__init__ and explicit threading.local.__init__ at the same time; explicit initialization is used far and wide in legacy code.
|
|||
| msg152948 - (view) | Author: Dima Tisnek (Dima.Tisnek) * | Date: 2012年02月09日 15:14 | |
ah feeling stupid only minutes later. A has to inherit from object() and then it works fine. |
|||
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2022年04月11日 14:57:26 | admin | set | github: 58184 |
| 2012年02月09日 15:14:34 | Dima.Tisnek | set | status: open -> closed resolution: not a bug messages: + msg152948 |
| 2012年02月09日 15:07:18 | Dima.Tisnek | create | |