File tree 2 files changed +15
-1
lines changed 2 files changed +15
-1
lines changed Original file line number Diff line number Diff line change @@ -369,7 +369,11 @@ def _base_class_object_build(
369
369
# this at least resolves common case such as Exception.args,
370
370
# OSError.errno
371
371
if issubclass (member , Exception ):
372
- instdict = member ().__dict__
372
+ member_object = member ()
373
+ if hasattr (member_object , "__dict__" ):
374
+ instdict = member_object .__dict__
375
+ else :
376
+ raise TypeError
373
377
else :
374
378
raise TypeError
375
379
except TypeError :
Original file line number Diff line number Diff line change 32
32
build_from_import ,
33
33
build_function ,
34
34
build_module ,
35
+ object_build_class ,
35
36
)
36
37
37
38
DUMMY_MOD = build_module ("DUMMY" )
@@ -160,3 +161,12 @@ def mocked_sys_modules_getitem(name: str) -> types.ModuleType | CustomGetattr:
160
161
assert expected_err in caplog .text
161
162
assert not out
162
163
assert not err
164
+
165
+
166
+ def test_missing__dict__ ():
167
+ # This shouldn't raise an exception.
168
+ class TestError (Exception ):
169
+ def __init__ (self ):
170
+ del self .__dict__
171
+
172
+ object_build_class (build_module (_io .__name__ ), TestError )
You can’t perform that action at this time.
0 commit comments