diff options
author | Martin Basti <mbasti@redhat.com> | 2017-01-09 19:26:04 +0100 |
---|---|---|
committer | Martin Basti <mbasti@redhat.com> | 2017-01-24 13:25:47 +0100 |
commit | 7ae5e5f66919141821fdffbd6f8683c6d7afddd7 (patch) | |
tree | eda3cef0602e44ef772d01275980c50aeec4bf7a /ipapython/ipautil.py | |
parent | bbe8849a654ed0764e1834f24d1837df41a79881 (diff) | |
download | freeipa-7ae5e5f66919141821fdffbd6f8683c6d7afddd7.tar.gz freeipa-7ae5e5f66919141821fdffbd6f8683c6d7afddd7.tar.xz freeipa-7ae5e5f66919141821fdffbd6f8683c6d7afddd7.zip |
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>
Diffstat (limited to 'ipapython/ipautil.py')
-rw-r--r-- | ipapython/ipautil.py | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/ipapython/ipautil.py b/ipapython/ipautil.py index 34d10ef78..f2b3d7419 100644 --- a/ipapython/ipautil.py +++ b/ipapython/ipautil.py @@ -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 |