[MERGE] Fix for Bug 129299, BZR_PLUGIN_PATH should ignore trailiing slashes.
John Arbash Meinel
john at arbash-meinel.com
Thu Aug 9 16:53:06 BST 2007
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Blake Winton wrote:
> Robert Collins wrote:
>> Robert Collins has voted resubmit.
>> Status is now: Resubmit
>> Comment:
>> Couple of things. If load_from_path is now accepting paths with '/',
>> then you shouldn't need to santise BZR_PLUGINS_PATH - the lower level
>> check will suffice.
>
> I thought that, but set_plugins_path seems to get called from
> __init__.py without a following call to load_from_path.
>
> Is load_from_path guaranteed to be called to load a plugin, or is there
> another way someone could access plugins.__path__? (i.e. from plugins
> import xxx...) Alternatively, if we're not using plugins.__path__, why
> do we set it?
>
> bzrlib/plugin.py says at lines 27-29:
> BZR_PLUGIN_PATH is also honoured for any plugins imported via
> 'import bzrlib.plugins.PLUGINNAME', as long as set_plugins_path has been
> called.
> But that won't work unless we sanitize plugins.__path__ since it doesn't
> call load_from_dirs. (I also thought about doing the check only in
> set_plugins_path, but tests for load_from_dirs which pass in a set of
> directories don't necessarily call set_plugins_path, and so wouldn't get
> sanitized.)
>
> I guess, in the end, I just felt "hinky" about storing an invalid path
> in plugins.__path__, since Python could try to use it for something. If
> you think that's okay, I'ld be more than happy to only sanitize the data
> once, in load_from_path.
>
The reason we set plugins.__path__ is explicitly so that plugins can do
"from bzrlib.plugins.other_plugin import x". So yeah, I would make sure
that the __path__ variable is correct.
In fact, it would be reasonable to just assert it is correct in
load_from_path, rather than sanitizing it again. (I'm fine with doing
either, but we should have __path__ be correct.)
John
=:->
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
iD8DBQFGuzhiJdeBCYSNAAMRAnklAJ0b2pHZO/CILVH08exdYfnafleZxwCcDlGi
P8p7Mny8CeOkyI3cRCz7mO0=
=5N7Q
-----END PGP SIGNATURE-----
More information about the bazaar
mailing list