Message164684
Of course `nan` and `inf` are part of the syntax! The `ast.parse` function recognize them as `Name`.
So that works:
>>> ast.dump(ast.parse('True'))
"Module(body=[Expr(value=Name(id='True', ctx=Load()))])"
>>> ast.dump(ast.parse('inf'))
"Module(body=[Expr(value=Name(id='inf', ctx=Load()))])"
>>> inf = float('inf')
>>> eval('inf')
inf
I've run into some literals with `Ellipsis` and `inf` and couldn't load them with literal_eval. That's why I'm proposing that.
The thing about `nan` and `inf` is because they are the *only* representations of float numbers produced by the interpreter that cannot be loaded.
Something like that could solve the problem keeping `literal_eval` safe and allowing other names:
ast.literal_eval('[1.0, 2.0, inf]', {'inf': float('inf')}) |
|
Date |
User |
Action |
Args |
2012-07-05 15:48:05 | JBernardo | set | recipients:
+ JBernardo, mark.dickinson, benjamin.peterson, daniel.urban |
2012-07-05 15:48:05 | JBernardo | set | messageid: <1341503285.8.0.0409777709765.issue15245@psf.upfronthosting.co.za> |
2012-07-05 15:48:05 | JBernardo | link | issue15245 messages |
2012-07-05 15:48:04 | JBernardo | create | |
|