[issue24663] ast.literal_eval does not handle empty set literals

2016-02-27 Thread yota moteuchi

yota moteuchi added the comment:

Well, I would disagree with R. David Murray on this.

literal_eval() is meant to safely parse literal pythons "containers" structures.

{1, 2, 3} is a valid literal set(), why would an empty one not be parse-able as 
well. I can not predict, when I dump the structure with repr(), if the set() 
will be empty or not.

--
nosy: +yota moteuchi

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue24663] ast.literal_eval does not handle empty set literals

2015-11-03 Thread R. David Murray

R. David Murray added the comment:

Like I said, you should take your use case to python-ideas, for a safe_eval 
that would handle it.  literal_eval is not the place for handing 'set()', in my 
opinion.  (There is always a chance other other devs will disagree, but none 
have so far :).

FYI, reprs are often evalable to get back the original value, but the key word 
there is 'eval', not 'literal_eval'.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue24663] ast.literal_eval does not handle empty set literals

2015-11-03 Thread Hrvoje Abraham

Hrvoje Abraham added the comment:

For now I'll implement my_literal_eval via AST filtering, reproducing 
ast.literal_eval + 'set()' functionality.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue24663] ast.literal_eval does not handle empty set literals

2015-11-03 Thread Hrvoje Abraham

Hrvoje Abraham added the comment:

I use communication protocol based on Python literals and ast.literal_eval for 
deserialization. I'm avoiding sets because empty set value is not supported in 
a clean consistent manner on language level.

If I write repr(set()) i get 'set()', this should matter, maybe.

I know I can handle it as a special case, None for empty set, and close my eyes 
on fact that I lose None value reserved for some other cases. But this really 
is not a nice thing to do. Please reconsider...

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue24663] ast.literal_eval does not handle empty set literals

2015-11-03 Thread Hrvoje Abraham

Hrvoje Abraham added the comment:

I believe this is the issue. ast.literal_eval sets support can not be 
considered complete until it also handles empty sets. I do not consider it 
valid for me to explicitly handle this case in my projects using some weird 
hacks.

Python community settled on not introducing empty set literal because one can 
simply use set(), as discussed a few times before. But no corresponding 
alternative was defined for ast.literal_eval, maybe it should handle 'set()' as 
such.

I strongly advise reopening this issue and finding functional solution for 
empty set case. I need it!

--
nosy: +ahrvoje
type:  -> enhancement
versions: +Python 3.5 -Python 3.4

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue24663] ast.literal_eval does not handle empty set literals

2015-11-03 Thread R. David Murray

R. David Murray added the comment:

You haven't presented an actual use case, it would be interesting to see one.

Regardless of that, however, ast.literal_eval is an exposure of the literal 
value parsing part of the AST.  set() is not part of that, because it is not a 
literal, it is a function call.

There has been some discussion of adding a "safe_eval" function to the stdlib 
(see issue 22525), and that would be the appropriate place to introduce 
evaluation of set().

python-ideas would be the appropriate place to discuss safe_eval.

--
nosy: +r.david.murray

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue24663] ast.literal_eval does not handle empty set literals

2015-07-18 Thread Ezio Melotti

Ezio Melotti added the comment:

I believe this is by design, since set() -- like str(), list(), dict(), etc -- 
is not a literal.
I don't think set() should be special-cased either.
Perhaps you could tell us more about your use case?

--
nosy: +ezio.melotti
resolution:  - not a bug
status: open - pending

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue24663
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue24663] ast.literal_eval does not handle empty set literals

2015-07-18 Thread Ezio Melotti

Changes by Ezio Melotti ezio.melo...@gmail.com:


--
stage:  - resolved

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue24663
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue24663] ast.literal_eval does not handle empty set literals

2015-07-18 Thread Filip Haglund

Filip Haglund added the comment:

Okey, then this is not a bug. I can just handle this special case myself. 
Thanks!

--
status: pending - closed

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue24663
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com