mirror of
https://github.com/tahoe-lafs/tahoe-lafs.git
synced 2025-02-21 02:01:31 +00:00
Alongside unicode_to_argv, declare the argv type to avoid errors on Windows now that args are actually unicode.
This commit is contained in:
parent
0838133006
commit
c673726139
@ -1,6 +1,6 @@
|
||||
from __future__ import print_function
|
||||
|
||||
from future.utils import PY2, native_str, bchr, binary_type
|
||||
from future.utils import PY2, bchr, binary_type
|
||||
from future.builtins import str as future_str
|
||||
from past.builtins import unicode
|
||||
|
||||
@ -20,7 +20,7 @@ from twisted.trial import unittest
|
||||
|
||||
from ..util.assertutil import precondition
|
||||
from ..scripts import runner
|
||||
from allmydata.util.encodingutil import unicode_platform, get_filesystem_encoding, get_io_encoding
|
||||
from allmydata.util.encodingutil import unicode_platform, get_filesystem_encoding, get_io_encoding, argv_type
|
||||
|
||||
|
||||
def skip_if_cannot_represent_filename(u):
|
||||
@ -75,8 +75,8 @@ def run_cli_native(verb, *args, **kwargs):
|
||||
nodeargs = kwargs.pop("nodeargs", [])
|
||||
encoding = kwargs.pop("encoding", None)
|
||||
precondition(
|
||||
all(isinstance(arg, native_str) for arg in [verb] + nodeargs + list(args)),
|
||||
"arguments to run_cli must be a native string -- convert using unicode_to_argv",
|
||||
all(isinstance(arg, argv_type) for arg in [verb] + nodeargs + list(args)),
|
||||
"arguments to run_cli must be {argv_type} -- convert using unicode_to_argv".format(argv_type=argv_type),
|
||||
verb=verb,
|
||||
args=args,
|
||||
nodeargs=nodeargs,
|
||||
|
@ -13,6 +13,7 @@ from __future__ import print_function
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from future.utils import PY2, PY3, native_str
|
||||
from future.builtins import str as future_str
|
||||
if PY2:
|
||||
# We omit str() because that seems too tricky to get right.
|
||||
from builtins import filter, map, zip, ascii, chr, hex, input, next, oct, open, pow, round, super, bytes, dict, list, object, range, max, min # noqa: F401
|
||||
@ -142,6 +143,14 @@ def unicode_to_argv(s, mangle=False):
|
||||
return ensure_str(s)
|
||||
|
||||
|
||||
# According to unicode_to_argv above, the expected type for
|
||||
# cli args depends on the platform, so capture that expectation.
|
||||
argv_type = future_str if sys.platform == "win32" else native_str
|
||||
"""
|
||||
The expected type for args to a subprocess
|
||||
"""
|
||||
|
||||
|
||||
def unicode_to_url(s):
|
||||
"""
|
||||
Encode an unicode object used in an URL to bytes.
|
||||
|
Loading…
x
Reference in New Issue
Block a user