Comparison

util/debug.lua @ 4418:70b5e533325d

util.debug: Fix potential traceback
author Matthew Wild <mwild1@gmail.com>
date Sat, 19 Nov 2011 22:40:30 +0000
parent 4412:5d7d9a60bc7f
child 4465:41c4252526bd
comparison
equal deleted inserted replaced
4417:33c149394dcb 4418:70b5e533325d
18 return locals; 18 return locals;
19 end 19 end
20 20
21 local function get_upvalues_table(func) 21 local function get_upvalues_table(func)
22 local upvalues = {}; 22 local upvalues = {};
23 for upvalue_num = 1, math.huge do 23 if func then
24 local name, value = debug.getupvalue(func, upvalue_num); 24 for upvalue_num = 1, math.huge do
25 if not name then break; end 25 local name, value = debug.getupvalue(func, upvalue_num);
26 table.insert(upvalues, { name = name, value = value }); 26 if not name then break; end
27 table.insert(upvalues, { name = name, value = value });
28 end
27 end 29 end
28 return upvalues; 30 return upvalues;
29 end 31 end
30 32
31 local function string_from_var_table(var_table, max_line_len, indent_str) 33 local function string_from_var_table(var_table, max_line_len, indent_str)