From: Mike Verdone Date: Sun, 27 Jan 2013 21:51:01 +0000 (+0100) Subject: UTF-8 decode extra_args only if Py 2.7. X-Git-Tag: twitter-1.9.1~2 X-Git-Url: https://jfr.im/git/z_archive/twitter.git/commitdiff_plain/d2f3bdc9ec47168999d8d300dc6dc87b1b203626 UTF-8 decode extra_args only if Py 2.7. --- diff --git a/twitter/cmdline.py b/twitter/cmdline.py index f586e4a..fd062f0 100644 --- a/twitter/cmdline.py +++ b/twitter/cmdline.py @@ -132,8 +132,9 @@ def parse_args(args, options): 'datestamp', 'no-ssl', 'force-ansi'] short_opts = "e:p:f:h?rR:c:l:td" opts, extra_args = getopt(args, short_opts, long_opts) - extra_args = [arg.decode(locale.getpreferredencoding()) - for arg in extra_args] + if extra_args and hasattr(extra_args[0], 'decode'): + extra_args = [arg.decode(locale.getpreferredencoding()) + for arg in extra_args] for opt, arg in opts: if opt in ('-f', '--format'):