AttributeError: module 'cgi' has no attribute 'escape' when using mozlog
Categories
(Testing :: Mozbase, defect, P2)
Tracking
(firefox85 fixed)
Tracking | Status | |
---|---|---|
firefox85 | --- | fixed |
People
(Reporter: hermes.cheng, Assigned: bc)
References
(Blocks 1 open bug)
Details
Attachments
(1 file)
User Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.183 Safari/537.36
Steps to reproduce:
- use mozlog in my test automation project.
- use parameter "--log-html LOG_HTML" to generate html report
My project is using Python 3.8.
Actual results:
Got errors like below.
mozlog.structuredlog: Failure calling log handler:
Traceback (most recent call last):
File "/Users/hermesc/workspace/QA/kapic/.v3.0/lib/python3.8/site-packages/mozlog/structuredlog.py", line 274, in _handle_log
handler(data)
File "/Users/hermesc/workspace/QA/kapic/.v3.0/lib/python3.8/site-packages/mozlog/handlers/base.py", line 74, in call
formatted = self.formatter(data)
File "/Users/hermesc/workspace/QA/kapic/.v3.0/lib/python3.8/site-packages/mozlog/handlers/base.py", line 42, in call
return self.inner(item)
File "/Users/hermesc/workspace/QA/kapic/.v3.0/lib/python3.8/site-packages/mozlog/reader.py", line 74, in call
return handler(data)
File "/Users/hermesc/workspace/QA/kapic/.v3.0/lib/python3.8/site-packages/mozlog/formatters/html/html.py", line 105, in test_end
self.make_result_html(data)
File "/Users/hermesc/workspace/QA/kapic/.v3.0/lib/python3.8/site-packages/mozlog/formatters/html/html.py", line 208, in make_result_html
log.append(raw(cgi.escape(line)))
AttributeError: module 'cgi' has no attribute 'escape'
Expected results:
it should generate html report without any exception.
Reporter | ||
Comment 1•4 years ago
|
||
It looks like we can use html
to replace cgi
like below.
import html
(skip)
log.append(html.span(raw(html.escape(line)), class_="error"))
else:
log.append(raw(html.escape(line)))
Reporter | ||
Comment 2•4 years ago
|
||
Fabrice,
Do you know who can help fix this and publish it to PyPi?
Comment 3•4 years ago
|
||
According to https://wiki.mozilla.org/Auto-tools/Projects/Mozbase it is maintained by Will Lachance (:wlach) and Andrew Halberstadt (:ahal)
Updated•4 years ago
|
Updated•4 years ago
|
Comment 4•4 years ago
•
|
||
Yes, I can help review and publish if you could submit a patch to Phabricator! Looks like cgi.escape
was removed in Python 3.8. So html.escape
is the correct replacement there. Couple things to bear in mind:
- We should try to maintain py2 compat for now (though I'm not aware of anything in-tree using this formatter.. so maybe it's fine to drop it).
- There's already a global variable called
html
in that module. We'll need to rename it or useimport html as
Comment 5•3 years ago
|
||
The severity field is not set for this bug.
:bc, could you have a look please?
For more information, please visit auto_nag documentation.
Assignee | ||
Comment 6•3 years ago
|
||
I'll take it as part of my python3 work. eta this week sometime.
Assignee | ||
Comment 7•3 years ago
|
||
Pushed by bclary@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/18f7558b7bb0 python3 - [mozlog] use cgi.escape for Python2, html.escape for Python3. r=jgraham
Comment 9•3 years ago
|
||
bugherder |
Description
•