scoder / lupa

Lua in Python
http://pypi.python.org/pypi/lupa
Other
1.02k stars 136 forks source link

Bug with hexchat. #30

Open SoniEx2 opened 10 years ago

SoniEx2 commented 10 years ago

So I was trying to use this with hexchat and this happened:

 >>> import lupa; lua = lupa.LuaRuntime(unpack_returned_tuples=False, encoding=None)
 >>> exec("def x(*args):\n hexchat.prnt(*([x.decode(\"utf-8\") for x in args]))\n\nlua.globals().print = x",globals(),locals())
 >>> lua.eval("print('\\xC2\\xA7')")
 §
 >>> lua.eval("print('\\xC2\\xA7')")
 Traceback (most recent call last):
   File "<string>", line 1, in <module>
   File "lupa/_lupa.pyx", line 203, in lupa._lupa.LuaRuntime.eval (lupa/_lupa.c:3789)
   File "lupa/_lupa.pyx", line 1060, in lupa._lupa.run_lua (lupa/_lupa.c:14933)
   File "lupa/_lupa.pyx", line 1079, in lupa._lupa.execute_lua_call (lupa/_lupa.c:15193)
   File "lupa/_lupa.pyx", line 189, in lupa._lupa.LuaRuntime.reraise_on_exception (lupa/_lupa.c:3579)
   File "lupa/_lupa.pyx", line 1214, in lupa._lupa.py_call_with_gil (lupa/_lupa.c:16528)
   File "lupa/_lupa.pyx", line 1206, in lupa._lupa.call_python (lupa/_lupa.c:16408)
   File "<string>", line 2, in x
   File "<string>", line 2, in <listcomp>
 RuntimeError: lost sys.__plugin__
 >>> lua.eval("print('\\xC2\\xA7')")
 §

Wat?

scoder commented 10 years ago

I have no idea what sys.__plugin__ is, so I can't say if it's a problem in lupa, lua or hexchat (whatever that is). Can you debug this to find out what goes wrong where?

SoniEx2 commented 10 years ago

Lua version:

[soniex2@soniex-pc autostart]$ lua -v
Lua 5.2.3  Copyright (C) 1994-2013 Lua.org, PUC-Rio

Python version:

[soniex2@soniex-pc autostart]$ python --version
Python 3.4.2

HexChat version:

[soniex2@soniex-pc hexchat]$ hexchat -v
HexChat 2.11.0

More debugging:

 >>> import sys
 >>> sys.__plugin__
 <hexchat.Plugin object at 0x7ffa8722f530>

This doesn't seem to happen with anything else, so I think it's Lupa messing with something, but I'll report this to hexchat too.

scoder commented 10 years ago

Which Lupa version are you using? (1.0.1? Latest git master?)

Does this also happen if you run straight forward code instead of going through exec()?

SoniEx2 commented 10 years ago

@scoder 1.0.1, and hexchat just locks up... (I can use either exec() if I want multiline in one line or .py scripts) If I remove exec() entirely and just run Lua code it also happens. (the locking up on init)