mirror of
https://github.com/valitydev/salt.git
synced 2024-11-06 08:35:21 +00:00
Merge pull request #51658 from dwoz/pip_test_fix
[2019.2] Let memcopy make the null bytes, better py3 support
This commit is contained in:
commit
1ea6f4b18b
@ -355,13 +355,16 @@ class ContiguousUnicode(ctypes.Structure):
|
||||
return buf[:length]
|
||||
return None
|
||||
|
||||
def _set_unicode_buffer(self, value):
|
||||
def _set_unicode_buffer(self, values):
|
||||
cls = type(self)
|
||||
wchar_size = ctypes.sizeof(WCHAR)
|
||||
bufsize = (len(value) + 1) * wchar_size
|
||||
bufsize = (len('\x00'.join(values)) + 1) * wchar_size
|
||||
ctypes.resize(self, ctypes.sizeof(cls) + bufsize)
|
||||
addr = ctypes.addressof(self) + ctypes.sizeof(cls)
|
||||
for value in values:
|
||||
bufsize = (len(value) + 1) * wchar_size
|
||||
ctypes.memmove(addr, value, bufsize)
|
||||
addr += bufsize
|
||||
|
||||
def _set_unicode_string(self, name, value):
|
||||
values = []
|
||||
@ -370,7 +373,7 @@ class ContiguousUnicode(ctypes.Structure):
|
||||
values.append(value or '')
|
||||
else:
|
||||
values.append(getattr(self, n) or '')
|
||||
self._set_unicode_buffer('\x00'.join(values))
|
||||
self._set_unicode_buffer(values)
|
||||
|
||||
cls = type(self)
|
||||
wchar_size = ctypes.sizeof(WCHAR)
|
||||
|
Loading…
Reference in New Issue
Block a user