mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
commit
916b1c4f7c
1 changed files with 14 additions and 1 deletions
|
@ -1015,7 +1015,7 @@ def fopen(*args, **kwargs):
|
|||
NB! We still have small race condition between open and fcntl.
|
||||
|
||||
'''
|
||||
# Remove lock, uid, gid and mode from kwargs if present
|
||||
# Remove lock from kwargs if present
|
||||
lock = kwargs.pop('lock', False)
|
||||
|
||||
if lock is True:
|
||||
|
@ -1028,6 +1028,19 @@ def fopen(*args, **kwargs):
|
|||
)
|
||||
return flopen(*args, **kwargs)
|
||||
|
||||
# ensure 'binary' mode is always used on windows
|
||||
if is_windows():
|
||||
if len(args) > 1:
|
||||
args = list(args)
|
||||
if 'b' not in args[1]:
|
||||
args[1] += 'b'
|
||||
elif kwargs.get('mode', None):
|
||||
if 'b' not in kwargs['mode']:
|
||||
kwargs['mode'] += 'b'
|
||||
else:
|
||||
# the default is to read
|
||||
kwargs['mode'] = 'rb'
|
||||
|
||||
fhandle = open(*args, **kwargs)
|
||||
if is_fcntl_available():
|
||||
# modify the file descriptor on systems with fcntl
|
||||
|
|
Loading…
Add table
Reference in a new issue