Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Suppress "Compile called before Add" in re2.Filter
When compiling an empty set, ``FilteredRE2::Compile`` logs a warning to stderr which can not be suppressed (google/re2#485). Use low-level fd redirection to suppress that message as it does not seem to hurt, and not compiling is a lot worse (google/re2#484). To add to the fun, when running under pytest not only is stderr captured `sys.stderr` is redirected to an object with a different fd. Since the C stdlib does not even know about that it obviously keeps writing to the "normal" stderr, so use the raw fd number (2) instead of use the symbolic `sys.stderr.fileno()`. Thankfully this mess seems to be working on windows Less thankfully, since fds are process global and there's no real lock I know of this introduces a race, anyone could be trying to write to stderr while we've redirected the fd and I don't know how to fix this...
- Loading branch information