GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | ||||||||||||||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | ||||||||||||||||||||||||||
GeezerVison is showing github.com — bpo-39159: Declare errors that might be raised from literal_eval by isidentical · Pull Request #19899 · python/cpython Conversation
|
| container display. The string or node provided may only consist of the | ||
| following Python literal structures: strings, bytes, numbers, tuples, lists, | ||
| dicts, sets, booleans, and ``None``. | ||
| dicts, sets, booleans, ``None`` and ``Ellipsis``. |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Let's also take this opportunity to be more specific about what is meant by "numbers". Replace that with "ints, floats, complex numbers".
Also, please make the same update to the docstring for ast.literal_eval().
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| It can raise :exc:`ValueError`, :exc:`TypeError`, :exc:`SyntaxError`, | ||
| :exc:`MemoryError` and :exc:`RecursionError` depending on the malformed | ||
| input. | ||
|
|
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Just for my edification and for future reference, can you add a non-displayed in-line documentation comment showing an example of how each of these could happen.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
import ast recursion_tuple = ast.Tuple(elts=[], ctx=ast.Load()) recursion_tuple.elts.append(recursion_tuple) INPUTS = [ ("invalid syntax", SyntaxError), ("test", ValueError), (ast.List(elts=None, ctx=ast.Load()), TypeError), (recursion_tuple, RecursionError), ] for inp, exc_type in INPUTS: try: ast.literal_eval(inp) except exc_type: continue else: assert False
does something like this suits?
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
@rhettinger or maybe we can put this in an actual test in test_ast and refer it? How does that sounds?
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Ping, @rhettinger? |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Triggering a rebuild. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
There was an error while loading. Please reload this page.