Skip to content

Commit

Permalink
fix: address PR change request
Browse files Browse the repository at this point in the history
  • Loading branch information
farhan committed Jul 25, 2024
1 parent 036ae24 commit 8885b94
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
2 changes: 1 addition & 1 deletion xblock/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
6 changes: 5 additions & 1 deletion xblock/utils/resources.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down

0 comments on commit 8885b94

Please sign in to comment.