Issue #31 wontfix

demandimport error - *** failed to import extension mercurial_keyring: 'module' object has no attribute 'system'

Matt Joiner
created an issue
matt@netbook:~/src/go/src$ pip list | grep keyring
keyring (3.0.1)
mercurial-keyring (0.6.0)
matt@netbook:~/src/go/src$ python2 -c 'import mercurial.demandimport as d; d.enable(); import mercurial_keyring; from mercurial_keyring import PasswordStore'
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/usr/lib/python2.7/dist-packages/mercurial/demandimport.py", line 114, in _demandimport
    mod = _origimport(name, globals, locals)
  File "/usr/local/lib/python2.7/dist-packages/mercurial_keyring.py", line 82, in <module>
    import keyring
  File "/usr/lib/python2.7/dist-packages/mercurial/demandimport.py", line 95, in _demandimport
    return _import(name, globals, locals, fromlist, level)
  File "/usr/local/lib/python2.7/dist-packages/keyring/__init__.py", line 12, in <module>
    from .core import (set_keyring, get_keyring, set_password, get_password,
  File "/usr/lib/python2.7/dist-packages/mercurial/demandimport.py", line 112, in _demandimport
    return _origimport(name, globals, locals, fromlist, level)
  File "/usr/local/lib/python2.7/dist-packages/keyring/core.py", line 166, in <module>
    init_backend()
  File "/usr/local/lib/python2.7/dist-packages/keyring/core.py", line 58, in init_backend
    keyring = load_config()
  File "/usr/local/lib/python2.7/dist-packages/keyring/core.py", line 127, in load_config
    config_path = os.path.join(platform.data_root(), filename)
  File "/usr/lib/python2.7/dist-packages/mercurial/demandimport.py", line 86, in __getattribute__
    self._load()
  File "/usr/lib/python2.7/dist-packages/mercurial/demandimport.py", line 58, in _load
    mod = _origimport(head, globals, locals)
  File "/usr/local/lib/python2.7/dist-packages/keyring/util/platform.py", line 24, in <module>
    data_root = globals().get('_data_root_' + platform.system(), _data_root_Linux)
  File "/usr/lib/python2.7/dist-packages/mercurial/demandimport.py", line 87, in __getattribute__
    return getattr(self._module, attr)
AttributeError: 'module' object has no attribute 'system'
matt@netbook:~/src/go/src$ uname -a
Linux netbook 3.8.0-29-generic #42-Ubuntu SMP Tue Aug 13 19:40:39 UTC 2013 x86_64 x86_64 x86_64 GNU/Linux
matt@netbook:~/src/go/src$ hg version
*** failed to import extension mercurial_keyring: 'module' object has no attribute 'system'
Mercurial Distributed SCM (version 2.2.2)

Comments (22)

  1. Jason R. Coombs

    We can probably fix this in keyring, but I do want to get a feel for how things will go upstream first. Before your comment, My feeling was that the issue emerged recently in keyring so was due to early adoption of keyring which would suggest the likelihood of early adoption of Mercurial updates as well.

    Since that's not the case, and that's surely not a reason not to address the issue, would you be willing to share a bit more about your environment and why updating keyring is important but why you stick to older versions of Mercurial? I ask for my edification and curiosity more than anything.

  2. Matt Joiner reporter

    I don't believe mercurial_keyring or keyring are packaged in Ubuntu 13.04. This is all. I stick to the system packaged versions of Mercurial because I use several Mercurial tools that rely on the system version.

  3. Matt Joiner reporter

    You may be interested to know that the next release of Ubuntu, has decided to package mercurial_keyring 0.5.6, probably for the same reasons I have to try to use this version. Unfortunately it's not available via pip anymore.

  4. Marcin Kasperski repo owner

    If you take a look at the list of past issues in mercurial_keyring, you may note that most of them are similar to this one: keyring itself or some keyring backend imports some library, mercurial's demandimport fires and destroys import, I get the error.

    Then I am to guess what to blacklist so demandimport stops spoiling things (and I usually don't have backend in charge installed or even OS on which the problem happens, so I can't test anything).

    I must say I have enough.

    I won't guess anymore. I gladly accept patches which extend those demandimport blacklists, I promise to quickly number and distribute releases, but I am fed up with discussions like „try blacklisting this and this. DId not help? Well, maybe try that? ...”

    Do you want this bug fixed? Open the source here: https://bitbucket.org/Mekk/mercurial_keyring/src/tip/mercurial_keyring.py?at=default#cl-52 , try adding things to blacklist until mercurial stops spoiling things, then offer me pull request.

    Or maybe persuade mercurial authors that this demandimport idea isn't so great, they saved an hour or two thanks to not writing "from mercurial import something" lines, people who extend mercurial spend time facing issues as this one.

  5. Jason R. Coombs

    Hi Marcin. I value your time and respect your pain. For this issue and related ones, I've taken in late versions of keyring to explicitly force imports by accessing a module attribute early, so these issues should be minimized in the future.

    But I agree - it's absolutely not fair to you to ask you to guess at blacklists. And yes, the demandimport idea is annoying, but my understanding is it's a necessary pain for mercurial to have reasonable startup performance.

  6. Marcin Kasperski repo owner

    If anyone still faces it, it would be much better to check what must be blacklisted (as sooner or later next person is to face the same library versions combination). As I said, I am OK with accepting those blacklisting changes, I just don't want to guess myself.

  7. Katsunori FUJIWARA

    The patch to fix root cause of this issue is imported into main repository of Mercurial itself.

    http://selenic.com/repo/hg/rev/e3a5922e18c3
    

    2.8-rc or later releases should include this fix.

  8. Franck Bret

    I had the same issue on Ubuntu 13.10 while installing the packaged deb that install mercurial-keyring 0.5.5. Just force the python package upgrade with "sudo pip install mercurial_keyring --upgrade" It will install 0.6.1 and solve that issue

  9. Log in to comment