updated on Mon Jan 16 12:07:49 UTC 2012
[aur-mirror.git] / lunatic-python-bzr / 3-subscript-panic.patch
blobee3b8146be9d926b0dc73dc02793f8c13b56d0f9
1 --- src/luainpython.c.orig 2011-07-26 12:49:51.456988438 +0600
2 +++ src/luainpython.c 2011-07-26 12:52:50.218038281 +0600
3 @@ -191,12 +191,23 @@
4 static PyObject *LuaObject_getattr(PyObject *obj, PyObject *attr)
6 PyObject *ret = NULL;
7 - int rc;
8 + int rc, type;
9 lua_rawgeti(L, LUA_REGISTRYINDEX, ((LuaObject*)obj)->ref);
10 - if (lua_isnil(L, -1)) {
11 + type = lua_type(L, -1);
13 + if (type == LUA_TNIL) {
14 lua_pop(L, 1);
15 PyErr_SetString(PyExc_RuntimeError, "lost reference");
16 return NULL;
17 + /* It ought to be impossible to index a LUA_TNUMBER, LUA_TSTRING (and
18 + maybe others) as they should have already been converted to their
19 + Python equivalent. */
20 + } else if (type == LUA_TFUNCTION ||
21 + type == LUA_TLIGHTUSERDATA ||
22 + type == LUA_TTHREAD) {
23 + lua_pop(L, 1);
24 + PyErr_Format(PyExc_RuntimeError, "cannot index values of type '%s'", lua_typename(L, type));
25 + return NULL;
27 rc = py_convert(L, attr, 0);
28 if (rc) {