[mod_python] zero terminated strings and req.write

Frederick Grim fred at forsalebyowner.com
Mon Mar 8 14:32:59 EST 2004


Howdy all,
	so I have a little problem that is making me crazy. I have a python script
	like
	
def gen_xml():
	return """<?xml ... Tons of xhtml stuff here
	
</html>"""
	
def main(req, ERR='0'):
	re.content_type = 'text/xml'
	req.write(gen_xml())
	return apache.OK

The problem here is that python puts null bytes at the end of a string and
req.write fails with the error that there is a 0 after </html>.  How do I get this
failure to not happen.  Even if i set content_type to 'text/html' there appears a
little zero at the end of my script. It seems like a bug? maybe.  I am using mod_python 3.1.3
apache 2.0.47, and python 2.3

	Fred

-- 
"Windows Longhorn will be like having a little cop right inside your computer"
	-- Jorge Lopez, MCSE


More information about the Mod_python mailing list