Merge pull request #1057 from tahoe-lafs/3704-tahoe-get-regression

Fix `tahoe get` regression.

Fixes ticket:3704
This commit is contained in:
Itamar Turner-Trauring 2021-05-12 12:03:35 -04:00 committed by GitHub
commit 32e82a5a48
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 13 additions and 4 deletions

0
newsfragments/3704.minor Normal file
View File

View File

@ -1,5 +1,7 @@
from __future__ import print_function
from future.utils import PY3
from urllib.parse import quote as url_quote
from allmydata.scripts.common import get_alias, DEFAULT_ALIAS, escape_path, \
UnknownAliasError
@ -32,7 +34,7 @@ def get(options):
outf = stdout
# Make sure we can write bytes; on Python 3 stdout is Unicode by
# default.
if getattr(outf, "encoding", None) is not None:
if PY3 and getattr(outf, "encoding", None) is not None:
outf = outf.buffer
while True:
data = resp.read(4096)

View File

@ -10,7 +10,7 @@ from future.utils import PY2
if PY2:
from future.builtins import filter, map, zip, ascii, chr, hex, input, next, oct, open, pow, round, super, bytes, dict, list, object, range, str, max, min # noqa: F401
from six import ensure_str
from six import ensure_text
from six.moves import StringIO
import os.path
from twisted.trial import unittest
@ -182,7 +182,7 @@ class CreateAlias(GridTestMixin, CLITestMixin, unittest.TestCase):
(rc, out, err) = args
self.failUnlessReallyEqual(rc, 0)
self.assertEqual(len(err), 0, err)
self.failUnlessIn(ensure_str("Alias %s created") % quote_output(etudes_arg), out)
self.failUnlessIn(u"Alias %s created" % ensure_text(quote_output(etudes_arg)), out)
aliases = get_aliases(self.get_clientdir())
self.failUnless(aliases[u"\u00E9tudes"].startswith(b"URI:DIR2:"))

View File

@ -105,9 +105,15 @@ def run_cli_native(verb, *args, **kwargs):
# necessary. This works okay for ASCII and if LANG is set
# appropriately. These aren't great constraints so we should move
# away from this behavior.
#
# The encoding attribute doesn't change StringIO behavior on Python 2,
# but it's there for realism of the emulation.
stdin = StringIO(stdin)
stdin.encoding = encoding
stdout = StringIO()
stdout.encoding = encoding
stderr = StringIO()
stderr.encoding = encoding
else:
# The new behavior, the Python 3 behavior, is to accept unicode and
# encode it using a specific encoding. For older versions of Python 3,

View File

@ -3,7 +3,8 @@
# test suite on all supported python versions. To use it, "pip install tox"
# and then run "tox" from this directory.
# Map Python versions in GitHub Actions to tox environments to run.
# Map Python versions in GitHub Actions to tox environments to run, for use by
# the tox-gh-actions package.
[gh-actions]
python =
2.7: py27-coverage,codechecks