[issue605] demandimport surprises unsuspecting programmers
Gregory Collins
greg at maptuit.com
Wed Jun 27 08:56:08 CDT 2007
On Wed, Jun 27, 2007 at 12:39:40PM -0000, Thomas Arendsen Hein wrote:
>
> New submission from Thomas Arendsen Hein <thomas at 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.
--
Gregory Collins <greg at maptuit.com>
More information about the Mercurial-devel
mailing list