Skip to content

Commit

Permalink
set encoding to utf-8 when opening plugin init files (#123)
Browse files Browse the repository at this point in the history
following report from Marin Dujmovic:
> on a couple of different Windwos systems is the error [...] I was running into a couple of weeks ago. I guess for some reason it ends up forcing cp1252 instead of utf8 and it throws up this error whenever a plugin is being loaded (metric, benchmark etc.).

Co-authored-by: deirdre-k <[email protected]>
  • Loading branch information
mschrimpf and deirdre-k authored Jul 16, 2024
1 parent dcfb35d commit f3f7da3
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion brainscore_core/plugin_management/import_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,10 @@ def locate_plugin(self) -> str:
continue
plugin_dirpath = self.plugins_dir / plugin_dirname
init_file = plugin_dirpath / "__init__.py"
with open(init_file) as f:
if not init_file.is_file():
logger.warning(f"No __init__.py in {plugin_dirpath}")
continue
with open(init_file, encoding='utf-8') as f:
plugin_registrations = [line for line in f if f"{self.registry_name}['{self.identifier}']"
in line.replace('\"', '\'')]
if len(plugin_registrations) > 0:
Expand Down

0 comments on commit f3f7da3

Please sign in to comment.