New submission from Nick Coghlan:

I realised my experiment with supporting implicit calls could potentially be 
used as the basis for a patch that reported more specific error details when 
"print" and "exec" were used as statements, so I went ahead and updated it to 
do so.

The initial patch has a failure in test_source_encoding - this appears to be a 
general issue with moving syntax errors from the parser (which reliably sets 
the "text" attribute on the raised SyntaxError) to the AST compiler (which sets 
that to None when running from a string compiled directly from memory rather 
than from a file on disk).

I've also only flagged this as a patch for 3.5 - I can't think of a way to do 
it without changing the language grammar to allow the error to be generated in 
a later stage of the compilation process, and that's not the kind of thing we 
want to be doing in a maintenance release.

----------
files: custom_builtin_syntax_errors.diff
keywords: patch
messages: 219816
nosy: alex, glyph, gvanrossum, ncoghlan
priority: normal
severity: normal
status: open
title: Custom error messages when print & exec are used as statements
versions: Python 3.5
Added file: http://bugs.python.org/file35491/custom_builtin_syntax_errors.diff

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue21669>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to