Handle None vs. nil mapping
masterLupa maps Python's None to Lua's nil by default. However, because Lua uses nil as a termination marker for iterators, Lupa uses a special constant python.none during iteration to prevent loops from terminating prematurely when encountering a None value.
To check for None inside Lua code, compare the value against python.none.
# In Lua, use python.none to represent Python's None during iteration
func = lua.eval('''
function(items)
for value in python.iter(items) do
if value == python.none then
-- This was a Python None
end
end
end
''')
items = [1, None, 2]
func(items)