summaryrefslogtreecommitdiff
path: root/Lib/runpy.py
diff options
context:
space:
mode:
Diffstat (limited to 'Lib/runpy.py')
-rw-r--r--Lib/runpy.py6
1 files changed, 4 insertions, 2 deletions
diff --git a/Lib/runpy.py b/Lib/runpy.py
index 8adc91e32f..0f54f3e71b 100644
--- a/Lib/runpy.py
+++ b/Lib/runpy.py
@@ -15,6 +15,7 @@ import importlib.machinery # importlib first so we can test #15386 via -m
import importlib.util
import io
import types
+import os
from pkgutil import read_code, get_importer
__all__ = [
@@ -229,11 +230,12 @@ def _get_main_module_details(error=ImportError):
def _get_code_from_file(run_name, fname):
# Check for a compiled file first
- with io.open_code(fname) as f:
+ decoded_path = os.path.abspath(os.fsdecode(fname))
+ with io.open_code(decoded_path) as f:
code = read_code(f)
if code is None:
# That didn't work, so try it as normal source code
- with io.open_code(fname) as f:
+ with io.open_code(decoded_path) as f:
code = compile(f.read(), fname, 'exec')
return code, fname