Change use of GetEnvironmentVariableW (#7582)

This commit is contained in:
Josip 2014-04-06 00:20:22 +02:00
parent 0a5b2e9f6a
commit f7e144f853

View File

@ -184,7 +184,8 @@ def get_env_var(name, default=None):
n = ctypes.windll.kernel32.GetEnvironmentVariableW(name, None, 0) n = ctypes.windll.kernel32.GetEnvironmentVariableW(name, None, 0)
if n==0: if n==0:
return default return default
buf = ctypes.create_unicode_buffer(u'\0'*n) # n is number of codepoints
buf = ctypes.create_unicode_buffer(n+1)
ctypes.windll.kernel32.GetEnvironmentVariableW(name, buf, n) ctypes.windll.kernel32.GetEnvironmentVariableW(name, buf, n)
return buf.value return buf.value