Very useful message -- Hah!

dgrassi dan at grassi.org
Sun Dec 5 17:02:56 EST 1999


On 12/5/99 4:02 PM Fredrik Lundh wrote:

>in your sample script, change:
>
>    #!/usr/bin/python
>
>to:
>
>    #!/usr/bin/python -u
>
>> >    - or call sys.stdout.flush() at the appropriate
>> >      places (you have to import the sys module
>> >      first).
>> 
>> But that won't work for syntax error -- right?
>
>it will work, if you've redirected sys.stderr to
>sys.stdout (as you did in your sample).

Not for me:

#!/usr/bin/python -u

import sys
import traceback
print "Content-type: text/html"
print
sys.stderr = sys.stdout
try:
  print "as"
 print "ax"
except:
 print "\n\n<PRE>"
 traceback.print_exc()


produces the Apache "Internal Server Error".

Dan




More information about the Python-list mailing list