diff --git a/xblock/plugin.py b/xblock/plugin.py index 6b5888d0c..3f1574c4b 100644 --- a/xblock/plugin.py +++ b/xblock/plugin.py @@ -100,7 +100,7 @@ def select(identifier, all_entry_points): if select is None: select = default_select - all_entry_points = importlib.metadata.entry_points(group=cls.entry_point, name=identifier) + all_entry_points = list(importlib.metadata.entry_points(group=cls.entry_point, name=identifier)) for extra_identifier, extra_entry_point in iter(cls.extra_entry_points): if identifier == extra_identifier: all_entry_points.append(extra_entry_point) diff --git a/xblock/utils/resources.py b/xblock/utils/resources.py index 778007cd1..f3f2ac69f 100644 --- a/xblock/utils/resources.py +++ b/xblock/utils/resources.py @@ -22,7 +22,11 @@ def load_unicode(self, resource_path): Gets the content of a resource """ package_name = importlib.import_module(self.module_name).__package__ - # Strip leading slash to avoid importlib exception with absolute paths + # TODO: Add encoding on other places as well + # resource_path should be a relative path, but historically some callers passed it in + # with a leading slash, which pkg_resources tolerated and ignored. importlib is less + # forgiving, so in order to maintain backwards compatibility, we must strip off the + # leading slash is there is one to ensure we actually have a relative path. return importlib.resources.files(package_name).joinpath(resource_path.lstrip('/')).read_text(encoding="utf-8") def render_django_template(self, template_path, context=None, i18n_service=None):