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:
parent
a229db0dce
commit
fd2f3ea634
1 changed files with 10 additions and 5 deletions
|
@ -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:])
|
||||
|
|
Loading…
Reference in a new issue