Skip to content

Commit 08627b0

Browse files
committed
fix: address PR change request
1 parent 20149cf commit 08627b0

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

xblock/plugin.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ def select(identifier, all_entry_points):
100100
if select is None:
101101
select = default_select
102102

103-
all_entry_points = importlib.metadata.entry_points(group=cls.entry_point, name=identifier)
103+
all_entry_points = list(importlib.metadata.entry_points(group=cls.entry_point, name=identifier))
104104
for extra_identifier, extra_entry_point in iter(cls.extra_entry_points):
105105
if identifier == extra_identifier:
106106
all_entry_points.append(extra_entry_point)

xblock/utils/resources.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,11 @@ def load_unicode(self, resource_path):
2222
Gets the content of a resource
2323
"""
2424
package_name = importlib.import_module(self.module_name).__package__
25-
# Strip leading slash to avoid importlib exception with absolute paths
25+
# TODO: Add encoding on other places as well
26+
# resource_path should be a relative path, but historically some callers passed it in
27+
# with a leading slash, which pkg_resources tolerated and ignored. importlib is less
28+
# forgiving, so in order to maintain backwards compatibility, we must strip off the
29+
# leading slash is there is one to ensure we actually have a relative path.
2630
return importlib.resources.files(package_name).joinpath(resource_path.lstrip('/')).read_text(encoding="utf-8")
2731

2832
def render_django_template(self, template_path, context=None, i18n_service=None):

0 commit comments

Comments
 (0)