This commit is contained in:
Itamar Turner-Trauring 2021-05-17 12:59:38 -04:00
parent c92bf72437
commit 073f521cc1
2 changed files with 8 additions and 3 deletions

View File

@ -15,13 +15,14 @@ import os.path
from six.moves import cStringIO as StringIO
from datetime import timedelta
import re
import sys
from twisted.trial import unittest
from twisted.python.monkey import MonkeyPatcher
from allmydata.util import fileutil
from allmydata.util.fileutil import abspath_expanduser_unicode
from allmydata.util.encodingutil import get_io_encoding, unicode_to_argv
from allmydata.util.encodingutil import quote_output, unicode_to_argv
from allmydata.util.namespace import Namespace
from allmydata.scripts import cli, backupdb
from ..common_util import StallMixin
@ -372,7 +373,7 @@ class Backup(GridTestMixin, CLITestMixin, StallMixin, unittest.TestCase):
def test_exclude_options_unicode(self):
nice_doc = u"nice_d\u00F8c.lyx"
try:
doc_pattern_arg = u"*d\u00F8c*".encode(get_io_encoding())
doc_pattern_arg = quote_output(u"*d\u00F8c*", sys.stdout.encoding)
except UnicodeEncodeError:
raise unittest.SkipTest("A non-ASCII command argument could not be encoded on this platform.")
@ -399,6 +400,7 @@ class Backup(GridTestMixin, CLITestMixin, StallMixin, unittest.TestCase):
fileutil.write(excl_filepath, exclusion_string)
backup_options = parse(['--exclude-from', excl_filepath, 'from', 'to'])
filtered = list(backup_options.filter_listdir(root_listdir))
import pdb; pdb.set_trace()
self._check_filtering(filtered, root_listdir, (u'_darcs', u'subdir'),
(nice_doc, u'lib.a'))

View File

@ -276,7 +276,10 @@ def quote_output(s, quotemarks=True, quote_newlines=None, encoding=None):
On Python 3, returns Unicode strings.
"""
precondition(isinstance(s, (bytes, unicode)), s)
encoding = encoding or io_encoding
# Since we're quoting, the assumption is this will be read by a human, and
# therefore printed, so stdout's encoding is the plausible one. io_encoding
# is now always utf-8.
encoding = encoding or getattr(sys.stdout, "encoding") or io_encoding
if quote_newlines is None:
quote_newlines = quotemarks