utils.create_file_from_handle now handles binary opening mode

This commit is contained in:
hakril
2017-11-15 09:00:38 +01:00
parent be68ba8b15
commit d9db5ba428
+2 -1
View File
@@ -48,7 +48,8 @@ def is_wow_64(hProcess):
def create_file_from_handle(handle, mode="r"):
"""Return a Python :class:`file` around a ``Windows`` HANDLE"""
fd = msvcrt.open_osfhandle(handle, os.O_TEXT)
flags = os.O_BINARY if "b" in mode else os.O_TEXT
fd = msvcrt.open_osfhandle(handle, flags)
return os.fdopen(fd, mode, 0)