After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 682051 - Import errors building with Python 3.3
Import errors building with Python 3.3
Status: RESOLVED FIXED
Product: pygobject
Classification: Bindings
Component: general
unspecified
Other Linux
: Normal normal
: ---
Assigned To: Nobody's working on this now (help wanted and appreciated)
Python bindings maintainers
Depends on:
Blocks:
 
 
Reported: 2012-08-16 23:03 UTC by Simon Feltman
Modified: 2012-08-21 06:02 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Fixed erronous import statements for Python 3.3 (2.00 KB, patch)
2012-08-16 23:12 UTC, Simon Feltman
none Details | Review

Description Simon Feltman 2012-08-16 23:03:08 UTC
While trying to build pygobject with Python 3.3 a few erronous import errors popped up do to changes in 3.3. It looks like using invalid items in fromlist for __import__ and PyImport_ImportModuleEx now raise an ImportError. I've logged: http://bugs.python.org/issue15715 just for tracking the behavioural change, but these things should be cleaned up on the pygobject side anyway.

$ python3.3 -c "import gi"
Traceback (most recent call last):
  • File "<stdin>", line 1 in <module>
  • File "/opt/gnome3/lib/python3.3/site-packages/gi/__init__.py", line 23 in <module>
    from ._gi import _API, Repository
ImportError: No module named 'gi._gobject.GTypeWrapper'

AND

$ make check
Traceback (most recent call last):
  File "./runtests.py", line 44, in <module>
    suite = loader.loadTestsFromNames(names)
  File "/usr/local/lib/python3.3/unittest/loader.py", line 137, in loadTestsFromNames
    suites = [self.loadTestsFromName(name, module) for name in names]
  File "/usr/local/lib/python3.3/unittest/loader.py", line 137, in <listcomp>
    suites = [self.loadTestsFromName(name, module) for name in names]
  File "/usr/local/lib/python3.3/unittest/loader.py", line 96, in loadTestsFromName
    module = __import__('.'.join(parts_copy))
  File "/home/simon/src/gnome3/pygobject/tests/test_gobject.py", line 6, in <module>
    from gi.repository import GObject
  File "/home/simon/src/gnome3/pygobject/gi/importer.py", line 76, in load_module
    dynamic_module._load()
  File "/home/simon/src/gnome3/pygobject/gi/module.py", line 244, in _load
    overrides_modules = __import__('gi.overrides', fromlist=[self._namespace])
ImportError: No module named 'gi.overrides.GObject'
Comment 1 Simon Feltman 2012-08-16 23:12:51 UTC
Created attachment 221523 [details] [review]
Fixed erronous import statements for Python 3.3

Updated pygobject/gi/pygobject-external to use GType (which is
what GTypeWrapper is exposed as) instead of GTypeWrapper when
attempting import.
Added try/except on ImportError around attempted imports of
a typelibs override file which don't always exist (GObject...)
Comment 2 Martin Pitt 2012-08-20 12:38:24 UTC
With python3.3 I also encounter another problem which happens even earlier:

Traceback (most recent call last):
  • File "./runtests.py", line 44 in <module>
    suite = loader.loadTestsFromNames(names)
  • File "/usr/lib/python3.3/unittest/loader.py", line 137 in loadTestsFromNames
    suites = [self.loadTestsFromName(name, module) for name in names]
  • File "/usr/lib/python3.3/unittest/loader.py", line 137 in <listcomp>
    suites = [self.loadTestsFromName(name, module) for name in names]
  • File "/usr/lib/python3.3/unittest/loader.py", line 96 in loadTestsFromName
    module = __import__('.'.join(parts_copy))
  • File "/home/martin/upstream/pygobject/tests/test_unknown.py", line 5 in <module>
    from gi.repository import GObject
  • File "<frozen importlib._bootstrap>", line 1421 in _find_and_load
  • File "<frozen importlib._bootstrap>", line 1372 in _find_and_load_unlocked
  • File "/home/martin/upstream/pygobject/gi/__init__.py", line 23 in <module>
    from ._gi import _API, Repository
ValueError: level must be >= 0

Don't you get this as well?
Comment 3 Martin Pitt 2012-08-20 12:44:04 UTC
My previous comment looks like http://bugs.python.org/issue15610.

Your patch looks good, though, and does work fine with Python 2.7 and 3.2, so I pushed it. Thanks!
Comment 4 Simon Feltman 2012-08-21 01:51:41 UTC
Hi Martin,
I was testing with the beta 2 which looks like http://bugs.python.org/issue15610 was fixed so I didn't run into it.

It seems the python devs are recommending using importlib instead of __import__ so I've logged: https://bugzilla.gnome.org/show_bug.cgi?id=682320

The next thing I ran into with python 3.3 is logged here: https://bugzilla.gnome.org/show_bug.cgi?id=682323
Comment 5 Martin Pitt 2012-08-21 06:02:58 UTC
Ah, right. I used 3.3beta1 for testing.