Unsafe import in bzrlib/index.py

John Arbash Meinel john at arbash-meinel.com
Wed Nov 14 16:25:36 GMT 2007


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

I just noticed this:

from bzrlib.lazy_import import lazy_import
lazy_import(globals(), """
from bzrlib import trace
from bzrlib.bisect_multi import bisect_multi_bytes
from bzrlib.revision import NULL_REVISION
from bzrlib.trace import mutter
""")

In general, it isn't safe to lazy import instances because you don't actually
access any members, and thus you don't actually trigger the lazy import code.
I'm actually surprised it was working. Maybe NULL_REVISION was just never present.

In general, I would recommend only using lazy_import to import modules, since
you don't have these problems.

John
=:->
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.7 (Darwin)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFHOyF/JdeBCYSNAAMRArt6AJ0QtqF7UK2a6qd9oHuohVp4YPMWvQCfQmMZ
ooZIR6tcB4AOf1OHufgyh3E=
=7bGi
-----END PGP SIGNATURE-----



More information about the bazaar mailing list