exec(formula) does not like embedded "\r" in linux?

E

Ernie

Hi,

I spent more than an hour wondering why the following works in my
Python 2.3.4 Linux box:

formula = """
def dummy():
print "This is Ok!"
"""

exec(formula)
dummy()

but if I receive a formula string from a textarea in an HTML form page
using the cgi library, the exec(formula) raises an error. Inspecting
the formula string, the line terminators used were "\r\n"s.
Translating these line terinators back to "\n" fixed the problem.

Should not exec() be happy to process these "\r\n" as easily as "\r"
without errors in linux? Is this a bug?

Regards,

Ernie
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,432
Messages
2,571,681
Members
48,796
Latest member
Greg L.

Latest Threads

Top