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 2010年10月13日 19:36 by nestor, last changed 2022年04月11日 14:57 by admin. This issue is now closed.
| Messages (7) | |||
|---|---|---|---|
| msg118568 - (view) | Author: nestor (nestor) | Date: 2010年10月13日 19:36 | |
>>> import ast
>>> eval('{1:11,2:22}')
{1: 11, 2: 22}
>>> ast.literal_eval('{1:11,2:22}')
{1: 11, 2: 22}
>>> eval('{1,2}')
{1, 2}
>>> ast.literal_eval('{1,2}')
Traceback (most recent call last):
File "<pyshell#8>", line 1, in <module>
ast.literal_eval('{1,2}')
File "C:\Python31\lib\ast.py", line 80, in literal_eval
return _convert(node_or_string)
File "C:\Python31\lib\ast.py", line 79, in _convert
raise ValueError('malformed string')
ValueError: malformed string
>>>
I haven't tested for 2.7 or 3.2 but this bug probably applies also there.
|
|||
| msg118571 - (view) | Author: Georg Brandl (georg.brandl) * (Python committer) | Date: 2010年10月13日 19:58 | |
This is fixed in 3.2 (see r82804). As it is a new feature, it is not backported to 2.7 or earlier. |
|||
| msg119054 - (view) | Author: Éric Araujo (eric.araujo) * (Python committer) | Date: 2010年10月18日 18:14 | |
Set literals, a new feature indeed, have been backported to 2.7 and 3.1. The lack of support in ast.literal_eval is arguably a bug. Benjamin, can you make a statement as release manager? Thanks. |
|||
| msg119064 - (view) | Author: Benjamin Peterson (benjamin.peterson) * (Python committer) | Date: 2010年10月18日 18:55 | |
2010年10月18日 Éric Araujo <report@bugs.python.org>: > > Éric Araujo <merwok@netwok.org> added the comment: > > Set literals, a new feature indeed, have been backported to 2.7 and 3.1. The lack of support in ast.literal_eval is arguably a bug. Benjamin, can you make a statement as release manager? Thanks. No change please. |
|||
| msg119071 - (view) | Author: Raymond Hettinger (rhettinger) * (Python committer) | Date: 2010年10月18日 19:33 | |
ast.literal_eval's docs: 'The string or node provided may only consist of the following Python literal structures: strings, numbers, tuples, lists, dicts, booleans, and None.' |
|||
| msg119094 - (view) | Author: nestor (nestor) | Date: 2010年10月18日 23:39 | |
FYI although it breaks symmetry with eval, I am fine with this going in for 3.2. It just surprised me and I wanted to make sure it was documented here for future reference. |
|||
| msg166055 - (view) | Author: Piotr Dobrogost (piotr.dobrogost) | Date: 2012年07月21日 19:52 | |
I totally agree with Eric's statement that "Set literals, a new feature indeed, have been backported to 2.7 and 3.1. The lack of support in ast.literal_eval is arguably a bug." I came here from "set literal syntax support in Python 2.7" question at Stackoverflow (http://stackoverflow.com/q/6078262/95735) |
|||
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2022年04月11日 14:57:07 | admin | set | github: 54300 |
| 2012年07月21日 19:52:38 | piotr.dobrogost | set | nosy:
+ piotr.dobrogost messages: + msg166055 |
| 2011年12月06日 01:47:59 | benjamin.peterson | link | issue13536 superseder |
| 2010年10月18日 23:39:29 | nestor | set | messages: + msg119094 |
| 2010年10月18日 19:33:44 | rhettinger | set | resolution: out of date -> not a bug messages: + msg119071 |
| 2010年10月18日 18:55:46 | benjamin.peterson | set | messages: + msg119064 |
| 2010年10月18日 18:14:42 | eric.araujo | set | nosy:
+ eric.araujo messages: + msg119054 |
| 2010年10月13日 19:58:00 | georg.brandl | set | status: open -> closed resolution: out of date messages: + msg118571 |
| 2010年10月13日 19:39:49 | ezio.melotti | set | nosy:
+ ezio.melotti |
| 2010年10月13日 19:36:40 | nestor | create | |