1
0
Fork 0
mirror of https://github.com/borgbackup/borg.git synced 2024-12-25 17:27:31 +00:00

Fix UnicodeEncodeError on verbose output of unicode paths

We can't assume that the stdout encoding is not less restrictive
than the filesystem encoding.
This commit is contained in:
Jonas Borgström 2014-02-25 12:33:23 +01:00
parent a229db0dce
commit fd2f3ea634

View file

@ -2,6 +2,7 @@
from binascii import hexlify
from datetime import datetime
from operator import attrgetter
import io
import os
import stat
import sys
@ -598,6 +599,10 @@ def run(self, args=None):
def main():
# Make sure stdout and stderr have errors='replace') to avoid unicode
# issues when print()-ing unicode file names
sys.stdout = io.TextIOWrapper(sys.stdout.buffer, sys.stdout.encoding, 'replace', line_buffering=sys.stdout.line_buffering)
sys.stderr = io.TextIOWrapper(sys.stderr.buffer, sys.stderr.encoding, 'replace', line_buffering=sys.stderr.line_buffering)
archiver = Archiver()
try:
exit_code = archiver.run(sys.argv[1:])