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

Discussion in 'Python' started by Ernie, Jul 25, 2004.

  1. Ernie

    Ernie Guest

    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
     
    Ernie, Jul 25, 2004
    #1
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Hal Vaughan
    Replies:
    11
    Views:
    1,198
    Gordon Beaton
    May 22, 2006
  2. tedsuzman
    Replies:
    2
    Views:
    7,166
    Michel Claveau, résurectionné d'outre-bombe inform
    Jul 21, 2004
  3. Ted
    Replies:
    1
    Views:
    497
    Duncan Booth
    Jul 22, 2004
  4. Guillermo Riojas
    Replies:
    0
    Views:
    200
    Guillermo Riojas
    Nov 26, 2010
  5. News123
    Replies:
    3
    Views:
    377
    News123
    Jun 6, 2012
Loading...

Share This Page