summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorToshio Kuratomi <a.badger@gmail.com>2018-05-17 12:32:45 -0700
committerToshio Kuratomi <a.badger@gmail.com>2018-05-17 15:24:56 -0700
commit3760cc3a7d30e58d3ee85f145a8cb6263b54500f (patch)
treeaf0a8b6fb986adcd744ad7368aeea93a016344f0
parent0442efd33aa8b8b6018e86be57347370381b8ad2 (diff)
downloadansible-3760cc3a7d30e58d3ee85f145a8cb6263b54500f.tar.gz
Fix python-2.4ism that was still present in basic.py's use of tempfile
-rw-r--r--lib/ansible/module_utils/basic.py9
1 files changed, 4 insertions, 5 deletions
diff --git a/lib/ansible/module_utils/basic.py b/lib/ansible/module_utils/basic.py
index 10c8f2a0fe..0043b67652 100644
--- a/lib/ansible/module_utils/basic.py
+++ b/lib/ansible/module_utils/basic.py
@@ -2532,17 +2532,16 @@ class AnsibleModule(object):
self.fail_json(msg='Could not replace file: %s to %s: %s' % (src, dest, to_native(e)),
exception=traceback.format_exc())
else:
- b_dest_dir = os.path.dirname(b_dest)
# Use bytes here. In the shippable CI, this fails with
# a UnicodeError with surrogateescape'd strings for an unknown
# reason (doesn't happen in a local Ubuntu16.04 VM)
- native_dest_dir = b_dest_dir
- native_suffix = os.path.basename(b_dest)
- native_prefix = b('.ansible_tmp')
+ b_dest_dir = os.path.dirname(b_dest)
+ b_suffix = os.path.basename(b_dest)
error_msg = None
tmp_dest_name = None
try:
- tmp_dest_fd, tmp_dest_name = tempfile.mkstemp(prefix=native_prefix, dir=native_dest_dir, suffix=native_suffix)
+ tmp_dest_fd, tmp_dest_name = tempfile.mkstemp(prefix=b'.ansible_tmp',
+ dir=b_dest_dir, suffix=b_suffix)
except (OSError, IOError) as e:
error_msg = 'The destination directory (%s) is not writable by the current user. Error was: %s' % (os.path.dirname(dest), to_native(e))
except TypeError: