erg-lang / erg

A statically typed language compatible with Python
http://erg-lang.org
Apache License 2.0
2.65k stars 55 forks source link

RuntimeError: Bad code object in .pyc file #296

Closed stasoid closed 1 year ago

stasoid commented 1 year ago

Describe the bug?

Erg fails with RuntimeError: Bad code object in .pyc file and deletes code file:

$ echo 'print!0' > tst
$ cat tst
print!0
$ erg tst
RuntimeError: Bad code object in .pyc file
$ cat tst
cat: tst: No such file or directory

I tried other versions, 0.5.8 is the latest version that I am able to compile that doesn't have this bug:

0.5.12 this error
0.5.11 this error
0.5.10 build error
0.5.9  build error
0.5.8  good

Erg version

0.5.13 also tested latest dev version

Python version

3.8.10

OS

Ubuntu 20.04 (On Windows 10 through WSL2)

mtshiba commented 1 year ago

This script ran successfully in Python 3.10 and 3.11. Although not explicitly stated in the documentation, Python 3.8 is "tier 2 support", which is more unstable than 3.10 or 3.11.

We will work on fixing this, but for the time being, please run Erg using the Python version shown above.

Alternatively, you can convert Erg scripts to Python scripts with the --mode transpile option. This feature is still experimental, but with this feature, you can run scripts with any Python version (>=3).

mtshiba commented 1 year ago

The bug that caused files to be deleted when no extension was added has been fixed.

stasoid commented 1 year ago

Yes, it works with Python 3.11, thank you.