Brandon spake verily:
I have solved our problem with triple-quotes.
The problem is that Emacs expects PyFlakes to only output error
messages, but on a syntax error, PyFlakes prints out an error message,
then the *entire* contents of the module that it cannot import, and
*finally* a line that contains a number of spaces equal to the offset
into the file of the syntax error (in the case of my real-world file,
the triple-quote was 3,896 characters into the file, so PyFlake's line
of spaces was that long as well). The offending code is in the
"pyflakes" command-line program and looks like this:
print >> sys.stderr, 'could not compile %r:%d:' % (filename, lineno)
print >> sys.stderr, line
print >> sys.stderr, " " * (offset-2), "^"
By removing or commenting out those last two lines, so that PyFlakes
only outputs its error message, you will stop flooding the Emacs
regular-expression engine with data. It's actually the long line of
spaces that causes the problem, and it's one regular expression that's
really sensitive to it (this is from the Emacs 22 flymake.el):
;; ant/javac
(" *\\(\\[javac\\] *\\)?\\(\\([a-zA-Z]:\\)?[^:(\t\n]+\\)\:\\([0-9]+\\)\:[ \t\n]*\\(.+\\)"
2 4 nil 5))
For some reason (I'm not an RE engine guru), something about the way
it's matching spaces takes exponential time when given several thousand
spaces. Go figure. Anyway, I see no point in throwing anything but
error messages at Flymake, so I comment out both the printing of the
module and the spaces from PyFlakes.
And sure nuff, that solves it. Brandon gets a well-deserved $500.00.
http://divmod.org/trac/browser/tags/releases/Pyflakes-0.3.0/NEWS.txt says
3 - Don't hang flymake with unmatched triple quotes (only report a single
4 line of source for a multiline syntax error).