diff --git a/.travis.yml b/.travis.yml index 6dfaa57..715ac80 100644 --- a/.travis.yml +++ b/.travis.yml @@ -8,23 +8,13 @@ python: - 3.4 - 3.5 - 3.6 + - 3.7 env: - TOXENV=test matrix: include: - - # The OS X VM doesn't have any Python support at all - # See https://github.com/travis-ci/travis-ci/issues/2312 - os: osx - language: generic - env: TOXENV=test - before_install: - - brew update - - brew upgrade python - - python3 -m pip install --user virtualenv - - /Users/travis/Library/Python/3.7/bin/virtualenv $HOME/osx-py - - source $HOME/osx-py/bin/activate - python: 2.7 env: TOXENV=stylecheck - python: 3.6 diff --git a/atomicwrites/__init__.py b/atomicwrites/__init__.py index cfa5c29..623826e 100644 --- a/atomicwrites/__init__.py +++ b/atomicwrites/__init__.py @@ -9,7 +9,13 @@ except ImportError: fcntl = None -__version__ = '1.3.0' +# `fspath` was added in Python 3.6 +try: + from os import fspath +except ImportError: + fspath = None + +__version__ = '1.4.0' PY2 = sys.version_info[0] == 2 @@ -137,6 +143,10 @@ def __init__(self, path, mode=DEFAULT_MODE, overwrite=False, if 'w' not in mode: raise ValueError('AtomicWriters can only be written to.') + # Attempt to convert `path` to `str` or `bytes` + if fspath is not None: + path = fspath(path) + self._path = path self._mode = mode self._overwrite = overwrite @@ -165,8 +175,8 @@ def _open(self, get_fileobject): except Exception: pass - def get_fileobject(self, suffix="", prefix=tempfile.template, dir=None, - **kwargs): + def get_fileobject(self, suffix="", prefix=tempfile.gettempprefix(), + dir=None, **kwargs): '''Return the temporary file to use.''' if dir is None: dir = os.path.normpath(os.path.dirname(self._path)) diff --git a/setup.py b/setup.py index e0eaca0..adbf232 100644 --- a/setup.py +++ b/setup.py @@ -32,6 +32,7 @@ 'Programming Language :: Python :: 3.4', 'Programming Language :: Python :: 3.5', 'Programming Language :: Python :: 3.6', + 'Programming Language :: Python :: 3.7', 'Programming Language :: Python :: Implementation :: CPython', ], python_requires='>=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*',