python - Apache2 "Response header name '<!--' contains invalid characters, aborting request" -


i have inherited website based on apache2/python/cgi scripts i'm trying maintain, i'm struggling unhelpful errors. in case, the server encountered internal error or misconfiguration , unable complete request. when clicking on element on page. error log gives me following information:
[fri jul 28 14:11:15.150877 2017] [http:error] [pid 1727] [client 193.174.111.250:53426] ah02429: response header name '<!--' contains invalid characters, aborting request

based on similar question, i'm assuming error quite new, can't find problem. since link / script name stays same. works when first opening site, stops working when click not refer me different site/script. how can header's fault?

just in case, here code generates beginning of web page:

code = "content-type: text/html\n\n" code += "<!doctype html public '-//w3c//dtd html 4.0 transitional//en'>\n<html>\n"     code += "<head>\n  <title>bactome: relative expressions</title>\n" ... 

as far understand now, first line constitutes http header have. there no '<!--' stated in error log. header need else functional?

ps: alternatively, if there's easy way turn these generic errors more verbose ones, i'd interested in that.

in case problem way aligment of output print statement

before:

try:     if <some-condition>         message = "%s" % filename     else:         message = "file not found"     print """\n         content-type: text/html\n         <html><body>         <p>%s</p>         </body></html>         """ % (message,) except exception e:     print e 

after:

try:     if <some-condition>:         message = "%s" % filename     else:         message = "file not found"     print """\ content-type: text/html\n <html><body> <p>%s</p> </body></html>    """ % (message,) except exception e:     print e 

Comments