UnicodeEncodeError when run under Python 2.7

Bug #1457970 reported by Daniel Manrique
8
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Checkbox Support Library
Fix Released
High
Daniel Manrique

Bug Description

checkbox-support needs to work well under Python 2.7 since it's used in hexr which runs under 2.7.

James reported this:

Traceback (most recent call last):
  File "apps/uploads/checkbox_parser.py", line 228, in <module>
    sys.exit(main())
  File "apps/uploads/checkbox_parser.py", line 219, in main
    messages = parse_stream(stream)
  File "apps/uploads/checkbox_parser.py", line 22, in parse_stream
    parser.run(TestRun, messages=messages)
  File "/home/jjesudason/Documents/PES/hexr/hexr/local/lib/python2.7/site-packages/checkbox_support/parsers/submission.py",
line 1152, in run
    self.parseRoot(result, root)
  File "/home/jjesudason/Documents/PES/hexr/hexr/local/lib/python2.7/site-packages/checkbox_support/parsers/submission.py",
line 1125, in parseRoot
    parser(result, child)
  File "/home/jjesudason/Documents/PES/hexr/hexr/local/lib/python2.7/site-packages/checkbox_support/parsers/submission.py",
line 936, in parseContext
    result.addContext(text, command)
  File "/home/jjesudason/Documents/PES/hexr/hexr/local/lib/python2.7/site-packages/checkbox_support/parsers/submission.py",
line 643, in addContext
    text = text.decode("utf-8")
  File "/home/jjesudason/Documents/PES/hexr/hexr/lib/python2.7/encodings/utf_8.py",
line 16, in decode
    return codecs.utf_8_decode(input, errors, True)
UnicodeEncodeError: 'ascii' codec can't encode character u'\xe9' in
position 99516: ordinal not in range(128)
No JSON object could be decoded

How to reproduce:
- Run the attached submission.xml through the hexr checkbox_parser script using Python 2.7. Assuming up-to-date checkouts of lp:hexr and lp:checkbox, run this inside the hexr tree:

PYTHONPATH=/path/to/checkbox/checkbox-support python apps/uploads/checkbox_parser.py sample-with-modaliases-dkms.xml >/dev/null

Expected result:
- Nothing, since we're sending the good output to /dev/null

Actual result:
- Trace as seen above.

And as noted, running the same thing with python3 doesn't return anything (meaning it was parsed correctly).

Related branches

Daniel Manrique (roadmr)
Changed in checkbox-support:
importance: Undecided → High
Daniel Manrique (roadmr)
Changed in checkbox-support:
status: New → In Progress
assignee: nobody → Daniel Manrique (roadmr)
Changed in checkbox-support:
status: In Progress → Fix Committed
milestone: none → 0.20
Changed in checkbox-support:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.