[Python-Dev] bpo-36919: Exception from 'compile' reports a newline char not present in input (original) (raw)
Guido van Rossum guido at python.org
Mon May 20 15:46:12 EDT 2019
- Previous message (by thread): [Python-Dev] bpo-36919: Exception from 'compile' reports a newline char not present in input
- Next message (by thread): [Python-Dev] PEP 594: Removing dead batteries from the standard library
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
I answered (B) in the tracker.
On Mon, May 20, 2019 at 12:32 PM Pavel Koneski <pavel.koneski at gmail.com> wrote:
Hi,
The following issue arose when implementing IronPython 3. Normally the behavior of CPython is authoritative, but in this case I started having doubts. Since Python 3.2, input in 'exec' mode of 'compile' does not have to end in a newline anymore. However, it creates a surprising behavior when a 'SyntaxError' is reported: >>> try: compile('try', '', 'exec') ... except SyntaxError as ex: print(repr(ex)) ... SyntaxError('invalid syntax', ('', 1, 4, 'try\n')) The 'text' field of the exception thrown contains an additional newline character that was not present in the input. Is it: a. Proper Python language behavior? b. CPython implementation artifact? c. A bug? The comments on bpo (https://bugs.python.org/issue36919) suggest Case B, but inconclusive. If case B it is, since IronPython does not exhibit this behavior, I will submit a patch to StdLib test(s) to make them implementation independent. Thanks for comments, Pavel
Python-Dev mailing list Python-Dev at python.org https://mail.python.org/mailman/listinfo/python-dev Unsubscribe: https://mail.python.org/mailman/options/python-dev/guido%40python.org
-- --Guido van Rossum (python.org/~guido) *Pronouns: he/him/his **(why is my pronoun here?)* <http://feministing.com/2015/02/03/how-using-they-as-a-singular-pronoun-can-change-the-world/> -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://mail.python.org/pipermail/python-dev/attachments/20190520/686a3e8c/attachment-0001.html>
- Previous message (by thread): [Python-Dev] bpo-36919: Exception from 'compile' reports a newline char not present in input
- Next message (by thread): [Python-Dev] PEP 594: Removing dead batteries from the standard library
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]