Skip to content

Commit

Permalink
[fix] strange python frontends often fails here, don't break redbaron…
Browse files Browse the repository at this point in the history
… for that
  • Loading branch information
Psycojoker committed Jan 13, 2015
1 parent ab89dec commit 79a4e24
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion redbaron.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,16 @@

def in_a_shell():
# the isinstance here is for building sphinx doc
return isinstance(sys.stdout, StringIO) or (hasattr(sys.stdout, 'fileno') and os.isatty(sys.stdout.fileno()))
if isinstance(sys.stdout, StringIO):
return True
try:
if hasattr(sys.stdout, 'fileno') and os.isatty(sys.stdout.fileno()):
return True
except Exception:
# someone is doing strange things with stdout (eg: bpython or ipython notebook)
return False

return False


def indent(block_of_text, indentation):
Expand Down

0 comments on commit 79a4e24

Please sign in to comment.