[pygobject] IntrospectionModule: __path__ should be List[str] and not str



commit 4208d1eab0da81a64f5fe0346e540140bd56072b
Author: Christoph Reiter <reiter christoph gmail com>
Date:   Sat Mar 10 18:54:28 2018 +0100

    IntrospectionModule: __path__ should be List[str] and not str
    
    This fixes a crash when calling help() on the module which got stricter with
    Python 3.7.
    
    It's a bit questionable why the type has __path__ in the first place as
    that's only meant for packages. But let's leave that for now.

 gi/module.py     | 5 +++--
 tests/test_gi.py | 6 ++++--
 2 files changed, 7 insertions(+), 4 deletions(-)
---
diff --git a/gi/module.py b/gi/module.py
index 0b226342..28569039 100644
--- a/gi/module.py
+++ b/gi/module.py
@@ -122,10 +122,11 @@ class IntrospectionModule(object):
         self._version = version
         self.__name__ = 'gi.repository.' + namespace
 
-        self.__path__ = repository.get_typelib_path(self._namespace)
+        path = repository.get_typelib_path(self._namespace)
+        self.__path__ = [path]
         if _have_py3:
             # get_typelib_path() delivers bytes, not a string
-            self.__path__ = self.__path__.decode('UTF-8')
+            self.__path__ = [path.decode('UTF-8')]
 
         if self._version is None:
             self._version = repository.get_version(self._namespace)
diff --git a/tests/test_gi.py b/tests/test_gi.py
index 2e2fed40..282a20f4 100644
--- a/tests/test_gi.py
+++ b/tests/test_gi.py
@@ -2973,8 +2973,10 @@ class TestKeywords(unittest.TestCase):
 
 class TestModule(unittest.TestCase):
     def test_path(self):
-        self.assertTrue(GIMarshallingTests.__path__.endswith('GIMarshallingTests-1.0.typelib'),
-                        GIMarshallingTests.__path__)
+        path = GIMarshallingTests.__path__
+        assert isinstance(path, list)
+        assert len(path) == 1
+        assert path[0].endswith('GIMarshallingTests-1.0.typelib')
 
     def test_str(self):
         self.assertTrue("'GIMarshallingTests' from '" in str(GIMarshallingTests),


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]