lihaoyi/macropy

macropy.activate fails in Python 3.10.2

danielshub opened this issue · 4 comments

I am unable to use macropy.activate from version 1.1.0b2 in Python 3.10.2 on Arch Linux. When running import macropy.activate I expected Python to cleanly import the package, but instead it gives an error related to lineno.

$ python
Python 3.10.2 (main, Jan 15 2022, 19:56:27) [GCC 11.1.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import macropy.activate
Error while compiling file /usr/lib/python3.10/site-packages/macropy/core/hquotes.py
Traceback (most recent call last):
  File "/usr/lib/python3.10/site-packages/macropy/core/import_hooks.py", line 113, in expand_macros
    return compile(tree, filename, "exec"), new_tree
TypeError: required field "lineno" missing from alias
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python3.10/site-packages/macropy/activate.py", line 4, in <module>
    macropy.activate()
  File "/usr/lib/python3.10/site-packages/macropy/__init__.py", line 18, in activate
    from .core import hquotes  # noqa
  File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1002, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 945, in _find_spec
  File "/usr/lib/python3.10/site-packages/macropy/core/import_hooks.py", line 147, in find_spec
    code, tree = self.expand_macros(source, origin, spec)
  File "/usr/lib/python3.10/site-packages/macropy/core/import_hooks.py", line 113, in expand_macros
    return compile(tree, filename, "exec"), new_tree
TypeError: required field "lineno" missing from alias

I'm running into the same error here, which prevents Psychopy from running. I don't know how to debug this...

@DestyNova I got the problem via PsychoPy/javascripthon also:
https://discourse.psychopy.org/t/what-is-the-state-of-python-3-10-support/27303
https://discourse.psychopy.org/t/psychopy-2021-2-3-1-fails-to-start/27067

The solution for PsychoPy/javascripthon is to use the unreleased version of javascripthon that does not depend on macopy (https://github.com/metapensiero/metapensiero.pj/blob/master/CHANGES.rst)

Thanks @danielshub -- I was falling down the rabbit hole of debugging Macropy but this sounds like a better solution 👍

I've opened #108 which addresses this problem.