How to reproduce: put the following code in tmp.py and run exocc on it.
from __future__ import annotations
from exo import proc, config
@config
class Test:
a: f32
@proc
def foo(x: f32):
Test.a = 32.0
x = Test.a
print(foo)
$ exocc tmp.py
Traceback (most recent call last):
File "/Users/yuka/.venv/exo/bin/exocc", line 8, in <module>
sys.exit(main())
^^^^^^
File "/Users/yuka/.venv/exo/lib/python3.12/site-packages/exo/main.py", line 58, in main
for proc in get_procs_from_module(load_user_code(mod))
^^^^^^^^^^^^^^^^^^^
File "/Users/yuka/.venv/exo/lib/python3.12/site-packages/exo/main.py", line 107, in load_user_code
loader.exec_module(user_module)
File "<frozen importlib._bootstrap_external>", line 995, in exec_module
File "<frozen importlib._bootstrap>", line 488, in _call_with_frames_removed
File "/Users/yuka/test/tmp.py", line 4, in <module>
@config
^^^^^^
File "/Users/yuka/.venv/exo/lib/python3.12/site-packages/exo/API.py", line 86, in config
return parse_config(_cls)
^^^^^^^^^^^^^^^^^^
File "/Users/yuka/.venv/exo/lib/python3.12/site-packages/exo/API.py", line 71, in parse_config
body, getsrcinfo = get_ast_from_python(cls)
^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/yuka/.venv/exo/lib/python3.12/site-packages/exo/frontend/pyparser.py", line 47, in get_ast_from_python
rawsrc = inspect.getsource(f)
^^^^^^^^^^^^^^^^^^^^
File "/opt/homebrew/Cellar/python@3.12/3.12.5/Frameworks/Python.framework/Versions/3.12/lib/python3.12/inspect.py", line 1285, in getsource
lines, lnum = getsourcelines(object)
^^^^^^^^^^^^^^^^^^^^^^
File "/opt/homebrew/Cellar/python@3.12/3.12.5/Frameworks/Python.framework/Versions/3.12/lib/python3.12/inspect.py", line 1267, in getsourcelines
lines, lnum = findsource(object)
^^^^^^^^^^^^^^^^^^
File "/opt/homebrew/Cellar/python@3.12/3.12.5/Frameworks/Python.framework/Versions/3.12/lib/python3.12/inspect.py", line 1078, in findsource
file = getsourcefile(object)
^^^^^^^^^^^^^^^^^^^^^
File "/opt/homebrew/Cellar/python@3.12/3.12.5/Frameworks/Python.framework/Versions/3.12/lib/python3.12/inspect.py", line 955, in getsourcefile
filename = getfile(object)
^^^^^^^^^^^^^^^
File "/opt/homebrew/Cellar/python@3.12/3.12.5/Frameworks/Python.framework/Versions/3.12/lib/python3.12/inspect.py", line 924, in getfile
raise TypeError('{!r} is a built-in class'.format(object))
TypeError: <class 'tmp.Test'> is a built-in class
The problem is that cls in parse_config does not have __file__ attribute, and this seems like a known issue in Python ( https://bugs.python.org/issue12920 )
How to reproduce: put the following code in tmp.py and run exocc on it.