Pregunta

I know the question may looks stupid, but I am really not able to figure it out. I naively though a sequence of strings is a list of strings. However, this fails:

(pid, stdin, stdout, stderr) = glib.spawn_async(
    argv=["foo", "bar"],
    envp=None,
    flags=glib.SPAWN_SEARCH_PATH + glib.SPAWN_CHILD_INHERITS_STDIN,
    standard_input=True,
    standard_output=True,
    standard_error=True)

Fails with this error:

TypeError: glib.spawn_async: first argument must be a sequence of strings

I tried with a tuple, which gives nothing better.

What is a sequence of strings if not a list? I though about a possible Python‑Glib bug, while I don't believe such a bug can really exists. I found mention of a similar message on the web, but I don't know if this is this error which is a bug, or the occurrence of this error which is one.

-- edit --

Using this even shorter sample, ends into the same:

(pid, stdin, stdout, stderr) = glib.spawn_async(argv=["foo", "bar"])

As requested by posters, here is the full trace:

Traceback (most recent call last):
  File "<...>/test.py", line 92, in <module>
    run()
  File "<...>/test.py", line 62, in run
    standard_error=True)
TypeError: glib.spawn_async: first argument must be a sequence of strings
¿Fue útil?

Solución

To summarize the comments on the question:

  1. The strings shouldn't be unicode objects. If you have have Python 3 or from __future__ import unicode_literals, make byte literals via the b"foo" syntax.
  2. The envp argument seems to have diverged from its documentation. Don't provide None to it. Just don't provide that keyword/position if you aren't going to use it.
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top