[issue15245] ast.literal_eval fails on some literals

2018-11-20 Thread Serhiy Storchaka


Change by Serhiy Storchaka :


--
resolution:  -> out of date
stage: patch review -> resolved
status: open -> closed

___
Python tracker 

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



[issue15245] ast.literal_eval fails on some literals

2018-11-18 Thread Mark Dickinson


Mark Dickinson  added the comment:

> The question is should we make it working in older versions? 

That seems like an easy question: it would be a new feature in a bugfix branch, 
so no, we shouldn't make it work in older versions.

Looks to me as though this issue can be closed.

--

___
Python tracker 

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



[issue15245] ast.literal_eval fails on some literals

2018-11-04 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:

ast.literal_eval('...') works in 3.8.

The question is should we make it working in older versions?

--
nosy: +serhiy.storchaka

___
Python tracker 

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



[issue15245] ast.literal_eval fails on some literals

2012-07-06 Thread Ezio Melotti

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


--
nosy: +ezio.melotti

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



[issue15245] ast.literal_eval fails on some literals

2012-07-05 Thread Mark Dickinson

Mark Dickinson dicki...@gmail.com added the comment:

 I don't think literal_eval should handle anything which is not syntax.
+1

-1 on supporting 'inf' and 'nan'
-0 on supporting 'Ellipsis' or '...';  seems harmless, but I don't really see 
the point.

--

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



[issue15245] ast.literal_eval fails on some literals

2012-07-05 Thread João Bernardo

João Bernardo jbv...@gmail.com added the comment:

Of course `nan` and `inf` are part of the syntax! The `ast.parse` function 
recognize them as `Name`. 

So that works:

 ast.dump(ast.parse('True'))
Module(body=[Expr(value=Name(id='True', ctx=Load()))])

 ast.dump(ast.parse('inf'))
Module(body=[Expr(value=Name(id='inf', ctx=Load()))])

 inf = float('inf')
 eval('inf')
inf

I've run into some literals with `Ellipsis` and `inf` and couldn't load them 
with literal_eval. That's why I'm proposing that.

The thing about `nan` and `inf` is because they are the *only* representations 
of float numbers produced by the interpreter that cannot be loaded.

Something like that could solve the problem keeping `literal_eval` safe and 
allowing other names:

ast.literal_eval('[1.0, 2.0, inf]', {'inf': float('inf')})

--

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



[issue15245] ast.literal_eval fails on some literals

2012-07-05 Thread Éric Araujo

Changes by Éric Araujo mer...@netwok.org:


--
nosy: +eric.araujo, georg.brandl

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



[issue15245] ast.literal_eval fails on some literals

2012-07-05 Thread João Bernardo

Changes by João Bernardo jbv...@gmail.com:


--
keywords: +patch
Added file: http://bugs.python.org/file26262/ast.py.diff

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



[issue15245] ast.literal_eval fails on some literals

2012-07-05 Thread Éric Araujo

Changes by Éric Araujo mer...@netwok.org:


--
keywords: +needs review
stage:  - test needed

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



[issue15245] ast.literal_eval fails on some literals

2012-07-05 Thread Amaury Forgeot d'Arc

Amaury Forgeot d'Arc amaur...@gmail.com added the comment:

I like the 'safe_names' idea, but is this patch supposed to work?

 isinstance(None, Ellipsis)
TypeError: isinstance() arg 2 must be a type or tuple of types

--
nosy: +amaury.forgeotdarc

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



[issue15245] ast.literal_eval fails on some literals

2012-07-05 Thread João Bernardo

João Bernardo jbv...@gmail.com added the comment:

Ellipsis in this context is `_ast.Ellipsis`, not the original one...

There's no TypeError there as `_ast.Ellipsis` is a class.

--

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



[issue15245] ast.literal_eval fails on some literals

2012-07-05 Thread Amaury Forgeot d'Arc

Amaury Forgeot d'Arc amaur...@gmail.com added the comment:

Ah right, that's confusing indeed...

Unit tests and doc updates are needed though.

--

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



[issue15245] ast.literal_eval fails on some literals

2012-07-05 Thread João Bernardo

Changes by João Bernardo jbv...@gmail.com:


Added file: http://bugs.python.org/file26264/ast.py_with_tests.diff

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



[issue15245] ast.literal_eval fails on some literals

2012-07-05 Thread Éric Araujo

Éric Araujo mer...@netwok.org added the comment:

Thanks for the patch.  It looks good to me, but I think that adding support for 
Ellipsis and adding a new parameter to allow extra names are two different 
requests, but someone more knowledgeable than me about AST may judge 
differently.  My rationale is that supporting Ellipsis literals is a no-brainer 
addition, whereas adding an argument to support things that are not actual 
Python literals may be rejected.  You don’t have to split your patch in two 
anyway, it’s easy to do if the dev who will commit wants to.

Each change would also need a doc update.

--
stage: test needed - patch review

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



[issue15245] ast.literal_eval fails on some literals

2012-07-05 Thread João Bernardo

João Bernardo jbv...@gmail.com added the comment:

Just to be sure: What's a doc update? The `.rst` files are updated 
automatically with the doc strings?

The adding another argument should require a:
Changed in version 3.x: Accepts a second argument ... ?

--

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



[issue15245] ast.literal_eval fails on some literals

2012-07-05 Thread Éric Araujo

Éric Araujo mer...@netwok.org added the comment:

No, the rst documentation is maintained manually.

Look for versionchanged in the doc source files or the documentation about 
writing documentation to see how to document the new argument (and new 
supported Ellipsis literal).

--

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



[issue15245] ast.literal_eval fails on some literals

2012-07-05 Thread João Bernardo

Changes by João Bernardo jbv...@gmail.com:


Added file: http://bugs.python.org/file26266/ast.py_tests_doc.diff

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



[issue15245] ast.literal_eval fails on some literals

2012-07-04 Thread Mark Dickinson

Changes by Mark Dickinson dicki...@gmail.com:


--
nosy: +mark.dickinson

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



[issue15245] ast.literal_eval fails on some literals

2012-07-04 Thread Daniel Urban

Daniel Urban urban.dani...@gmail.com added the comment:

eval(repr(float('nan'))) doesn't work either, so I'm not sure ast.literal_eval 
should. The same with float('inf').

--
nosy: +daniel.urban

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



[issue15245] ast.literal_eval fails on some literals

2012-07-04 Thread João Bernardo

João Bernardo jbv...@gmail.com added the comment:

That's what I said by `nan` and `inf` are not literals, but their 
representations look like they should be.

One solution could be to add another argument to allow some extra names. Maybe 
a mapping, as `eval`.

--

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



[issue15245] ast.literal_eval fails on some literals

2012-07-04 Thread Benjamin Peterson

Benjamin Peterson benja...@python.org added the comment:

I don't think literal_eval should handle anything which is not syntax.

--

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



[issue15245] ast.literal_eval fails on some literals

2012-07-03 Thread Antoine Pitrou

Changes by Antoine Pitrou pit...@free.fr:


--
nosy: +benjamin.peterson
title: ast.literal_eval on some literals - ast.literal_eval fails on some 
literals
versions: +Python 3.4 -Python 3.3

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