summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPetteri Aimonen <jpa@git.mail.kapsi.fi>2015-04-08 18:05:25 +0300
committerPetteri Aimonen <jpa@git.mail.kapsi.fi>2015-04-08 18:05:25 +0300
commit9e4ac1ba9b27ebb8d37a6c58ae11fa748ddb7384 (patch)
tree4aa4259e7437a4d3b2ad4062402c2ab45fc0ffd5
parent400fba7f8f4a9758edaa02c67159fba0bbc60e8d (diff)
Fix problem with plugin options on Python 2.7.2 and older.
Update issue 153 Status: FixedInGit
-rwxr-xr-xgenerator/nanopb_generator.py9
1 files changed, 8 insertions, 1 deletions
diff --git a/generator/nanopb_generator.py b/generator/nanopb_generator.py
index b1ee04e0..49ce4da6 100755
--- a/generator/nanopb_generator.py
+++ b/generator/nanopb_generator.py
@@ -1384,8 +1384,15 @@ def main_plugin():
data = sys.stdin.read()
request = plugin_pb2.CodeGeneratorRequest.FromString(data)
+ try:
+ # Versions of Python prior to 2.7.3 do not support unicode
+ # input to shlex.split(). Try to convert to str if possible.
+ params = str(request.parameter)
+ except UnicodeEncodeError:
+ params = request.parameter
+
import shlex
- args = shlex.split(request.parameter)
+ args = shlex.split(params)
options, dummy = optparser.parse_args(args)
Globals.verbose_options = options.verbose