mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +00:00
bpo-39158: ast.literal_eval() doesn't support empty sets (GH-17742)
This commit is contained in:
parent
32f1443aa9
commit
4fcf5c12a3
4 changed files with 8 additions and 0 deletions
|
@ -83,6 +83,9 @@ def literal_eval(node_or_string):
|
|||
return list(map(_convert, node.elts))
|
||||
elif isinstance(node, Set):
|
||||
return set(map(_convert, node.elts))
|
||||
elif (isinstance(node, Call) and isinstance(node.func, Name) and
|
||||
node.func.id == 'set' and node.args == node.keywords == []):
|
||||
return set()
|
||||
elif isinstance(node, Dict):
|
||||
return dict(zip(map(_convert, node.keys),
|
||||
map(_convert, node.values)))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue