Python 2.3.3 (#2, Feb 17 2004, 11:45:40) [GCC 3.3.2 (Mandrake Linux 10.0 3.3.2-6mdk)] on linux2 I think this affects 2.4 as well. If you invoke re.sub(), and the replacement contains a two-digit group-reference, it hangs. E.g. try print re.sub( r'(.)(.)(.)(.)(.)(.)(.)(.)(.)(.)', r'\10', 'abcdefghijklm' ) Problem is infinite loop in sre_parse.py. I've attached a change that I think fixes it.