Fix asciidoc2html on Windows.

Windows needs the SystemRoot environment variable set to initialize the crypto
API, what running Python in a subprocess does.

However, we did override the whole environment instead of extending it, which
means this broke on Windows when calling asciidoc:

    Traceback (most recent call last):
      File "C:\asciidoc-8.6.9\asciidoc.py", line 9, in <module>
        import sys, os, re, time, traceback, tempfile, subprocess, codecs, locale, unicodedata, copy
      File "C:\Python27\lib\tempfile.py", line 35, in <module>
        from random import Random as _Random
      File "C:\Python27\lib\random.py", line 885, in <module>
        _inst = Random()
      File "C:\Python27\lib\random.py", line 97, in __init__
        self.seed(x)
      File "C:\Python27\lib\random.py", line 113, in seed
        a = long(_hexlify(_urandom(2500)), 16)
    WindowsError: [Error -2146893795] Provider DLL failed to initialize correctly
This commit is contained in:
Florian Bruhin 2016-01-05 08:00:35 +01:00
parent 814e6f5959
commit e603470260

View File

@ -226,7 +226,9 @@ class AsciiDoc:
cmdline += args
cmdline.append(src)
try:
subprocess.check_call(cmdline, env={'HOME': self._homedir})
env = os.environ.copy()
env['HOME'] = self._homedir
subprocess.check_call(cmdline, env=env)
self._failed = True
except (subprocess.CalledProcessError, OSError) as e:
self._failed = True