[MERGE] Fix for Bug 129299, BZR_PLUGIN_PATH should ignore trailiing slashes.

Blake Winton bwinton at latte.ca
Wed Aug 15 14:46:28 BST 2007


Alexander Belchenko wrote:
> +def strip_trailing_sep(path):
> +    return path.rstrip(os.sep)
> ^-- IMO, it's better to rstrip both \ or /, i.e. path.rstrip('\\/')
> because on windows you can use both of them for BZR_PLUGIN_PATH

Oh, yeah, good catch.  Fixed.  (I always forget you can do that...)

> +            os.environ['BZR_PLUGIN_PATH'] = "first\%s%ssecond\%s"% 
> (os.sep, os.pathsep, os.sep)
> ^-- why for backslashes here? (after 'first' and 'second')

I believe it's because I needed them to get it working when I was just 
using "first\\;second\\", but now that we're stripping both \ and /, it 
makes more sense to hard-code them as \ or /, and so I've done so, with 
a random (pathological?) number of each in the test.

A diff from my last patch follows, to highlight the changes:
=== modified file 'bzrlib/plugin.py'
--- bzrlib/plugin.py	2007-08-09 17:20:02 +0000
+++ bzrlib/plugin.py	2007-08-15 13:32:59 +0000
@@ -80,7 +80,7 @@
      _loaded = True

  def strip_trailing_sep(path):
-    return path.rstrip(os.sep)
+    return path.rstrip("\\/")

  def set_plugins_path():
      """Set the path for plugins to be loaded from."""

=== modified file 'bzrlib/tests/test_plugins.py'
--- bzrlib/tests/test_plugins.py	2007-08-09 15:28:27 +0000
+++ bzrlib/tests/test_plugins.py	2007-08-15 13:37:14 +0000
@@ -277,7 +277,7 @@
          old_env = os.environ.get('BZR_PLUGIN_PATH')
          try:
              bzrlib.plugins.__path__ = []
-            os.environ['BZR_PLUGIN_PATH'] = "first\%s%ssecond\%s"% 
(os.sep, os.pathsep, os.sep)
+            os.environ['BZR_PLUGIN_PATH'] = 
"first\\//\\%ssecond/\\/\\/"% (os.pathsep,)
              bzrlib.plugin.set_plugins_path()
              expected_path = ['first', 'second', 
os.path.dirname(bzrlib.plugins.__file__)]
              self.assertEqual(expected_path, bzrlib.plugins.__path__)

Thanks,
Blake.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: plugin_path3.patch
Type: text/x-patch
Size: 19852 bytes
Desc: not available
Url : https://lists.ubuntu.com/archives/bazaar/attachments/20070815/6f4d370b/attachment-0001.bin 


More information about the bazaar mailing list