Message152947
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. |
|
Date |
User |
Action |
Args |
2012-02-09 15:07:18 | Dima.Tisnek | set | recipients:
+ Dima.Tisnek, pitrou |
2012-02-09 15:07:18 | Dima.Tisnek | set | messageid: <1328800038.58.0.378315403366.issue13976@psf.upfronthosting.co.za> |
2012-02-09 15:07:17 | Dima.Tisnek | link | issue13976 messages |
2012-02-09 15:07:17 | Dima.Tisnek | create | |
|