We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 68d5acd commit f3995e8Copy full SHA for f3995e8
1 file changed
twtoolbox/cli.py
@@ -18,6 +18,7 @@
18
import sys
19
import logging
20
from argparse import ArgumentParser
21
+from contextlib import closing
22
from .helpers import init_logger
23
from . import streaming
24
from . import tweets
@@ -29,7 +30,9 @@
29
30
31
def _get_writer(filename, resume=False):
32
if filename is None:
- return sys.stdout
33
+ if "__exit__" in dir(sys.stdout):
34
+ return sys.stdout
35
+ return closing(sys.stdout)
36
return open(filename, "a" if resume else "w")
37
38
def _read_strings(filename):
0 commit comments