A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2019-May/157504.html below:

[Python-Dev] bpo-36919: Exception from 'compile' reports a newline char not present in input

[Python-Dev] bpo-36919: Exception from 'compile' reports a newline char not present in inputPavel Koneski pavel.koneski at gmail.com
Mon May 20 15:26:31 EDT 2019
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', '<string>', 'exec')
... except SyntaxError as ex: print(repr(ex))
...
SyntaxError('invalid syntax', ('<string>', 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

More information about the Python-Dev mailing list

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4