Commits

Lenard Lindstrom committed 893b7dd

fix bug introduced into the test framework in r2938

  • Participants
  • Parent commits 3129146

Comments (0)

Files changed (1)

File test/test_utils/async_sub.py

 def geterror ():
     return sys.exc_info()[1]
 
+if sys.version_info >= (3,):
+    null_byte = '\x00'.encode('ascii')
+else:
+    null_byte = '\x00'
+
 if subprocess.mswindows:
     if sys.version_info >= (3,):
         # Test date should be in ascii.
             c_read = DWORD()
             buffer = ctypes.create_string_buffer(desired_bytes+1)
             success = ctypes.windll.kernel32.ReadFile(handle, buffer, desired_bytes, ctypes.byref(c_read), ol)
-            buffer[c_read.value] = ctypes.c_char(0)
+            buffer[c_read.value] = null_byte
             return ctypes.windll.kernel32.GetLastError(), decode(buffer.value)
         def PeekNamedPipe(handle, desired_bytes):
             c_avail = DWORD()
                 c_read = DWORD()
                 buffer = ctypes.create_string_buffer(desired_bytes+1)
                 success = ctypes.windll.kernel32.PeekNamedPipe(handle, buffer, desired_bytes, ctypes.byref(c_read), ctypes.byref(c_avail), ctypes.byref(c_message))
-                buffer[c_read.value] = ctypes.c_char(0)
+                buffer[c_read.value] = null_byte
                 return decode(buffer.value), c_avail.value, c_message.value
             else:
                 success = ctypes.windll.kernel32.PeekNamedPipe(handle, None, desired_bytes, None, ctypes.byref(c_avail), ctypes.byref(c_message))