Bruno Martin avatar Bruno Martin committed 9e881eb

removed decode from return string, but leaves the tests to check if everything is unicode.

Comments (0)

Files changed (2)

MoinMoin/util/_tests/test_interwiki.py

 
     def test__split_namespace(self):
         map = set()
-        map.add('ns1')
-        map.add('ns1:ns2')
+        map.add(u'ns1')
+        map.add(u'ns1:ns2')
         tests = [('', ('', '')),
                  ('OtherWiki:', ('', 'OtherWiki:')),
                  ('ns1:', ('ns1', '')),
         for markup, (namespace, pagename) in tests:
             assert _split_namespace(map, markup) == (namespace, pagename)
             (namespace, pagename) = _split_namespace(map, markup)
-            assert isinstance(namespace, unicode)
-            assert isinstance(pagename, unicode)
 
     def test_split_interwiki(self):
         app.cfg.namespace_mapping = [(u'', 'default_backend'), (u'ns1:', 'default_backend'), (u'ns1:ns2:', 'other_backend')]

MoinMoin/util/interwiki.py

     if namespace:
         length = len(namespace) + 1
         url = url[length:]
-    return namespace.decode('utf-8'), url.decode('utf-8')
+    return namespace, url
 
 def split_interwiki(wikiurl):
     """ Split a interwiki name, into wikiname and pagename, e.g:
     :rtype: tuple
     :returns: (wikiname, namespace, pagename)
     """
+    if not isinstance(wikiurl, unicode):
+        wikiurl = wikiurl.decode('utf-8')
     namespace_mapping = set()
     for namespace, _ in app.cfg.namespace_mapping:
         namespace_mapping.add(namespace.rstrip(':'))
     # Base case: no colon in wikiurl
     if not ':' in wikiurl:
-        return u'Self', u'', wikiurl.decode('utf-8')
+        return u'Self', u'', wikiurl
     if not wikiurl.startswith(':'):
         wikiname, item_name = _split_namespace(set(app.cfg.interwiki_map.keys()), wikiurl)
         namespace = u''
             if ':' in wikiname:
                 namespace = wikiname.split(':', 1)[1]
                 wikiname = wikiname.split(':', 1)[0]
-        return wikiname.decode('utf-8'), namespace.decode('utf-8'), item_name.decode('utf-8')
+        return wikiname, namespace, item_name
     else:
         namespace, item_name =  _split_namespace(set(namespace_mapping), wikiurl.split(':', 1)[1])
         if not namespace:
             item_name = u':{0}'.format(item_name)
-        return u'Self', namespace.decode('utf-8'), item_name.decode('utf-8')
+        return u'Self', namespace, item_name
 
 def join_wiki(wikiurl, wikitail, namespace):
     """
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.