From 576a41136ffd20f4cb92c1a6abade66a58125cfd 2020-10-26 21:16:52 From: Matthias Bussonnier Date: 2020-10-26 21:16:52 Subject: [PATCH] Merge pull request #12665 from szarroug3/pathlib_io use pathlib.Path in io.py --- diff --git a/IPython/utils/io.py b/IPython/utils/io.py index fab9bae..7dc8986 100644 --- a/IPython/utils/io.py +++ b/IPython/utils/io.py @@ -13,6 +13,7 @@ import os import sys import tempfile import warnings +from pathlib import Path from warnings import warn from IPython.utils.decorators import undoc @@ -205,7 +206,7 @@ def temp_pyfile(src, ext='.py'): It is the caller's responsibility to close the open file and unlink it. """ fname = tempfile.mkstemp(ext)[1] - with open(fname,'w') as f: + with open(Path(fname), "w") as f: f.write(src) f.flush() return fname