[issue41887] ast.literal_eval does not accept strings with leading whitespaces

2020-10-03 Thread Guido van Rossum
Guido van Rossum added the comment: Closing. Let’s not backport. -- resolution: -> fixed stage: patch review -> resolved status: open -> closed ___ Python tracker ___

[issue41887] ast.literal_eval does not accept strings with leading whitespaces

2020-10-03 Thread miss-islington
Change by miss-islington : -- nosy: +miss-islington nosy_count: 5.0 -> 6.0 pull_requests: +21536 pull_request: https://github.com/python/cpython/pull/22533 ___ Python tracker _

[issue41887] ast.literal_eval does not accept strings with leading whitespaces

2020-10-03 Thread Guido van Rossum
Guido van Rossum added the comment: New changeset e799aa8b92c195735f379940acd9925961ad04ec by Batuhan Taskaya in branch 'master': bpo-41887: omit leading spaces/tabs on ast.literal_eval (#22469) https://github.com/python/cpython/commit/e799aa8b92c195735f379940acd9925961ad04ec -- __

[issue41887] ast.literal_eval does not accept strings with leading whitespaces

2020-10-03 Thread Pablo Galindo Salgado
Pablo Galindo Salgado added the comment: > I dunno, but it's been doing this since 1992, so I think it would be fragile > to change. The best thing therefore is to make ast.literal_eval() match it > exactly. +1 We had considerable finicky behaviour in the parser related to new lines and whi

[issue41887] ast.literal_eval does not accept strings with leading whitespaces

2020-10-02 Thread Guido van Rossum
Guido van Rossum added the comment: [Terry] > But why should not parsing remove indents for 'eval' mode? I dunno, but it's been doing this since 1992, so I think it would be fragile to change. The best thing therefore is to make ast.literal_eval() match it exactly. -- __

[issue41887] ast.literal_eval does not accept strings with leading whitespaces

2020-10-02 Thread Terry J. Reedy
Terry J. Reedy added the comment: The doc for literal_eval says "evaluate ... a string containing a Python literal or container display." To me, ' 1' qualifies, just as it does as an expression for eval(). The exception comes from parsing raising IndentationError with leading whitespace ev

[issue41887] ast.literal_eval does not accept strings with leading whitespaces

2020-09-30 Thread Batuhan Taskaya
Change by Batuhan Taskaya : -- keywords: +patch pull_requests: +21492 stage: -> patch review pull_request: https://github.com/python/cpython/pull/22469 ___ Python tracker ___

[issue41887] ast.literal_eval does not accept strings with leading whitespaces

2020-09-30 Thread Guido van Rossum
Guido van Rossum added the comment: Hm, I'm not sure. ast.literal_eval() does accept trailing whitespace, and embedded whitespace. ``` >>> ast.literal_eval("- ( 1\n)\n") -1 >>> ``` So I think it should start accepting leading whitespace too (but only in a feature release, so 3.10). --

[issue41887] ast.literal_eval does not accept strings with leading whitespaces

2020-09-30 Thread Raymond Hettinger
Change by Raymond Hettinger : -- nosy: +gvanrossum ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe: https://ma

[issue41887] ast.literal_eval does not accept strings with leading whitespaces

2020-09-30 Thread Batuhan Taskaya
Batuhan Taskaya added the comment: Looks like skipping the leading whitespace is an undocumented behavior for eval() introduced back in 1992 (f08ab0ad158f88f05dd923b129d2397e1882be14). I don't think that bringing it to the literal_eval is a good idea, at least after this much of a time. If s

[issue41887] ast.literal_eval does not accept strings with leading whitespaces

2020-09-30 Thread Batuhan Taskaya
Change by Batuhan Taskaya : -- nosy: +BTaskaya ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.p

[issue41887] ast.literal_eval does not accept strings with leading whitespaces

2020-09-29 Thread Saiyang Gou
New submission from Saiyang Gou : `ast.literal_eval` does not accept code with leading whitespaces, while `eval` accepts them, which is an inconsistency. ``` >>> import ast >>> eval(' 1') 1 >>> ast.literal_eval(' 1') Traceback (most recent call last): File "", line 1, in File "/usr/local/