changeset 2509:a55a20b092a2

make get_int safer, fix get_unicode(arg=u'')
author Johannes Berg <johannes AT sipsolutions DOT net>
date Sun, 22 Jul 2007 16:08:37 +0200
parents 552e748b86cd
children f6a777f45559
files MoinMoin/wikiutil.py
diffstat 1 files changed, 3 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/MoinMoin/wikiutil.py	Sun Jul 22 15:59:12 2007 +0200
+++ b/MoinMoin/wikiutil.py	Sun Jul 22 16:08:37 2007 +0200
@@ -1361,7 +1361,8 @@
 def get_int(request, arg, name=None, default=None):
     """
     For use with values returned from parse_quoted_separated or given
-    as macro parameters, return an integer from a unicode string.
+    as macro parameters, return an integer from a unicode string
+    containing the decimal representation of a number.
     The empty string or None are valid input and yield the default value.
 
     @param request: A request instance
@@ -1378,7 +1379,7 @@
     elif not isinstance(arg, unicode):
         raise TypeError('argument must be None or unicode')
     try:
-        arg = int(arg, 0)
+        arg = int(arg)
     except ValueError:
         if name:
             raise ValueError(_('Argument "%s" must be an integer value') % name)
@@ -1434,8 +1435,6 @@
         return default
     elif not isinstance(arg, unicode):
         raise TypeError('argument must be None or unicode')
-    elif arg == u'':
-        return default
 
     return arg