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.

classification
Title: threading.local doesn't support super()
Type: behavior Stage:
Components: None Versions: Python 2.7
process
Status: closed Resolution: not a bug
Dependencies: Superseder:
Assigned To: Nosy List: Dima.Tisnek, pitrou
Priority: normal Keywords:

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:26adminsetgithub: 58184
2012-02-09 15:14:34Dima.Tisneksetstatus: open -> closed
resolution: not a bug
messages: + msg152948
2012-02-09 15:07:18Dima.Tisnekcreate