Open Bug 1339103 Opened 7 years ago Updated 1 year ago

Python client unable to stringify error messages with Unicode characters (like "…") and fails to print exception details: TimeoutException: <unprintable TimeoutException object>

Categories

(Testing :: Marionette Client and Harness, defect, P3)

Version 3
defect

Tracking

(Not tracked)

People

(Reporter: whimboo, Unassigned)

Details

I tried to pass the following content as message to a TimeoutError. The Python client fails to actually print the message:

"Waiting for 127.0.0.1…"

> 1487003413236	Marionette	TRACE	conn6 <- [1,12,{"error":"timeout","message":"Error loading page, timed out: Waiting for 127.0.0.1…","stacktrace":"this.WebDriverError@chrome://marionette/content/error.js:214:17\nthis.TimeoutError@chrome://marionette/content/error.js:379:3\nonTimeout@chrome://marionette/content/driver.js:1165:16\n"},null]
[..]
TEST-UNEXPECTED-ERROR | test_minimized.py TestMinimizedTestCase.test | TimeoutException: <unprintable TimeoutException object>
Traceback (most recent call last):
  File "/Volumes/data/code/gecko/testing/marionette/harness/marionette_harness/marionette_test/testcases.py", line 166, in run
    testMethod()
  File "/Volumes/data/code/gecko/_a/test_minimized.py", line 30, in test
    self.marionette.navigate(self.marionette.absolute_url("slow"))
  File "/Volumes/data/code/gecko/testing/marionette/client/marionette_driver/marionette.py", line 1657, in navigate
    self._send_message("get", {"url": url})
  File "/Volumes/data/code/gecko/testing/marionette/client/marionette_driver/decorators.py", line 23, in _
    return func(*args, **kwargs)
  File "/Volumes/data/code/gecko/testing/marionette/client/marionette_driver/marionette.py", line 729, in _send_message
    self._handle_error(err)
  File "/Volumes/data/code/gecko/testing/marionette/client/marionette_driver/marionette.py", line 762, in _handle_error
    raise errors.lookup(error)(message, stacktrace=stacktrace)
Priority: -- → P3
Did you pass the value as a Unicode string?  Did the Python file have "coding: utf-8"?
Flags: needinfo?(hskupin)
The three dots unicode character has been set in Javascript and not Python.
Flags: needinfo?(hskupin)
I see, so it returns a TimeoutError with Unicode characters and it
gets unmarshaled to the Python TimeoutException object which it then
fails to stringify:

> TimeoutException: <unprintable TimeoutException object>
Summary: Special characters (like …) cause failure in printing exception details: TimeoutException: <unprintable TimeoutException object> → Python client unable to stringify error messages with Unicode characters (like "…") and fails to print exception details: TimeoutException: <unprintable TimeoutException object>
Hm, not really able to reproduce this, but I suspect it can
have something to do with Unicode conversion between mozlog and
Marionette:

> >>> resp = Response.from_msg(r"""[1,12,{"error":"timeout","message":"Error loading page, timed out: Waiting for 127.0.0.1…","stacktrace":"this.WebDriverError@chrome://marionette/content/error.js:214:17\nthis.TimeoutError@chrome://marionette/content/error.js:379:3\nonTimeout@chrome://marionette/content/driver.js:1165:16\n"},null]""")
> >>> resp
> <marionette_driver.transport.Response object at 0x7fb93662e590>
> >>> str(resp)
> "<Response id=12, error={u'stacktrace': u'this.WebDriverError@chrome://marionette/content/error.js:214:17\\nthis.TimeoutError@chrome://marionette/content/error.js:379:3\\nonTimeout@chrome://marionette/content/driver.js:1165:16\\n', u'message': u'Error loading page, timed out: Waiting for 127.0.0.1\\u2026', u'error': u'timeout'}, result=None>"
> >>> resp.error
> {u'stacktrace': u'this.WebDriverError@chrome://marionette/content/error.js:214:17\nthis.TimeoutError@chrome://marionette/content/error.js:379:3\nonTimeout@chrome://marionette/content/driver.js:1165:16\n', u'message': u'Error loading page, timed out: Waiting for 127.0.0.1\u2026', u'error': u'timeout'}
> >>> str(resp.error)
> "{u'stacktrace': u'this.WebDriverError@chrome://marionette/content/error.js:214:17\\nthis.TimeoutError@chrome://marionette/content/error.js:379:3\\nonTimeout@chrome://marionette/content/driver.js:1165:16\\n', u'message': u'Error loading page, timed out: Waiting for 127.0.0.1\\u2026', u'error': u'timeout'}"
Please note that I didn't escape the unicode character. Maybe that makes the difference here.
Severity: normal → S3
Product: Testing → Remote Protocol
Component: Marionette → Marionette Client and Harness
Product: Remote Protocol → Testing
You need to log in before you can comment on or make changes to this bug.