Message3369

Author greg1
Recipients ThomasAH, alexis, brendan, mercurial-devel, mpm
Date 2007-06-27.15:07:36
Content
On Wed, Jun 27, 2007 at 12:39:40PM -0000, Thomas Arendsen Hein wrote:
>
> New submission from Thomas Arendsen Hein <thomas@intevation.de>:
>
> When importing mercurial.commands or mercurial.hgweb.hgwebdir_mod demandimport
> is automatically activated, but not for many other modules.
> This is not consistent, e.g. for hgweb.cgi or other tools importing parts of
> mercurial.
>
> My suggestion:
>
> Add "import mercurial.demandimport; mercurial.demandimport.enable()" to the hg
> and cgi scripts and let other applications decide for themselves whether they
> want to use it or not.
>
> Currently even our own setup.py uses
> mercurial.demandimport.enable = lambda: None
> to disable it ...

In fact, this is preventing us from upgrading to 0.9.4 for our Trac
installation --- 0.9.3 works fine but after upgrading we got
demandimport errors from unrelated modules:

# in mercurial/node.py, with `demandimport` enabled:

import binascii

# in Trac's acct_mgr/pwhash.py:

from binascii import hexlify
...
    v = long(hexlify(urandom(4)), 16)
# raises => TypeError: 'unloaded module' object is not callable

Christian from the Trac project attempted the following fix:

try:
    from mercurial import demandimport
    demandimport.enable = lambda : None
except ImportError:
    pass

Unfortunately this causes modules imported from mercurial to fail on
instantiation. Looking at the revision history from 0.9.3's
demandimport.py, all of the changes seem innocuous to me.
History
Date User Action Args
2007-06-27 15:07:38greg1setrecipients: + mpm, ThomasAH, brendan, alexis
2007-06-27 15:07:38greg1linkissue605 messages
2007-06-27 15:07:36greg1create