Skip to content
This repository has been archived by the owner on Jul 16, 2022. It is now read-only.

Commit

Permalink
Merge pull request #48 from LovecraftianHorror/pathlib-support
Browse files Browse the repository at this point in the history
Add support for pathlib paths

Fix #47
  • Loading branch information
untitaker authored Apr 28, 2020
2 parents 4705e84 + 2a91f2e commit ba24a05
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions atomicwrites/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,12 @@
except ImportError:
fcntl = None

# `fspath` was added in Python 3.6
try:
from os import fspath
except ImportError:
fspath = None

__version__ = '1.3.0'


Expand Down Expand Up @@ -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
Expand Down

0 comments on commit ba24a05

Please sign in to comment.