Allow instance and class checks for special stdlib modules. The abc and functools modules indiscriminately call isinstance() and issubclass() on the whole MRO of a user class, which may contain protocols.
(depth=2)
| 1940 | return None |
| 1941 | |
| 1942 | def _allow_reckless_class_checks(depth=2): |
| 1943 | """Allow instance and class checks for special stdlib modules. |
| 1944 | |
| 1945 | The abc and functools modules indiscriminately call isinstance() and |
| 1946 | issubclass() on the whole MRO of a user class, which may contain protocols. |
| 1947 | """ |
| 1948 | # gh-136047: When `_abc` module is not available, `_py_abc` is required to |
| 1949 | # allow `_py_abc.ABCMeta` fallback. |
| 1950 | return _caller(depth) in {'abc', '_py_abc', 'functools', None} |
| 1951 | |
| 1952 | |
| 1953 | _PROTO_ALLOWLIST = { |
no test coverage detected
searching dependent graphs…