From fa16759dc37fa313a2a607974d51d161c8ba5ea6 Mon Sep 17 00:00:00 2001 From: Jelle Zijlstra Date: Tue, 11 Jan 2022 20:29:05 -0800 Subject: [PATCH] Ignore more exceptions in stubtest (#11946) See python/typeshed#6801. --- mypy/stubtest.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/mypy/stubtest.py b/mypy/stubtest.py index 0a05cf210409..cb005c4bd52c 100644 --- a/mypy/stubtest.py +++ b/mypy/stubtest.py @@ -269,11 +269,14 @@ def verify_typeinfo( mangled_entry = "_{}{}".format(stub.name, entry) stub_to_verify = next((t.names[entry].node for t in stub.mro if entry in t.names), MISSING) assert stub_to_verify is not None - yield from verify( - stub_to_verify, - getattr(runtime, mangled_entry, MISSING), - object_path + [entry], - ) + try: + runtime_attr = getattr(runtime, mangled_entry, MISSING) + except Exception: + # Catch all exceptions in case the runtime raises an unexpected exception + # from __getattr__ or similar. + pass + else: + yield from verify(stub_to_verify, runtime_attr, object_path + [entry]) def _verify_static_class_methods(