From 05cee826e7f584f1bd689febba9ae366ab1be19e Mon Sep 17 00:00:00 2001 From: Muhammad Farhan Khan Date: Sun, 21 Jul 2024 13:50:55 +0500 Subject: [PATCH] fix: address PR change request --- xblock/__init__.py | 2 +- xblock/plugin.py | 2 +- xblock/utils/resources.py | 6 +++++- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/xblock/__init__.py b/xblock/__init__.py index 9ba6b90d0..8f666bd02 100644 --- a/xblock/__init__.py +++ b/xblock/__init__.py @@ -2,4 +2,4 @@ XBlock Courseware Components """ -__version__ = '5.0.0' +__version__ = '6.0.0' 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):