This issue tracker has been migrated to GitHub ,
and is currently read-only.
For more information,
see the GitHub FAQs in the Python's Developer Guide.
Created on 2011年12月06日 01:02 by alex, last changed 2022年04月11日 14:57 by admin. This issue is now closed.
| Files | ||||
|---|---|---|---|---|
| File name | Uploaded | Description | Edit | |
| x.diff | alex, 2011年12月06日 01:05 | review | ||
| Messages (6) | |||
|---|---|---|---|
| msg148897 - (view) | Author: Alex Gaynor (alex) * (Python committer) | Date: 2011年12月06日 01:02 | |
In 2.7 ast.literal_eval blows up with a set for input:
>>> import ast
>>> ast.literal_eval("{1}")
|
|||
| msg148898 - (view) | Author: Alex Gaynor (alex) * (Python committer) | Date: 2011年12月06日 01:05 | |
Patch with tests |
|||
| msg148899 - (view) | Author: Brian Curtin (brian.curtin) * (Python committer) | Date: 2011年12月06日 01:14 | |
I don't profess to have any special ast knowledge, but given the context around there and the fact that it works...it looks fine to me. |
|||
| msg148900 - (view) | Author: Alyssa Coghlan (ncoghlan) * (Python committer) | Date: 2011年12月06日 01:29 | |
Dict and Set comprehensions are also broken:
>>> {1 for x in ()}
set([])
>>> {1:2 for x in ()}
{}
>>> ast.literal_eval("{1 for x in ()}")
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib64/python2.7/ast.py", line 80, in literal_eval
return _convert(node_or_string)
File "/usr/lib64/python2.7/ast.py", line 79, in _convert
raise ValueError('malformed string')
ValueError: malformed string
>>> ast.literal_eval("{1:2 for x in ()}")
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib64/python2.7/ast.py", line 80, in literal_eval
return _convert(node_or_string)
File "/usr/lib64/python2.7/ast.py", line 79, in _convert
raise ValueError('malformed string')
ValueError: malformed string
|
|||
| msg148901 - (view) | Author: Alex Gaynor (alex) * (Python committer) | Date: 2011年12月06日 01:32 | |
There's no support for comprehensions of any sort, and confusingly limited support for arithmetic ops, I'd like to keep the scope of this issue small, basically backporting 90bf0631bfb8 and adding the tests (which I can also add to default). |
|||
| msg148910 - (view) | Author: Georg Brandl (georg.brandl) * (Python committer) | Date: 2011年12月06日 11:51 | |
Alex: IMO the operator support is only required for complex "literals". |
|||
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2022年04月11日 14:57:24 | admin | set | github: 57745 |
| 2011年12月06日 11:51:13 | georg.brandl | set | messages: + msg148910 |
| 2011年12月06日 01:47:59 | benjamin.peterson | set | status: open -> closed resolution: not a bug superseder: ast.literal_eval does not handled new set literals |
| 2011年12月06日 01:32:12 | alex | set | messages: + msg148901 |
| 2011年12月06日 01:29:19 | ncoghlan | set | messages: + msg148900 |
| 2011年12月06日 01:14:47 | brian.curtin | set | nosy:
+ brian.curtin messages: + msg148899 |
| 2011年12月06日 01:08:58 | pitrou | set | nosy:
+ brett.cannon, georg.brandl, ncoghlan, benjamin.peterson |
| 2011年12月06日 01:05:24 | alex | set | files:
+ x.diff keywords: + patch messages: + msg148898 |
| 2011年12月06日 01:02:39 | alex | create | |