[mod_python] problem using regular expressions in CGI scripts

Ralf Canis ralf at silicon.org
Thu May 18 13:32:38 EST 2000


Hello,

I've just installed mod_python and have a problem with CGI scripts
using regular expressions.

apache 1.3.6
python 1.52
mod_python 1.9a

httpd.conf contains:
AddHandler python-program .py
PythonHandler cgihandler

--- snip ---
import re, sys, traceback

print 'Content-type: text/plain'
print

sys.stderr = sys.stdout

try:
  re.compile( r'foo(\(.+\))bar' )
  print 'ok'
except:
  print '\n\n'
  traceback.print_exc()
  print '\n'
--- snip ---

Opening this page in a browser and pressing refresh several times
results in the following error, one at a time. Sometimes it works :)
I've already reinstalled python and mod_python. BTW, same problem
when using PyApache!

BUT: Loading the Python interpreter as a standard CGI program always works.

Traceback (innermost last):
  File "/home/httpd/sites/ralf/test/re_err.py", line 9, in ?
    re.compile( r'foo(\(.+\))bar' )
  File "/var/tmp/python/python-root/usr/lib/python1.5/re.py", line 79, in compile
    code=pcre_compile(pattern, flags, groupindex)
pcre.error: ('back reference to non-existent subpattern', 4149)

or

Traceback (innermost last):
  File "/home/httpd/sites/ralf/test/re_err.py", line 9, in ?
    re.compile( r'foo(\(.+\))bar' )
  File "/var/tmp/python/python-root/usr/lib/python1.5/re.py", line 79, in compile
    code=pcre_compile(pattern, flags, groupindex)
pcre.error: ('\\ at end of pattern', 1886)

or

Traceback (innermost last):
  File "/home/httpd/sites/ralf/test/re_err.py", line 9, in ?
    re.compile( r'foo(\(.+\))bar' )                     
  File "/var/tmp/python/python-root/usr/lib/python1.5/re.py", line 79, in compile
    code=pcre_compile(pattern, flags, groupindex)
pcre.error: ('unmatched parentheses', 10)

or

Traceback (innermost last):
  File "/home/httpd/sites/ralf/test/re_err.py", line 9, in ?
    re.compile( r'foo(\(.+\))bar' )                     
  File "/var/tmp/python/python-root/usr/lib/python1.5/re.py", line 79, in compile
    code=pcre_compile(pattern, flags, groupindex)
pcre.error: ('regular expression too large', 0)

or

Traceback (innermost last):
  File "/home/httpd/sites/ralf/test/re_err.py", line 9, in ?
    re.compile( r'foo(\(.+\))bar' )
  File "/var/tmp/python/python-root/usr/lib/python1.5/re.py", line 79, in compile
    code=pcre_compile(pattern, flags, groupindex)
pcre.error: ('missing )', 113)


Did I miss something or is this a nasty bug? It's ugly, because MySQLdb
doesn't work because of it.

Sincerely
  Ralf

-- 
Ralf Canis            ralf at silicon.org
Germany               canis at bigfoot.com



More information about the Mod_python mailing list