Merge pull request #3702 from guerler/fix_boolean_handling

Properly handle boolean values when parsed to a string-based/default tool parameter
This commit is contained in:
Dannon Baker
2017-03-08 13:05:04 -05:00
committed by GitHub
2 changed files with 4 additions and 4 deletions
-3
View File
@@ -2,7 +2,6 @@
Basic tool parameters.
"""
import logging
import numbers
import os
import os.path
import re
@@ -131,8 +130,6 @@ class ToolParameter( object, Dictifiable ):
def to_python( self, value, app ):
"""Convert a value created with to_json back to an object representation"""
if isinstance( value, numbers.Number ):
return unicodify( value )
return value
def value_to_basic( self, value, app, use_security=False ):
+4 -1
View File
@@ -56,10 +56,13 @@ def swap_inf_nan( val ):
def safe_loads( arg ):
"""
This is a wrapper around loads that returns the parsed value instead of
raising a value error.
raising a value error. It also avoids autoconversion of non-iterables
i.e numeric and boolean values.
"""
try:
loaded = json.loads( arg )
if loaded is not None and not isinstance( loaded, collections.Iterable ):
loaded = arg
except ( TypeError, ValueError ):
loaded = arg
return loaded