From ecb2fed58556331dd96fc0389df4891c9c3918ba Mon Sep 17 00:00:00 2001 From: Remi Rampin Date: Thu, 6 Nov 2014 10:54:18 -0500 Subject: [PATCH] Makes tempfile and tempdir accept Path as dir --- rpaths.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/rpaths.py b/rpaths.py index d6ad878..6eea41f 100644 --- a/rpaths.py +++ b/rpaths.py @@ -488,6 +488,10 @@ def tempfile(cls, suffix='', prefix=None, dir=None, text=False): """ if prefix is None: prefix = tempfile.template + if dir is not None: + # Note that this is not safe on Python 2 + # There is no work around, apart from not using the tempfile module + dir = str(Path(dir)) fd, filename = tempfile.mkstemp(suffix, prefix, dir, text) return fd, cls(filename).absolute() @@ -505,6 +509,10 @@ def tempdir(cls, suffix='', prefix=None, dir=None): """ if prefix is None: prefix = tempfile.template + if dir is not None: + # Note that this is not safe on Python 2 + # There is no work around, apart from not using the tempfile module + dir = str(Path(dir)) dirname = tempfile.mkdtemp(suffix, prefix, dir) return cls(dirname).absolute()