Repro:
>>> exec("""
... import msgspec
... S = msgspec.defstruct("S", [("x", int)])
... msgspec.convert({"x": 1}, type=S)
... """, {}, {})
Traceback (most recent call last):
File "<python-input-8>", line 1, in <module>
exec("""
~~~~^^^^
import msgspec
^^^^^^^^^^^^^^
S = msgspec.defstruct("S", [("x", int)])
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
msgspec.convert({"x": 1}, type=S)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
""", {}, {})
^^^^^^^^^^^^
File "<string>", line 4, in <module>
File "/Users/sobolev/Desktop/msgspec/src/msgspec/_utils.py", line 136, in get_class_annotations
cls_globals = getattr(sys.modules.get(cls.__module__, None), "__dict__", {})
^^^^^^^^^^^^^^
AttributeError: __module__. Did you mean '.__reduce__' instead of '.__module__'?
This happened to me while using pyperf that does a similar thing.
I will send a PR with the fix.
Repro:
This happened to me while using
pyperfthat does a similar thing.I will send a PR with the fix.