Skip to content

Commit f3995e8

Browse files
committed
fix sys.stdout handling on Windows because of colorlog and colorama
1 parent 68d5acd commit f3995e8

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

twtoolbox/cli.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
import sys
1919
import logging
2020
from argparse import ArgumentParser
21+
from contextlib import closing
2122
from .helpers import init_logger
2223
from . import streaming
2324
from . import tweets
@@ -29,7 +30,9 @@
2930

3031
def _get_writer(filename, resume=False):
3132
if filename is None:
32-
return sys.stdout
33+
if "__exit__" in dir(sys.stdout):
34+
return sys.stdout
35+
return closing(sys.stdout)
3336
return open(filename, "a" if resume else "w")
3437

3538
def _read_strings(filename):

0 commit comments

Comments
 (0)