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