I hit this when running some tests under nose with the xunit plugin. The plugin replaced sys.stdout with it's Tee object that as of version 1.3.0 did not implement isatty.
Safter isatty check
I've found a similar issue with pipe objects and posted a patch inspired from this one in #1022. Feedback always welcome. Thanks!
Changelog re #1019, closes #1019, closes #1022, closes #1186