Command-line arguments are now always converted to UTF-8 before use.

This commit is contained in:
Adam Waldenberg 2013-07-14 03:10:00 +02:00
parent 7f0e2b6fe8
commit 5c9335088a
2 changed files with 18 additions and 6 deletions

View File

@ -104,15 +104,16 @@ def __check_python_version__():
sys.exit(_("gitinspector requires at leat Python 2.6 to run (version {0} was found).").format(python_version))
def main():
argv = terminal.convert_command_line_to_utf8()
__run__ = Runner()
try:
__opts__, __args__ = optval.gnu_getopt(sys.argv[1:], "cf:F:hHlLmrTwx:", ["checkout-missing:true", "exclude=",
"file-types=", "format=", "hard:true", "help",
"list-file-types:true", "localize-output:true",
"metrics:true", "responsibilities:true", "since=",
"grading:true", "timeline:true", "until=", "version",
"weeks:true"])
__opts__, __args__ = optval.gnu_getopt(argv[1:], "cf:F:hHlLmrTwx:", ["checkout-missing:true", "exclude=",
"file-types=", "format=", "hard:true", "help",
"list-file-types:true", "localize-output:true",
"metrics:true", "responsibilities:true", "since=",
"grading:true", "timeline:true", "until=", "version",
"weeks:true"])
for arg in __args__:
__run__.repo = arg

View File

@ -106,3 +106,14 @@ def get_size():
def set_stdout_encoding():
if not sys.stdout.isatty() and sys.version_info < (3,):
sys.stdout = codecs.getwriter('utf-8')(sys.stdout)
def convert_command_line_to_utf8():
try:
argv = []
for arg in sys.argv:
argv.append(arg.decode(sys.stdin.encoding, "replace"))
return argv;
except AttributeError:
return sys.argv;