Changeset - c0b0351233ec
[Not reviewed]
beta
0 1 0
Marcin Kuzminski - 13 years ago 2013-01-24 01:20:03
marcin@python-works.com
safe_int should also catch TypeError
1 file changed with 1 insertions and 1 deletions:
0 comments (0 inline, 0 general)
rhodecode/lib/utils2.py
Show inline comments
 
@@ -173,25 +173,25 @@ def generate_api_key(username, salt=None
 

	
 
def safe_int(val, default=None):
 
    """
 
    Returns int() of val if val is not convertable to int use default
 
    instead
 

	
 
    :param val:
 
    :param default:
 
    """
 

	
 
    try:
 
        val = int(val)
 
    except ValueError:
 
    except (ValueError, TypeError):
 
        val = default
 

	
 
    return val
 

	
 

	
 
def safe_unicode(str_, from_encoding=None):
 
    """
 
    safe unicode function. Does few trick to turn str_ into unicode
 

	
 
    In case of UnicodeDecode error we try to return it with encoding detected
 
    by chardet library if it fails fallback to unicode with errors replaced
 

	
0 comments (0 inline, 0 general)