Skip to content

Commit

Permalink
model.py: Fix bug in gen_flatten_data()
Browse files Browse the repository at this point in the history
The "python-3 hack" in this function does not work as intended.
"unicode = unicode" line in try branch results in a "UnboundLocalError"
on both python 2 and 3. This exception is a subclass of NameError, so
the except branch is always taken.

Consequence:
If the data is a very large string (like GlueX translation table),
doing "list(gen_flatten_data(data))" results in:
RuntimeError: maximum recursion depth exceeded in cmp

Recent GlueX translation table updates have been carried out
with ccdb 1.06.00, which does not have this bug.
  • Loading branch information
Nathan Sparks committed Aug 2, 2016
1 parent 9dc200b commit ee886bd
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion python/ccdb/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -431,7 +431,7 @@ def gen_flatten_data(data):
"""
#python 3 hack to basestr
try:
unicode = unicode
u = unicode
except NameError:
# 'unicode' is undefined, must be Python 3
check_type = str
Expand Down

0 comments on commit ee886bd

Please sign in to comment.