Comment 33 for bug 1662531

Revision history for this message
Alvin Penner (apenner) wrote :

Hi,
    some responses, in no particular order
1. no other feedback, other than this bug report
2
. this concerns only those instances of Inkscape that are spawned by Python, not the command line, and also only on Windows
3. with respect to the question of fixing it in Inkscape, versus Python, I think it would be better to do it in Python. The Inkscape code that triggers the issue is: std::locale(""). This code will cause a crash if triggered from a Python Popen command, but not if Inkscape is called from the command line. As I understand it, this code tells Inkscape to inherit its locale from the parent that called it, which is a reasonable thing to do, and it would not be wise to arbitrarily override it.
4. wrt the question: 'what environment is inherited by inkscape processes spawned via Popen() on Windows'. To the best of my knowledge the answer is 'null'. Any use of the statement std::locale(""), even in just a print statement, generates an instantaneous crash if triggered by Popen. If triggered by a DOS run command, the answer is 'C'.
5. As far as the impact on Python extensions is concerned: to the best of my knowledge, the only affected extensions would be Synfig output, and the multi-bool extensions, and this current bug report. When I first learned of this problem, I generated output from every single Inkscape output extension I could find, and only Synfig raised a flag. In order for this problem to occur, you need to, first, be on Windows, secondly use Popen from Python, and thirdly use a verb that involves the gui. For example, commands like the commonly-used '--query-x' will not cause a problem because they apparently do not involve the gui. (It is kind of a sad commentary to realize how little these gui verbs are used. Given the potential power of the verb systen, one might have hoped that there would be many more examples of extensions that would be affected, but there are not.)
6. limiting the Python code change to Windows-only seems like a good idea. It could be done with a line of code like this:
if inkex.sys.platform.startswith('win'):
    inkex.os.environ['LC_ALL'] = 'C' # pass this to the spawned Inkscape

My proposal would be to patch the three known examples with code of this type, in Python.