diff MoinMoin/wikiutil.py @ 132:88acc9c18b90

fixed some tests, fixed quote functions for non-str/non-unicode values (make str out of them) imported from: moin--main--1.5--patch-134
author Thomas Waldmann <tw@waldmann-edv.de>
date Sun, 23 Oct 2005 12:59:10 +0000
parents 2fba84615be7
children 206b3db4eade
line wrap: on
line diff
--- a/MoinMoin/wikiutil.py	Sun Oct 23 12:02:20 2005 +0000
+++ b/MoinMoin/wikiutil.py	Sun Oct 23 12:59:10 2005 +0000
@@ -108,9 +108,10 @@
                          unicode and not str, set this to True
                          Default is False.
     """
-    is_unicode = isinstance(s, unicode)
-    if is_unicode:
+    if isinstance(s, unicode):
         s = s.encode(config.charset)
+    elif not isinstance(s, str):
+        s = str(s)
     s = urllib.quote(s, safe)
     if want_unicode:
         s = s.decode(config.charset) # ascii would also work
@@ -127,9 +128,10 @@
                          unicode and not str, set this to True
                          Default is False.
     """
-    is_unicode = isinstance(s, unicode)
-    if is_unicode:
+    if isinstance(s, unicode):
         s = s.encode(config.charset)
+    elif not isinstance(s, str):
+        s = str(s)
     s = urllib.quote_plus(s, safe)
     if want_unicode:
         s = s.decode(config.charset) # ascii would also work
@@ -145,8 +147,7 @@
                          str and not unicode, set this to False.
                          Default is True.
     """
-    is_unicode = isinstance(s, unicode)
-    if is_unicode:
+    if isinstance(s, unicode):
         s = s.encode(config.charset) # ascii would also work
     s = urllib.unquote(s)
     if want_unicode:
@@ -177,7 +178,7 @@
     keyword parameters are ignored.
 
     @param qstr: dict to format as query string, using either ascii or unicode
-    @param kw: same as dict when using keywords, using assci or unicode
+    @param kw: same as dict when using keywords, using ascii or unicode
     @rtype: string
     @return: query string ready to use in a url
     """