Repository navigation
Open
Labels
kind/triageUnclassified issues
Description
Problem Description
Using a dataclass like this:
from dataclasses import dataclass
@dataclass
class C:
x: intleads to an error like this:
Traceback (most recent call last):
File "/script.py", line 200, in <module>
@dataclass
^^^^^^^^^
File "/usr/local/lib/python3.14/dataclasses.py", line 1370, in dataclass
return wrap(cls)
File "/usr/local/lib/python3.14/dataclasses.py", line 1360, in wrap
return _process_class(cls, init, repr, eq, order, unsafe_hash,
frozen, match_args, kw_only, slots,
weakref_slot)
File "/usr/local/lib/python3.14/dataclasses.py", line 943, in _process_class
globals = sys.modules[cls.__module__].__dict__
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'object' object has no attribute '__dict__'. Did you mean: '__dir__'?
This seems to be similar to mkdocs/mkdocs#3141 and demands a similar fix.
A somewhat hacky workaround is to use something like this at the top of your script (this technically sets the wrong module, but still works):
# workaround for dataclass
sys.modules[__name__] = mitmproxySystem Information
Mitmproxy: 12.2.0
Python: 3.14.0
OpenSSL: OpenSSL 3.5.4 30 Sep 2025
Platform: Linux-7.0.11-200.fc44.x86_64-x86_64-with-glibc2.41
Checklist
- This bug affects the latest mitmproxy release.
Metadata
Metadata
Assignees
Labels
kind/triageUnclassified issues
Activity
scripts: fix crash when loading addon scripts that define a dataclass