[mod_python] pcre.error from python

Graham Swallow gps at trix.dircon.co.uk
Mon Aug 7 22:19:08 EST 2000


It doesnt happen every time but I get faults or trace-backs from pcre.
I think its due to interference between the pcre in python, and the
pcre in php (Perl Compat. Regular Expression). sig-seg or either of:

	pcre.error: ('unmatched parentheses', 40)
	pcre.error: ('\\ at end of pattern', 4425)

(Presumably these are random errors from some other memory corruption,
or incorrect function call, there are no parentheses or \\'s)

I haven't got a clue what to do about it, (would statically linking
pcre into python work? Can separate <Directories> NOT have mod_XYZ
loaded?) but if you see the above symptom, try the attached test script.

	Graham

-------------- next part --------------
#!/usr/bin/env python
# called by httpd or by shell

def handler(req):
	from mod_python import apache
	return handler2( req )
	# forgetting the above return is interesting. Try it!

def handler2( req ):

	req.content_type="text/plain"
	req.send_http_header()
	import re
	instr = "Old and New\n"
	outstr = re.sub( "Old", "New", instr, 0 )
	req.write( outstr )
	try:
		t = apache.OK
	except:
		t = "shell_mode"
	return t

if __name__ == '__main__':
	class REQ_DUMMY:
		def __init__( req, fd ):
			# req has writable (and readable) fields
			# when calling from shell ...
			req.fd = fd
		def send_http_header( req ):
			print "Not apache, so I sont say:", req.content_type
		def write( req, text ):
			req.fd.write( text )

	import sys
	# fd = open( "/dev/null", 'w' )
	# fd = open( "test_out.html", 'w' )
	fd = sys.stderr
	req_dummy = REQ_DUMMY( fd )
	handler2( req_dummy )



More information about the Mod_python mailing list