Skip to content

Commit

Permalink
Merge pull request XLSForm#186 from XLSForm/py3
Browse files Browse the repository at this point in the history
check encoding before trying to convert, avoids py3 errors
  • Loading branch information
ukanga authored Apr 3, 2018
2 parents 4a7d811 + 2ee6438 commit 423160f
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions pyxform/xls2json.py
Original file line number Diff line number Diff line change
Expand Up @@ -605,11 +605,13 @@ def workbook_to_json(
" Question or group with no name.")
question_name = unicode(row[constants.NAME])
if not is_valid_xml_tag(question_name):
if isinstance(question_name, bytes):
question_name = question_name.encode('utf-8')
error_message = row_format_string % row_number
error_message += " Invalid question name [" + \
question_name.encode('utf-8') + "] "
question_name + "] "
error_message += "Names must begin with a letter, colon,"\
+ " or underscore. "
+ " or underscore."
error_message += "Subsequent characters can include numbers," \
+ " dashes, and periods."
raise PyXFormError(error_message)
Expand Down

0 comments on commit 423160f

Please sign in to comment.