More robust pipe error check.
More robust pipe error check.

Copied from https://github.com/django/django/pull/3121/files#diff-f6d1c75ec606389da5af6558bf57f171

proversity-org/problem-builder,proversity-org/problem-builder,proversity-org/problem-builder