Skip to content

Commit 9da3f07

Browse files
committed
attempt at fixing windows console printing
1 parent 9abec55 commit 9da3f07

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

flickr_download/flick_download.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
from __future__ import print_function
99
from __future__ import unicode_literals
1010
import argparse
11+
import codecs
1112
import errno
1213
import logging
1314
import os
@@ -209,6 +210,11 @@ def main():
209210
if not ret:
210211
return 1
211212

213+
# Replace stdout with a non-strict writer that replaces unknown characters instead of throwing
214+
# an exception. This "fixes" print issues on the standard Windows terminal
215+
if sys.stdout.encoding.lower() != 'utf-8':
216+
sys.stdout = codecs.getwriter(sys.stdout.encoding)(sys.stdout, 'replace')
217+
212218
if args.list:
213219
print_sets(args.list)
214220
return 0

0 commit comments

Comments
 (0)