Merge pull request #2922 from laloch/filepath-to-logfile

make $XONSH_TRACEBACK_LOGFILE accept path objects
This commit is contained in:
Anthony Scopatz 2018-11-02 14:16:50 -04:00 committed by GitHub
commit fc64f31383
Failed to generate hash of commit
2 changed files with 29 additions and 0 deletions

View file

@ -0,0 +1,24 @@
**Added:**
* <news item>
**Changed:**
* ``$XONSH_TRACEBACK_LOGFILE`` now beside strings also accepts ``os.PathLike``
objects.
**Deprecated:**
* <news item>
**Removed:**
* <news item>
**Fixed:**
* <news item>
**Security:**
* <news item>

View file

@ -1169,6 +1169,11 @@ def to_logfile_opt(x):
the filepath if it is a writable file or None if the filepath is not
valid, informing the user on stderr about the invalid choice.
"""
superclass = pathlib.PurePath
if PYTHON_VERSION_INFO >= (3, 6, 0):
superclass = os.PathLike
if isinstance(x, superclass):
x = str(x)
if is_logfile_opt(x):
return x
else: