Re: Usage of ast.

2017-02-28 Thread Jon Ribbens
On 2017-02-28, Chris Angelico wrote: > On Tue, Feb 28, 2017 at 11:35 AM, Jon Ribbens > wrote: >> Sorry, I must have missed something here. What are you talking about? >> "lambda: [1,2,3]" is not acceptable input to ast.literal_eval(), it >> will

Re: Usage of ast.

2017-02-27 Thread Chris Angelico
On Tue, Feb 28, 2017 at 11:35 AM, Jon Ribbens wrote: > Sorry, I must have missed something here. What are you talking about? > "lambda: [1,2,3]" is not acceptable input to ast.literal_eval(), it > will throw an exception. [1,2,3] is, though. Go read my previous posts.

Re: Usage of ast.

2017-02-27 Thread Jon Ribbens
On 2017-02-27, Chris Angelico wrote: > On Tue, Feb 28, 2017 at 3:58 AM, Jon Ribbens > wrote: >> Seeing as most of it is code along the lines of "is this an integer >> constant? if so the value is that constant": no, I think "execution" >> is a

Re: Usage of ast.

2017-02-27 Thread Chris Angelico
On Tue, Feb 28, 2017 at 3:58 AM, Jon Ribbens wrote: > On 2017-02-27, Chris Angelico wrote: >> On Tue, Feb 28, 2017 at 3:17 AM, Jon Ribbens >> wrote: >>> On 2017-02-27, Chris Angelico wrote: Actually

Re: Usage of ast.

2017-02-27 Thread Jon Ribbens
On 2017-02-27, Chris Angelico wrote: > On Tue, Feb 28, 2017 at 3:17 AM, Jon Ribbens > wrote: >> On 2017-02-27, Chris Angelico wrote: >>> Actually it does execute, as you can see from the source code. >> >> I'm not sure what you

Re: Usage of ast.

2017-02-27 Thread Chris Angelico
On Tue, Feb 28, 2017 at 3:17 AM, Jon Ribbens wrote: > On 2017-02-27, Chris Angelico wrote: >> Actually it does execute, as you can see from the source code. > > I'm not sure what you mean by that. I was looking at the source code > (and its history)

Re: Usage of ast.

2017-02-27 Thread Jon Ribbens
On 2017-02-27, Chris Angelico wrote: > On Tue, Feb 28, 2017 at 1:18 AM, Jon Ribbens > wrote: >> "execution" isn't really the right way to describe literal_eval(). >> It isn't an code executor or even an expression evaluator, all it >> does is turns a

Re: Usage of ast.

2017-02-27 Thread Chris Angelico
On Tue, Feb 28, 2017 at 1:18 AM, Jon Ribbens wrote: > On 2017-02-27, Vincent Vande Vyvre wrote: >> Le 27/02/17 à 14:09, Chris Angelico a écrit : >>> The message is a little confusing, but the error comes from the fact >>> that

Re: Usage of ast.

2017-02-27 Thread Jon Ribbens
On 2017-02-27, Vincent Vande Vyvre wrote: > Le 27/02/17 à 14:09, Chris Angelico a écrit : >> The message is a little confusing, but the error comes from the fact >> that literal_eval permits a very few legal operations, and calling a >> function isn't one of them.

Re: Usage of ast.

2017-02-27 Thread Chris Angelico
On Tue, Feb 28, 2017 at 12:44 AM, Vincent Vande Vyvre wrote: > OK, it's coherent with the secure execution. > Yep. Here's a PR to make the message a bit clearer, though: https://github.com/python/cpython/pull/340 >>> ast.literal_eval("print('hello world')")

Re: Usage of ast.

2017-02-27 Thread Vincent Vande Vyvre
Le 27/02/17 à 14:09, Chris Angelico a écrit : On Mon, Feb 27, 2017 at 11:57 PM, Vincent Vande Vyvre wrote: I've this strange error: Python 3.4.3 (default, Nov 17 2016, 01:08:31) [GCC 4.8.4] on linux Type "help", "copyright", "credits" or "license" for more

Re: Usage of ast.

2017-02-27 Thread Jussi Piitulainen
Vincent Vande Vyvre writes: > I've this strange error: > > Python 3.4.3 (default, Nov 17 2016, 01:08:31) > [GCC 4.8.4] on linux > Type "help", "copyright", "credits" or "license" for more information. import ast l = "print('hello world')" ast.literal_eval(l) > Traceback (most

Re: Usage of ast.

2017-02-27 Thread Chris Angelico
On Mon, Feb 27, 2017 at 11:57 PM, Vincent Vande Vyvre wrote: > I've this strange error: > > Python 3.4.3 (default, Nov 17 2016, 01:08:31) > [GCC 4.8.4] on linux > Type "help", "copyright", "credits" or "license" for more information. import ast l =

Usage of ast.

2017-02-27 Thread Vincent Vande Vyvre
I've this strange error: Python 3.4.3 (default, Nov 17 2016, 01:08:31) [GCC 4.8.4] on linux Type "help", "copyright", "credits" or "license" for more information. >>> import ast >>> l = "print('hello world')" >>> ast.literal_eval(l) Traceback (most recent call last): File "", line 1, in