Regression: run_path broken for python >= 3.8
Affects setup.py
In [1]: from runpy import run_path
In [2]:
In [2]: from pathlib import Path
In [3]:
In [3]: cd ..
/home/avmo/src/fluiddyn/transonic
In [4]: v = Path("transonic/_version.py")
In [5]: v
Out[5]: PosixPath('transonic/_version.py')
In [6]: run_path(v)
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-6-6da5ed68dcf0> in <module>
----> 1 run_path(v)
~/.pyenv/versions/3.8.1/lib/python3.8/runpy.py in run_path(path_name, init_globals, run_name)
260 # Not a valid sys.path entry, so run the code directly
261 # execfile() doesn't help as we want to allow compiled files
--> 262 code, fname = _get_code_from_file(run_name, path_name)
263 return _run_module_code(code, init_globals, run_name,
264 pkg_name=pkg_name, script_name=fname)
~/.pyenv/versions/3.8.1/lib/python3.8/runpy.py in _get_code_from_file(run_name, fname)
230 def _get_code_from_file(run_name, fname):
231 # Check for a compiled file first
--> 232 with io.open_code(fname) as f:
233 code = read_code(f)
234 if code is None:
TypeError: open_code() argument 'path' must be str, not PosixPath
In [7]: import io
In [8]: io.open_code?
Signature: io.open_code(path)
Docstring:
Opens the provided file with the intent to import the contents.
This may perform extra validation beyond open(), but is otherwise interchangeable
with calling open(path, 'rb').
Type: builtin_function_or_method
In [9]: io.open_code(v)
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-9-30a090c83748> in <module>
----> 1 io.open_code(v)
TypeError: open_code() argument 'path' must be str, not PosixPath
In [10]:
In [10]: hist
from runpy import run_path
from pathlib import Path
cd ..
v = Path("transonic/_version.py")
v
run_path(v)
import io
io.open_code?
io.open_code(v)