Skip to content
GitLab
Projects Groups Topics Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Register
  • Sign in
  • M mercurial_keyring
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributor statistics
    • Graph
    • Compare revisions
  • Issues 7
    • Issues 7
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 1
    • Merge requests 1
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Container Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • mercurialmercurial
  • mercurial_keyring
  • Issues
  • #24
Closed
Open
Issue created Jun 24, 2013 by Bitbucket Importer@bitbucket_importerOwner

demandimport error - AttributeError: 'module' object has no attribute 'ModuleType'

Created originally on Bitbucket by SimonSapin (Simon Sapin)

Mercurial fails to load the extension:

$ hg --traceback status
*** failed to import extension mercurial_keyring: 'module' object has no attribute 'ModuleType'
Traceback (most recent call last):
  File "/usr/lib/python2.7/site-packages/mercurial/extensions.py", line 92, in loadall
    load(ui, name, path)
  File "/usr/lib/python2.7/site-packages/mercurial/extensions.py", line 79, in load
    mod = importh(name)
  File "/usr/lib/python2.7/site-packages/mercurial/extensions.py", line 69, in importh
    mod = __import__(name)
  File "/usr/lib/python2.7/site-packages/mercurial/demandimport.py", line 95, in _demandimport
    return _import(name, globals, locals, fromlist, level)
  File "/home/simon/.local/lib/python2.7/site-packages/mercurial_keyring.py", line 61, in <module>
    import keyring
  File "/usr/lib/python2.7/site-packages/mercurial/demandimport.py", line 95, in _demandimport
    return _import(name, globals, locals, fromlist, level)
  File "/home/simon/.local/lib/python2.7/site-packages/keyring/__init__.py", line 9, in <module>
    from core import (set_keyring, get_keyring, set_password, get_password,
  File "/usr/lib/python2.7/site-packages/mercurial/demandimport.py", line 114, in _demandimport
    mod = _origimport(name, globals, locals)
  File "/home/simon/.local/lib/python2.7/site-packages/keyring/core.py", line 166, in <module>
    init_backend()
  File "/home/simon/.local/lib/python2.7/site-packages/keyring/core.py", line 65, in init_backend
    keyrings.sort(key = lambda x: -x.supported())
  File "/home/simon/.local/lib/python2.7/site-packages/keyring/core.py", line 65, in <lambda>
    keyrings.sort(key = lambda x: -x.supported())
  File "/home/simon/.local/lib/python2.7/site-packages/keyring/backends/Gnome.py", line 15, in supported
    from gi.repository import GnomeKeyring
  File "/usr/lib/python2.7/site-packages/mercurial/demandimport.py", line 95, in _demandimport
    return _import(name, globals, locals, fromlist, level)
  File "/usr/lib/python2.7/site-packages/gi/repository/__init__.py", line 25, in <module>
    from ..importer import DynamicImporter
  File "/usr/lib/python2.7/site-packages/mercurial/demandimport.py", line 112, in _demandimport
    return _origimport(name, globals, locals, fromlist, level)
  File "/usr/lib/python2.7/site-packages/gi/importer.py", line 28, in <module>
    from .module import DynamicModule
  File "/usr/lib/python2.7/site-packages/mercurial/demandimport.py", line 112, in _demandimport
    return _origimport(name, globals, locals, fromlist, level)
  File "/usr/lib/python2.7/site-packages/gi/module.py", line 273, in <module>
    class DynamicModule(types.ModuleType):
  File "/usr/lib/python2.7/site-packages/mercurial/demandimport.py", line 87, in __getattribute__
    return getattr(self._module, attr)
AttributeError: 'module' object has no attribute 'ModuleType'

Fiddling with demandimport.py shows that types in types.ModuleType is the gi.types module instead of the stdlib’s types. The from __future__ import absolute_import line in the same file does not seem to take effect.

On the same system, python2 -c 'import mercurial_keyring' runs without an exception.

I though this would reproduce the issue outside of Mercurial, but it didn’t:

python2 -c 'import mercurial.demandimport as d; d.enable(); import mercurial_keyring'

GObject 3.8.2 Python 2.7.5 Mercurial 2.6.2 mercurial_keyring 0.5.5

To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information
Assignee
Assign to
Time tracking