New submission from Tomasz Trębski <kornicameis...@gmail.com>: Consider code (in attachment) that is being run on Python 3.9. An expected output of such code ought to be:
(typing_extensions.Literal[1], typing_extensions.Literal[0]) (typing_extensions.Literal[True], typing_extensions.Literal[False]) However that's not the case. An output of the code, given that A is declared first, will be: (typing.Literal[1], typing.Literal[0]) (typing.Literal[1], typing.Literal[0]) and if B is declared first we receive: (typing.Literal[True], typing.Literal[False]) (typing.Literal[True], typing.Literal[False]) I believe a reason for that is having `bool` as subclass of `int` and consecutively having `typing._tp_cache` function that declares untyped cache. Indeed changing `cached = functools.lru_cache()(func)` to `cached = functools.lru_cache(typed=True)(func)` makes the linked code immune to A and B deceleration order. ---------- components: ctypes files: scratch_1.py messages: 359822 nosy: Tomasz Trębski priority: normal severity: normal status: open title: Literal[True] interpreted as Literal[1] type: behavior versions: Python 3.9 Added file: https://bugs.python.org/file48835/scratch_1.py _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue39308> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com