py3: ipautil: open tempfiles in text mode

Code in ipautlis works with text, so tempfiles should be open in
textmode otherwise TypeErrors are raised

https://fedorahosted.org/freeipa/ticket/4985

Reviewed-By: Christian Heimes <cheimes@redhat.com>
Reviewed-By: Jan Cholasta <jcholast@redhat.com>
This commit is contained in:
Martin Basti
2017-01-09 19:26:04 +01:00
parent bbe8849a65
commit 7ae5e5f669

View File

@@ -1020,7 +1020,7 @@ $)''', re.VERBOSE)
orig_stat = os.stat(filepath)
old_values = dict()
temp_filename = None
with tempfile.NamedTemporaryFile(delete=False) as new_config:
with tempfile.NamedTemporaryFile(mode="w", delete=False) as new_config:
temp_filename = new_config.name
with open(filepath, 'r') as f:
for line in f:
@@ -1106,7 +1106,7 @@ $)''', re.VERBOSE)
orig_stat = os.stat(filepath)
old_values = dict()
temp_filename = None
with tempfile.NamedTemporaryFile(delete=False) as new_config:
with tempfile.NamedTemporaryFile(mode='w', delete=False) as new_config:
temp_filename = new_config.name
with open(filepath, 'r') as f:
in_section = False