[issue17490] Use converter functions to implement ast.literal_eval

Nick Coghlan report at bugs.python.org
Thu Mar 21 02:44:04 CET 2013


Nick Coghlan added the comment:

Updated patch attached. The complexity grew a bit, as it turned out to be useful for the converter functions to be able to tell the difference between top level conversions and recursive invocations. I also realised that:

- the complex number conversion currently allows arbitrarily deep nesting of addition and subtraction
- handling this properly made an exception based "Failed to convert" API far more sensible

The docstrings are updated, but ast.convert_node is tested only indirectly through the ast.literal_eval tests and the main docs haven't been updated at all.

At this point, I'm most interested in feedback from Larry as to whether or not this is helpful to him in implementing argument clinic.

----------
Added file: http://bugs.python.org/file29520/issue17490_ast_literal_eval_converters.diff

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue17490>
_______________________________________


More information about the Python-bugs-list mailing list