Skip to content

Commit

Permalink
Merge pull request #367 from davidlatwe/py3-unicode-plugin
Browse files Browse the repository at this point in the history
Support loading unicode contained plugin in Python 3
  • Loading branch information
mottosso authored Apr 4, 2020
2 parents 1431dd5 + 41a9803 commit 3290fd5
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 2 deletions.
2 changes: 1 addition & 1 deletion pyblish/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -1337,7 +1337,7 @@ def discover(type=None, regex=None, paths=None):
module.__file__ = abspath

try:
with open(abspath) as f:
with open(abspath, "rb") as f:
six.exec_(f.read(), module.__dict__)

# Store reference to original module, to avoid
Expand Down
2 changes: 1 addition & 1 deletion pyblish/version.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

VERSION_MAJOR = 1
VERSION_MINOR = 8
VERSION_PATCH = 6
VERSION_PATCH = 7

version_info = (VERSION_MAJOR, VERSION_MINOR, VERSION_PATCH)
version = '%i.%i.%i' % version_info
Expand Down
19 changes: 19 additions & 0 deletions tests/test_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -1006,3 +1006,22 @@ def my_plugin_filter(plugins):
pyblish.api.deregister_discovery_filter(my_plugin_filter)
plugins = pyblish.api.discover()
assert len(plugins) == 1, plugins


@with_setup(lib.setup_empty, lib.teardown)
def test_discovering_unicode_contained_plugin():
unicode_plugin = b"""
import pyblish.api
class UnicodePlugin(pyblish.api.InstancePlugin):
label = "\xf0\x9f\xa4\xa8"
"""

with lib.tempdir() as d:
pyblish.api.register_plugin_path(d)

with open(os.path.join(d, "unicode_plugin.py"), "wb") as f:
f.write(unicode_plugin)

plugins = [p.__name__ for p in pyblish.api.discover()]
assert plugins == ["UnicodePlugin"]

0 comments on commit 3290fd5

Please sign in to comment.