diff --git a/mitogen/core.py b/mitogen/core.py index 1634b031..d2d20723 100644 --- a/mitogen/core.py +++ b/mitogen/core.py @@ -420,7 +420,7 @@ class Importer(object): 'utils', ]} self._lock = threading.Lock() - self.whitelist = whitelist or [''] + self.whitelist = list(whitelist) or [''] self.blacklist = list(blacklist) + [ # 2.x generates needless imports for 'builtins', while 3.x does the # same for '__builtin__'. The correct one is built-in, the other diff --git a/tests/importer_test.py b/tests/importer_test.py index 9d533752..55cad182 100644 --- a/tests/importer_test.py +++ b/tests/importer_test.py @@ -32,6 +32,8 @@ class ImporterBlacklist(testlib.TestCase): importer = mitogen.core.Importer( router=mock.Mock(), context=None, core_src='', ) + self.assertIsInstance(importer.whitelist, list) + self.assertIsInstance(importer.blacklist, list) self.assertFalse(mitogen.core.is_blacklisted_import(importer, 'mypkg')) self.assertFalse(mitogen.core.is_blacklisted_import(importer, 'mypkg.mod')) self.assertFalse(mitogen.core.is_blacklisted_import(importer, 'otherpkg')) @@ -44,6 +46,8 @@ class ImporterBlacklist(testlib.TestCase): router=mock.Mock(), context=None, core_src='', whitelist=('mypkg',), ) + self.assertIsInstance(importer.whitelist, list) + self.assertIsInstance(importer.blacklist, list) self.assertFalse(mitogen.core.is_blacklisted_import(importer, 'mypkg')) self.assertFalse(mitogen.core.is_blacklisted_import(importer, 'mypkg.mod')) self.assertTrue(mitogen.core.is_blacklisted_import(importer, 'otherpkg')) @@ -56,6 +60,8 @@ class ImporterBlacklist(testlib.TestCase): router=mock.Mock(), context=None, core_src='', blacklist=('mypkg',), ) + self.assertIsInstance(importer.whitelist, list) + self.assertIsInstance(importer.blacklist, list) self.assertTrue(mitogen.core.is_blacklisted_import(importer, 'mypkg')) self.assertTrue(mitogen.core.is_blacklisted_import(importer, 'mypkg.mod')) self.assertFalse(mitogen.core.is_blacklisted_import(importer, 'otherpkg')) @@ -68,6 +74,8 @@ class ImporterBlacklist(testlib.TestCase): router=mock.Mock(), context=None, core_src='', whitelist=('mypkg',), blacklist=('mypkg',), ) + self.assertIsInstance(importer.whitelist, list) + self.assertIsInstance(importer.blacklist, list) self.assertTrue(mitogen.core.is_blacklisted_import(importer, 'mypkg')) self.assertTrue(mitogen.core.is_blacklisted_import(importer, 'mypkg.mod')) self.assertTrue(mitogen.core.is_blacklisted_import(importer, 'otherpkg'))