summaryrefslogtreecommitdiffstats
path: root/generator
diff options
context:
space:
mode:
authorKyle Manna <kyle@kylemanna.com>2015-09-20 18:39:45 -0700
committerKyle Manna <kyle@kylemanna.com>2015-09-20 18:55:04 -0700
commit67cafac8f2f4797e195c5ee1e1fcf691129f8694 (patch)
treef509bc173562f3fb7bd7d1e701b8fca9675eea5b /generator
parente02c65389493d195ee868bf927923108a753bf57 (diff)
generator: Fix strange unicode/str issue in python2
* Work around this by checking the appropriate class for the given * environment.
Diffstat (limited to 'generator')
-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 91a820f3..df973386 100755
--- a/generator/nanopb_generator.py
+++ b/generator/nanopb_generator.py
@@ -85,7 +85,14 @@ class Names:
return '_'.join(self.parts)
def __add__(self, other):
- if isinstance(other, str):
+ # The fdesc names are unicode and need to be handled for
+ # python2 and python3
+ try:
+ realstr = unicode
+ except NameError:
+ realstr = str
+
+ if isinstance(other, realstr):
return Names(self.parts + (other,))
elif isinstance(other, tuple):
return Names(self.parts + other)