This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: exec statement balks at CR/LF
Type: enhancement Stage: test needed
Components: Documentation, Interpreter Core Versions: Python 2.7
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: georg.brandl Nosy List: ajaksu2, georg.brandl, georg.brandl, hinsen
Priority: normal Keywords: easy

Created on 2004-07-16 09:21 by hinsen, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Messages (4)
msg60529 - (view) Author: Konrad Hinsen (hinsen) Date: 2004-07-16 09:21
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!

msg60530 - (view) Author: Georg Brandl (georg.brandl) * (Python committer) Date: 2006-01-10 22:57
Logged In: YES 
user_id=1188172

I'm not sure this is a bug.

Is exec supposed to accept code in crlf-terminated strings?
msg82036 - (view) Author: Daniel Diniz (ajaksu2) * (Python triager) Date: 2009-02-14 12:42
The behavior is still present, but I'm not sure it's a bug either. The
documentation could mention this:
http://docs.python.org/dev/reference/simple_stmts.html#exec
msg84837 - (view) Author: Georg Brandl (georg.brandl) * (Python committer) Date: 2009-03-31 16:57
Documented in r70838, r70840.
History
Date User Action Args
2022-04-11 14:56:05adminsetgithub: 40583
2009-03-31 16:57:30georg.brandlsetstatus: open -> closed
resolution: fixed
messages: + msg84837
2009-02-14 12:42:51ajaksu2setassignee: georg.brandl
type: enhancement
components: + Documentation
versions: + Python 2.7, - Python 2.3
keywords: + easy
nosy: + georg.brandl, ajaksu2
messages: + msg82036
stage: test needed
2004-07-16 09:21:42hinsencreate