Closed Bug 1087248 Opened 10 years ago Closed 10 years ago

[mozlog] Fix encoding for debug in HTML formatter such as page source

Categories

(Testing :: Mozbase, defect)

defect
Not set
normal

Tracking

(Not tracked)

RESOLVED FIXED
mozilla36

People

(Reporter: davehunt, Assigned: davehunt)

References

Details

Attachments

(3 files, 1 obsolete file)

The HTML formatter currently fails to output debug if it contains characters outside of the default encoding. The page source in B2G often contains such characters.
Blocks: 1087250
No longer blocks: 1065410
Attached patch Fix encoding to utf-8. v1.0 (obsolete) (deleted) — Splinter Review
This is how we fixed this in the HTML report currently generated by the Marionette test runner. I'm open to other suggestions.
Attachment #8509485 - Flags: review?(james)
Comment on attachment 8509485 [details] [diff] [review] Fix encoding to utf-8. v1.0 Review of attachment 8509485 [details] [diff] [review]: ----------------------------------------------------------------- ::: testing/mozbase/mozlog/mozlog/structured/formatters/html/html.py @@ +96,5 @@ > > def make_result_html(self, data): > + # change default encoding to avoid encoding problem for page source > + reload(sys) > + sys.setdefaultencoding('utf-8') This is terrifying ;) I think we should try to track down the places that are assuming ascii and actually fox them to be explicit. If you send me a log file that breaks I'll help with this.
Attachment #8509485 - Flags: review?(james) → review-
(In reply to James Graham [:jgraham] from comment #2) > I think we should try to track down the places that are assuming ascii and > actually fox them to be explicit. If you send me a log file that breaks I'll > help with this. I was hoping you'd say that. Traceback and page source that caused it coming up!
Flags: needinfo?(james)
It looks like the content argument in base64.b64encode(content) must be a unicode string. If you instead pass in content.encode("utf8") I expect it will work.
Flags: needinfo?(james)
Attached patch Fix encoding to utf-8. v2.0 (deleted) — Splinter Review
(In reply to James Graham [:jgraham] from comment #6) > It looks like the content argument in base64.b64encode(content) must be a > unicode string. If you instead pass in content.encode("utf8") I expect it > will work. Yep, that works well. Thanks!
Attachment #8509485 - Attachment is obsolete: true
Attachment #8511943 - Flags: review?(james)
Attachment #8511943 - Flags: review?(james) → review+
Status: ASSIGNED → RESOLVED
Closed: 10 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla36
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: