You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
so far all tests i've tried with the lua 5.1 testsuite have failed either because it didnt work or worked improperly
How to replicate:
Download the lua 5.1 testsuite
Download cli-python-lua
Make sure to enable all the features or the features you need in python-lua with cli-python-lua
Run one of the lua tests using cli-python-lua
Thanks for your interest in the project. I have recently been making quite a few changes to the project. I may have fixed some of the things you encountered. However, I didn't check everything you wrote yet.
What I can say is this:
The C code that was in there, was the start of my work to port the entire project to C. I have just made that work properly, and it is now the way it should be used.
The code no longer supports choosing your own Lua version (and perhaps it didn't when you tested it; that may have been the issue). It now only supports Lua 5.4.
Porting to other Lua versions (and probably also other variants such as Luau) is likely pretty easy (just link to the other Lua library), but possibly it requires some changes to the code. I didn't check.
Your cli-python-lua code contains some bugs, which may be the cause of (some of) the test failures. I may report them there if I have time.
The new code has a test script included, which tests most of the possible interactions between Lua and Python. You can use it as an example for how things should work.
Please let me know if things work properly for you, and also if they don't.
the main.lua test fails in the lua 5.4 test suite using cli-python-lua with ValueError: [string "# testing special comment on first line..."]:1: unexpected symbol near '#'
also the sort.lua test in the lua 5.4 testsuite fails because of File "", line 322, in decode
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xe1 in position 7892: invalid continuation byte
if i'm correct
the main.lua test fails in the lua 5.4 test suite using cli-python-lua with ValueError: [string "# testing special comment on first line..."]:1: unexpected symbol near '#'
This is a problem with your script. When you say that you are running a file, you are really reading the file into a string and running that.
Lua only support a first line starting with # when running a file, not when running a string. So because you are running it as a string, the error is expected and correct.
The solution is to use the Lua.run_file() function instead of the Lua.run() function.
also the sort.lua test in the lua 5.4 testsuite fails because of File "", line 322, in decode UnicodeDecodeError: 'utf-8' codec can't decode byte 0xe1 in position 7892: invalid continuation byte if i'm correct
This is also a problem with your code. You are reading the contents of the file as text, which means Python will parse the contents of the file as UTF-8. If the file isn't valid UTF-8 (as is the case with sort.lua), it will result in an error. Note that this error happens before calling Lua.run(), so it is obviously not in my code.
There are two possible solutions for this. The first is to use Lua.run_file(), because that will correctly parse the non-UTF-8 file. The other is to send a bytes object instead of a str. However, that second option is currently not supported. I think I will add support for it in the future, because it seems like a nice feature to support.
Activity
inceptorprogrammer commentedon May 31, 2025
You can also do os.execute and io.popen and they wont work
wijnen commentedon Jun 7, 2025
Hi,
Thanks for your interest in the project. I have recently been making quite a few changes to the project. I may have fixed some of the things you encountered. However, I didn't check everything you wrote yet.
What I can say is this:
The new code has a test script included, which tests most of the possible interactions between Lua and Python. You can use it as an example for how things should work.
Please let me know if things work properly for you, and also if they don't.
inceptorprogrammer commentedon Jun 7, 2025
let me see if the lua 5.4 testsuite works
inceptorprogrammer commentedon Jun 7, 2025
the main.lua test fails in the lua 5.4 test suite using cli-python-lua with ValueError: [string "# testing special comment on first line..."]:1: unexpected symbol near '#'
inceptorprogrammer commentedon Jun 7, 2025
also the sort.lua test in the lua 5.4 testsuite fails because of File "", line 322, in decode
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xe1 in position 7892: invalid continuation byte
if i'm correct
inceptorprogrammer commentedon Jun 7, 2025
You can replicate these by downloading the lua 5.4.0 test suite and running it using cli-python-lua
inceptorprogrammer commentedon Jun 7, 2025
however this is all being done with a old version of python-lua and cli-python-lua so let me try it on a newer version
inceptorprogrammer commentedon Jun 7, 2025
python-lua still fails on main.lua and sort.lua on the lua 5.4.0 testsuite with the same errors
wijnen commentedon Jun 8, 2025
This is a problem with your script. When you say that you are running a file, you are really reading the file into a string and running that.
Lua only support a first line starting with # when running a file, not when running a string. So because you are running it as a string, the error is expected and correct.
The solution is to use the Lua.run_file() function instead of the Lua.run() function.
wijnen commentedon Jun 8, 2025
This is also a problem with your code. You are reading the contents of the file as text, which means Python will parse the contents of the file as UTF-8. If the file isn't valid UTF-8 (as is the case with sort.lua), it will result in an error. Note that this error happens before calling Lua.run(), so it is obviously not in my code.
There are two possible solutions for this. The first is to use Lua.run_file(), because that will correctly parse the non-UTF-8 file. The other is to send a bytes object instead of a str. However, that second option is currently not supported. I think I will add support for it in the future, because it seems like a nice feature to support.
wijnen commentedon Jun 8, 2025
I have implemented it right away. :-) The current code supports running bytes objects as well.
inceptorprogrammer commentedon Jun 8, 2025
I didn't know Lua.run_file() existed thanks for telling me I'll rewrite my code and try the lua 5.4 testsuite again