Title: AST literal_eval exceptions provide no information about line number
Type: enhancement Stage: patch review
Components: Library (Lib) Versions: Python 3.7
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: berker.peksag, louielu, mbdevpl, serhiy.storchaka, stevemerritt
Priority: normal Keywords: patch

Created on 2016-12-13 21:47 by stevemerritt, last changed 2017-04-26 17:59 by stevemerritt.

File name Uploaded Description Edit
mywork.patch stevemerritt, 2016-12-13 21:47 review
Messages (6)
msg283142 - (view) Author: Steve Merritt (stevemerritt) * Date: 2016-12-13 21:47
Without line numbers, debugging syntax errors in large documents is a tedious and painful process.
msg284419 - (view) Author: Berker Peksag (berker.peksag) * (Python committer) Date: 2017-01-01 03:28
Thanks for the patch, Steve!.

This looks like a reasonable request to me, but 1) we can only make this change in 3.7 2) we need a test case for the new message 3) you can use f-strings instead of str.format()
msg284422 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2017-01-01 07:41
Usually literal_eval() is used with short one-line input. For what large documents do you use it?
msg284430 - (view) Author: Steve Merritt (stevemerritt) * Date: 2017-01-01 22:11
We're using Python dictionaries to express sizeable (read: 100-600 lines)
chunks of configuration data. We previously used JSON, but we now use
Jinja2 to template chunks of this configuration data, and JSON's inability
to handle trailing commas creates a problem here. So we've been using
ast.literal_eval, but the lack of line numbers makes debugging problems
with the configurations a painful process.

On Sun, Jan 1, 2017 at 2:41 AM Serhiy Storchaka <>

> Serhiy Storchaka added the comment:
> Usually literal_eval() is used with short one-line input. For what large
> documents do you use it?
> ----------
> nosy: +serhiy.storchaka
> _______________________________________
> Python tracker <>
> <>
> _______________________________________
msg292330 - (view) Author: Louie Lu (louielu) * Date: 2017-04-26 10:13
Steve, will you work on this patch to GitHub?
msg292381 - (view) Author: Steve Merritt (stevemerritt) * Date: 2017-04-26 17:59
I'll try to get to it this weekend. A bit swamped on another project right now. Thanks for the interest and the reminder!
Date User Action Args
2017-04-26 17:59:06stevemerrittsetmessages: + msg292381
2017-04-26 10:13:59louielusetnosy: + louielu
messages: + msg292330
2017-03-15 06:46:47mbdevplsetnosy: + mbdevpl
2017-01-01 22:11:46stevemerrittsetmessages: + msg284430
2017-01-01 07:41:51serhiy.storchakasetnosy: + serhiy.storchaka
messages: + msg284422
2017-01-01 03:28:55berker.peksagsetversions: + Python 3.7, - Python 2.7
nosy: + berker.peksag

messages: + msg284419

type: behavior -> enhancement
stage: patch review
2016-12-13 21:47:44stevemerrittcreate