mirror of
https://github.com/hakril/PythonForWindows
synced 2026-06-08 14:31:45 +00:00
utils.create_file_from_handle now handles binary opening mode
This commit is contained in:
@@ -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)
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user