Merge pull request #9609 from kdelee/patch-1
importlib.readers not valid until python 3.10
This commit is contained in:
commit
44290d1f6c
|
@ -0,0 +1 @@
|
||||||
|
Fix invalid importing of ``importlib.readers`` in Python 3.9.
|
|
@ -273,13 +273,15 @@ class AssertionRewritingHook(importlib.abc.MetaPathFinder, importlib.abc.Loader)
|
||||||
with open(pathname, "rb") as f:
|
with open(pathname, "rb") as f:
|
||||||
return f.read()
|
return f.read()
|
||||||
|
|
||||||
if sys.version_info >= (3, 9):
|
if sys.version_info >= (3, 10):
|
||||||
|
|
||||||
def get_resource_reader(self, name: str) -> importlib.abc.TraversableResources: # type: ignore
|
def get_resource_reader(self, name: str) -> importlib.abc.TraversableResources: # type: ignore
|
||||||
from types import SimpleNamespace
|
if sys.version_info < (3, 11):
|
||||||
from importlib.readers import FileReader
|
from importlib.readers import FileReader
|
||||||
|
else:
|
||||||
|
from importlib.resources.readers import FileReader
|
||||||
|
|
||||||
return FileReader(SimpleNamespace(path=self._rewritten_names[name]))
|
return FileReader(types.SimpleNamespace(path=self._rewritten_names[name]))
|
||||||
|
|
||||||
|
|
||||||
def _write_pyc_fp(
|
def _write_pyc_fp(
|
||||||
|
|
Loading…
Reference in New Issue