Do not attempt to rewrite non-source files (#5490)

Do not attempt to rewrite non-source files
This commit is contained in:
Bruno Oliveira
2019-06-25 20:43:23 -03:00
committed by GitHub

View File

@@ -70,6 +70,8 @@ class AssertionRewritingHook:
# python3.5 - python3.6: `namespace`
# python3.7+: `None`
or spec.origin in {None, "namespace"}
# we can only rewrite source files
or not isinstance(spec.loader, importlib.machinery.SourceFileLoader)
# if the file doesn't exist, we can't rewrite it
or not os.path.exists(spec.origin)
):