[MERGE] Fix for Bug 129299, BZR_PLUGIN_PATH should ignore trailiing slashes.
Blake Winton
bwinton at latte.ca
Thu Aug 9 16:46:34 BST 2007
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.
> Finally, your test that
> load_from_path works with '/' is clearly cargo culted - I suggest you
> read through it once and make sure the comments match what your test
> actually does - the don't currently.
Yup. I believe I've fixed it now.
I'll resubmit after I get a response to the first question above.
Later,
Blake.
More information about the bazaar
mailing list