scangobj chokes on non-ascii characters in command-line
While trying to build a debian package that invokes scan-obj, in a directory that contains non-ascii characters ("Téléchargements", in French), I got this error:
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 15: ordinal not in range(128)
More precisely, here is how the program was invoked (as dumped by deb tools):
['gtkdoc-scangobj', '--types=/home/pamaury/Téléchargements/geoclue-2.0-2.5.2/obj-x86_64-linux-gnu/docs/lib/libgeoclue.types', '--module=libgeoclue', '--run=', '--cflags=-I/home/pamaury/Téléchargements/geoclue-2.0-2.5.2/obj-x86_64-linux-gnu/public-api/. -I/home/pamaury/Téléchargements/geoclue-2.0-2.5.2/public-api/. -I/home/pamaury/Téléchargements/geoclue-2.0-2.5.2/obj-x86_64-linux-gnu/libgeoclue/. -I/home/pamaury/Téléchargements/geoclue-2.0-2.5.2/libgeoclue/. -I/home/pamaury/Téléchargements/geoclue-2.0-2.5.2/obj-x86_64-linux-gnu/libgeoclue/.. -I/home/pamaury/Téléchargements/geoclue-2.0-2.5.2/libgeoclue/.. -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -pthread -I/usr/include/libmount -I/usr/include/blkid -I/usr/include/uuid -I/usr/include/gio-unix-2.0 -g -O2 -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2', "--ldflags='-L/home/pamaury/Téléchargements/geoclue-2.0-2.5.2/obj-x86_64-linux-gnu/libgeoclue' '-Wl,-rpath,/home/pamaury/Téléchargements/geoclue-2.0-2.5.2/obj-x86_64-linux-gnu/libgeoclue' -lgeoclue-2 -lglib-2.0 -lgio-2.0 -lgobject-2.0 -lm -g -O2 -fstack-protector-strong -Wformat -Werror=format-security -Wl,-z,relro -Wl,-z,now", '--cc=cc', '--ld=cc', '--output-dir=/home/pamaury/Téléchargements/geoclue-2.0-2.5.2/obj-x86_64-linux-gnu/docs/lib']
and here is the line where it failed, in gtkdoc/scangobj.py:
output.write(string.Template(MAIN_CODE).substitute(locals()))
Here is how to reproduce on my debian machine:
cd <directory with accent>
apt-get source geoclue-2.0
cd <geoclue directory>
dpkg-buildpackage -rfakeroot -uc -b
Unfortunately, I don't quite know enough about gtkdoc and scangobj to understand how to fix it. Probably the ascii codec should not be used to parse the command line (it should use the current locale and anyway be ready to handle weird strings probably), but I'm not sure how this works.