Do not attempt to rewrite non-source files (#5490)
Do not attempt to rewrite non-source files
This commit is contained in:
commit
aaf40314d1
|
@ -70,6 +70,8 @@ class AssertionRewritingHook:
|
||||||
# python3.5 - python3.6: `namespace`
|
# python3.5 - python3.6: `namespace`
|
||||||
# python3.7+: `None`
|
# python3.7+: `None`
|
||||||
or spec.origin in {None, "namespace"}
|
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
|
# if the file doesn't exist, we can't rewrite it
|
||||||
or not os.path.exists(spec.origin)
|
or not os.path.exists(spec.origin)
|
||||||
):
|
):
|
||||||
|
|
Loading…
Reference in New Issue