Issue 992207: exec statement balks at CR/LF (original) (raw)
Under Linux and MacOS (no others tested), if "foo.py" is a DOS/ Windows style Python file (CR/LF line endings), then
python foo.py
will work, as will
execfile("foo.py")
and
exec file("foo.py")
from inside Python. However,
exec file("foo.py").read()
will report a syntax error. In other words, the parser seems to accept CR/LF only if the source of the data is a file, not a string.
When running under Linux and MacOS (no others tested), the exec statement reports a syntax error. I didn't find anything about this in the documentation, so I don't know if it's a bug or a feature. If it's a feature, it is not a useful one!