vte_pty_spawn_async 60.0 problem
Hello,
Since the version 60.0 my GTK+ Python code got broken and vte_pty_spawn_async
is throwing me a ton of errors. I've been reading the source code but I can not figure out how to fix it.
This is the working example that I was using on 58.3:
import gi
gi.require_version('Gtk', '3.0')
gi.require_version('Vte', '2.91')
from gi.repository import Gtk, Vte, GLib, Gio
class TheWindow(Gtk.Window):
def __init__(self):
Gtk.Window.__init__(self, title="GTK3 IDE")
self.set_default_size(600, 300)
terminal = Vte.Terminal()
pty = Vte.Pty.new_sync(Vte.PtyFlags.DEFAULT)
pty.spawn_async(
None,
["/bin/python"],
None,
GLib.SpawnFlags.DO_NOT_REAP_CHILD,
None,
None,
-1,
None,
self.ready
)
terminal.set_pty(pty)
box = Gtk.Box(orientation=Gtk.Orientation.VERTICAL)
scroller = Gtk.ScrolledWindow()
scroller.set_hexpand(True)
scroller.set_vexpand(True)
scroller.add(terminal)
box.pack_start(scroller, False, True, 2)
self.add(box)
def ready(self, pty, task):
print('pty ', pty)
win=TheWindow()
win.connect('destroy', Gtk.main_quit)
win.show_all()
Gtk.main()
but it fails on 60.0:
Traceback (most recent call last):
File "old.py", line 43, in <module>
win=TheWindow()
File "old.py", line 15, in __init__
pty.spawn_async(
TypeError: Argument 1 does not allow None as a value
which surprises me because vte_pty_spawn_async
is the same in 58.3 and 60.0:
/**
* vte_pty_spawn_async:
* @pty: a #VtePty
* @working_directory: (allow-none): the name of a directory the command should start
* in, or %NULL to use the current working directory
* @argv: (array zero-terminated=1) (element-type filename): child's argument vector
* @envv: (allow-none) (array zero-terminated=1) (element-type filename): a list of environment
* variables to be added to the environment before starting the process, or %NULL
* @spawn_flags: flags from #GSpawnFlags
* @child_setup: (allow-none) (scope async): an extra child setup function to run in the child just before exec(), or %NULL
* @child_setup_data: (closure child_setup): user data for @child_setup, or %NULL
* @child_setup_data_destroy: (destroy child_setup_data): a #GDestroyNotify for @child_setup_data, or %NULL
* @timeout: a timeout value in ms, or -1 to wait indefinitely
* @cancellable: (allow-none): a #GCancellable, or %NULL
*
* Starts the specified command under the pseudo-terminal @pty.
* The @argv and @envv lists should be %NULL-terminated.
* The "TERM" environment variable is automatically set to a default value,
* but can be overridden from @envv.
* @pty_flags controls logging the session to the specified system log files.
*
* Note that %G_SPAWN_DO_NOT_REAP_CHILD will always be added to @spawn_flags.
*
* Note that all open file descriptors will be closed in the child. If you want
* to keep some file descriptor open for use in the child process, you need to
* use a child setup function that unsets the FD_CLOEXEC flag on that file
* descriptor.
*
* Beginning with 0.60, and on linux only, and unless %VTE_SPAWN_NO_SYSTEMD_SCOPE is
* passed in @spawn_flags, the newly created child process will be moved to its own
* systemd user scope; and if %VTE_SPAWN_REQUIRE_SYSTEMD_SCOPE is passed, and creation
* of the systemd user scope fails, the whole spawn will fail.
* You can override the options used for the systemd user scope by
* providing a systemd override file for 'vte-spawn-.scope' unit. See man:systemd.unit(5)
* for further information.
*
* See vte_pty_new(), g_spawn_async() and vte_terminal_watch_child() for more information.
*
* Since: 0.48
*/
void
vte_pty_spawn_async(VtePty *pty,
const char *working_directory,
char **argv,
char **envv,
GSpawnFlags spawn_flags,
GSpawnChildSetupFunc child_setup,
gpointer child_setup_data,
GDestroyNotify child_setup_data_destroy,
int timeout,
GCancellable *cancellable,
GAsyncReadyCallback callback,
gpointer user_data)
{
g_return_if_fail(argv != nullptr);
g_return_if_fail(!child_setup_data || child_setup);
g_return_if_fail(!child_setup_data_destroy || child_setup_data);
g_return_if_fail(cancellable == nullptr || G_IS_CANCELLABLE (cancellable));
g_return_if_fail(callback);
auto data = async_spawn_data_new(pty,
working_directory, argv, envv,
spawn_flags,
child_setup, child_setup_data, child_setup_data_destroy,
timeout);
auto task = g_task_new(pty, cancellable, callback, user_data);
g_task_set_source_tag(task, (void*)vte_pty_spawn_async);
g_task_set_task_data(task, data, async_spawn_data_free);
g_task_run_in_thread(task, async_spawn_run_in_thread);
g_object_unref(task);
}
Thanks for your help, rsm