[GRASS-dev] Using grass.message in Python: Why does G_message() print to stderr and not stdout?

Markus Neteler neteler at osgeo.org
Sun Sep 9 06:47:15 PDT 2018


Hi,

Why does G_message() print to stderr and not stdout?
https://trac.osgeo.org/grass/browser/grass/trunk/lib/gis/error.c#L84

This is a big problem when working with grass.run_command() and
friends since Python tends to buffer error messages (or occasionally
eats them). I have no reference why Python does so but there a myriad
of posts from people complaining about it.

Why an issue? I am currently debugging a long Python script on a
remote system, all docker based, and errors do not really show up. But
especially the grass.message()  output is not there so that I can not
easily add debug output. So, the latter I would like to change.
To now add simple print() statements (on stdout) in a GRASS GIS Python
script is a bit against the idea of grass.message()...
Can grass.message() please (optionally) print on stdout?

Likely I am missing something - suggestions are welcome.

thanks
Markus


More information about the grass-dev mailing list