[MERGE] allow 'import bzrlib.plugins.NAME'
Robert Collins
robertc at robertcollins.net
Fri Feb 2 20:23:13 GMT 2007
On Fri, 2007-02-02 at 14:07 -0600, John Arbash Meinel wrote:
> What is the traceback in ~/.bzr.log? Having "unable to load" at least
> tells someone something is wrong.
>
> If you are going to have a check, I would actually prefer:
>
> if not re.match('\w+'):
> warning('Unable to load plugin %r from %r: '
> 'It is not a valid python module name.' % (name, d))
>
> That way we handle 'foo.bar' which is also invalid. And might actually
> cause problems based on what you are doing (import bzrlib.foo.bar)
> imports something different.
Discussed on irc: re.search('\.-') is a good start.
>
> __import__ returns something different than 'import' does. I think it
> has more to do with what it does to locals() and globals() than anything
> else.
>
> I just avoid exec() and eval(). If I see it, it makes me wonder if the
> code is correct.
import is a statement, I dont think it returns anything.
I'll change it to 'exec "import bzrlib.plugins.%s" % name in {}' to
address any chance of it altering the current namespace.
Ok now?
-Rob
--
GPG key available at: <http://www.robertcollins.net/keys.txt>.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part
Url : https://lists.ubuntu.com/archives/bazaar/attachments/20070203/7168839a/attachment.pgp
More information about the bazaar
mailing list