June 17, 2013
5:22 p.m.
On Mon, Jun 17, 2013 at 10:04 AM, Walter Dörwald <walter@livinglogic.de> wrote:
I expected that eval()ing a string that contains the characters
U+0027: APOSTROPHE U+0027: APOSTROPHE U+0027: APOSTROPHE U+000D: CR U+000A: LR U+0027: APOSTROPHE U+0027: APOSTROPHE U+0027: APOSTROPHE
to return a string containing the characters:
U+000D: CR U+000A: LR
No. Executing a file containing those exact characters produces a string containing only '\n' and exec/eval is meant to behave the same way. The string may not have originated from a file, so the universal newlines behavior of the io module is irrelevant here -- the parser must implement its own equivalent processing, and it does. -- --Guido van Rossum (python.org/~guido)