2to3: Apply `filter` fixes. Closes #3053.

Generally, this involves using list comprehension, or explicit list
construction as `filter` is an iterator in Python 3.
REF: Replace filters with list comprehensions.

2to3 does a lot of list(filter(...)) sort of thing which can be
avoided by using list comprehensions instead of filters. This
also seems to clarify the code to a considerable degree.
BUG: Fix `not a in ...` to `a not in ...`.

Also break regular expression compiles out of the loop.
Merge pull request #3056 from charris/2to3-filter

2to3: Apply `filter` fixes. Closes #3053.