Last active
October 28, 2021 16:42
-
-
Save kierdavis/87f06292051ebf670acc84cb567b9570 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import cgitb | |
import os | |
format = os.environ.get("CGITB_FORMAT", "text") | |
cgitb.enable(format=format, display=0) | |
raise Exception("oh no") | |
# [user@host:~]$ python --version | |
# Python 3.11.0a1 | |
# | |
# A CGI header block is correctly emitted here (separated from the body by a blank line): | |
# [user@host:~]$ CGITB_FORMAT=html python repro_cgitb_not_emitting_headers_in_text_mode.py | |
# <!--: spam | |
# Content-Type: text/html | |
# | |
# <body bgcolor="#f0f0f8"><font color="#f0f0f8" size="-5"> --> | |
# <body bgcolor="#f0f0f8"><font color="#f0f0f8" size="-5"> --> --> | |
# </font> </font> </font> </script> </object> </blockquote> </pre> | |
# </table> </table> </table> </table> </table> </font> </font> </font><p>A problem occurred in a Python script. | |
# | |
# No CGI header block is emitted here: | |
# [user@host:~]$ CGITB_FORMAT=text python repro_cgitb_not_emitting_headers_in_text_mode.py | |
# <p>A problem occurred in a Python script. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment