Exec across multiple platforms.

Joal Heagney s713221 at student.gu.edu.au
Wed Nov 28 04:26:26 EST 2001


I noticed a bug in a python package involving exec and dos-created
files. Basically, if a file was created in the dos-world then shipped
over to the linux world a-la tar.gz archive, the resulting /r/n endlines
caused problems in the program. Now I managed to get around this by
adding the following error-checking in the code.

file = open("a_file", "r")

a_value = file.readline()
if a_value[-2:] == "/r/n":
	a_value == a_value[:-2]
exec "doing something nasty to %s" % a_value

Now I'd like to contact the author of the program with a fix, but I'm
uncertain as how to ensure this solution is cross-platform. I.e. will
cutting the /r/n off the end of a string in the dos world render a
string un-exec-able, the same way not cutting the /r/n off does in the
unix world? If it doesn't matter, I'll submit as is. Otherwise, is there
a cross-platform solution?

P.S. Pick the person so linuxified that he can't remember how the
dosworld works. :).
-- 
      Joal Heagney is: _____           _____
   /\ _     __   __ _    |     | _  ___  |
  /__\|\  ||   ||__ |\  || |___|/_\|___] |
 /    \ \_||__ ||___| \_|! |   |   \   \ !



More information about the Python-list mailing list