GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | ||||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | ||||||||||||||||
GeezerVison is showing github.com — `typing.Protocol` implementation means that `isinstance([], collections.abc.Mapping)` can sometimes evaluate to `True` · Issue #105280 · python/cpython Closed Labels 3.12only security fixesonly security fixes3.13only security fixesonly security fixesstdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directorytopic-typingtype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error Description(In very specific circumstances) Bug reportDue to some changes that have been made to the implementation of Minimal repro: >>> import gc, collections.abc, typing >>> gc.disable() >>> try: ... class Foo(collections.abc.Mapping, typing.Protocol): pass ... except TypeError: ... pass ... >>> isinstance([], collections.abc.Mapping) True Why does this happen?! It's because Lines 1905 to 1912 in ce558e6
>>> import gc, collections.abc, typing >>> gc.disable() >>> try: ... class Foo(collections.abc.Mapping, typing.Protocol): pass ... except TypeError: ... pass ... >>> x = collections.abc.Mapping.__subclasses__() >>> x [<class 'collections.abc.MutableMapping'>, <class '__main__.Foo'>] >>> x[-1].__protocol_attrs__ set() The fix is to raise Why does this matter?This might seem like an absurdly specific bug report, but it would be good to see it fixed. It was causing bizarre test failures in the def test_protocols_bad_subscripts(self): T = TypeVar('T') S = TypeVar('S') with self.assertRaises(TypeError): class P(typing.Mapping[T, S], Protocol[T]): pass ...And that final Linked PRsReacted by James Hilton-Balfe Activity
MetadataMetadataAssigneesLabels3.12only security fixesonly security fixes3.13only security fixesonly security fixesstdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directorytopic-typingtype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error ProjectsMilestoneRelationshipsDevelopmentIssue actions | ||||||||||||||||
| You are visitor 01402503 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |