pavouk/lgi — pull request #49 by ntd (2013-04-04 15:20:46+00:00)
Title: Raise an exception if GTK+ initialization fails

An error in gtk_init() resulted in a program termination not
interceptable on the Lua side. Unsetting the DISPLAY environment
variable on X11 based systems exhibits this issue:

$ DISPLAY= lua -e "print(pcall((require 'lgi').require, 'Gtk'))" 2> /dev/null
$

This is due to the exit() call present in gtk_init().

An assertion on gtk_init_check() instead can be properly intercepted.
This is the result on the previous command on my system after having
applied this patch:

$ DISPLAY= lua -e "print(pcall((require 'lgi').require, 'Gtk'))" 2> /dev/null
false	/usr/share/lua/5.2/lgi/override/Gtk.lua:24: assertion failed!
$