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()