Merge "arguments are not locale decoded into Unicode"
This commit is contained in:
commit
f40f3f9f2f
@ -18,7 +18,9 @@
|
||||
|
||||
import argparse
|
||||
import getpass
|
||||
import locale
|
||||
import logging
|
||||
import six
|
||||
import sys
|
||||
import traceback
|
||||
|
||||
@ -474,8 +476,17 @@ class OpenStackShell(app.App):
|
||||
tcmd.run(targs)
|
||||
|
||||
|
||||
def main(argv=sys.argv[1:]):
|
||||
def main(argv=None):
|
||||
if argv is None:
|
||||
argv = sys.argv[1:]
|
||||
if six.PY2:
|
||||
# Emulate Py3, decode argv into Unicode based on locale so that
|
||||
# commands always see arguments as text instead of binary data
|
||||
encoding = locale.getpreferredencoding()
|
||||
if encoding:
|
||||
argv = map(lambda arg: arg.decode(encoding), argv)
|
||||
|
||||
return OpenStackShell().run(argv)
|
||||
|
||||
if __name__ == "__main__":
|
||||
sys.exit(main(sys.argv[1:]))
|
||||
sys.exit(main())
|
||||
|
Loading…
x
Reference in New Issue
Block a user