ast.literal_eval throws a syntax error in Python 3 when passed a string like "01". In Python 2, ast.literal_eval parses this string to 1. The behavior has been changed to return the original, unparsed value if an exception is thrown. Errors such as this should be caught by the initial input validation logic. The only reason that this occurred is that bad data got through the initial form validation.
Note that there was a bug where the wrong variable was returned and a NameError was thrown. This has been fixed.
While working on the issue above, I noticed that the input value validation logic needed some serious work. I spent some time trying to get the pyparser library to work as expected, but I was unsuccessful. Thus, I wrote an is_safe function that tests:
how long is the input string?
for each value in a comma separated value string:
ast.literal_eval
throws a syntax error in Python 3 when passed a string like"01"
. In Python 2,ast.literal_eval
parses this string to1
. The behavior has been changed to return the original, unparsed value if an exception is thrown. Errors such as this should be caught by the initial input validation logic. The only reason that this occurred is that bad data got through the initial form validation.Note that there was a bug where the wrong variable was returned and a
NameError
was thrown. This has been fixed.While working on the issue above, I noticed that the input value validation logic needed some serious work. I spent some time trying to get the
pyparser
library to work as expected, but I was unsuccessful. Thus, I wrote anis_safe
function that tests:Also, this resolves #924