Skip to content

Instantly share code, notes, and snippets.

@kaeawc
Created June 10, 2016 21:07
Show Gist options
  • Save kaeawc/25ad5a2c44dad58bc8323a4848270952 to your computer and use it in GitHub Desktop.
Save kaeawc/25ad5a2c44dad58bc8323a4848270952 to your computer and use it in GitHub Desktop.
WSGI error attempting to log unicode
Traceback (most recent call last):
File "/usr/local/lib/python3.4/dist-packages/flask/app.py", line 1475, in full_dispatch_request
rv = self.dispatch_request()
File "/usr/local/lib/python3.4/dist-packages/flask/app.py", line 1461, in dispatch_request
return self.view_functions[rule.endpoint](**req.view_args)
File "/usr/local/lib/python3.4/dist-packages/newrelic-2.60.0.46/newrelic/hooks/framework_flask.py", line 30, in _nr_wrapper_handler_
return wrapped(*args, **kwargs)
File "/api/services/playground/controllers/search.py", line 67, in test_unicode_stuff
File "/usr/lib/python3.4/logging/__init__.py", line 1596, in info
self.log(INFO, msg, *args, **kwargs)
File "/api/shared/libs/logging/style_adapter.py", line 18, in log
self.logger._log(level, Message(msg, args), (), **kwargs)
File "/usr/lib/python3.4/logging/__init__.py", line 1409, in _log
self.handle(record)
File "/usr/lib/python3.4/logging/__init__.py", line 1419, in handle
self.callHandlers(record)
File "/usr/lib/python3.4/logging/__init__.py", line 1481, in callHandlers
hdlr.handle(record)
File "/usr/lib/python3.4/logging/__init__.py", line 853, in handle
self.emit(record)
File "/usr/lib/python3.4/logging/__init__.py", line 984, in emit
self.handleError(record)
File "/usr/lib/python3.4/logging/__init__.py", line 915, in handleError
traceback.print_stack(frame, file=sys.stderr)
File "/usr/lib/python3.4/traceback.py", line 286, in print_stack
print_list(extract_stack(_get_stack(f), limit=limit), file=file)
File "/usr/lib/python3.4/traceback.py", line 30, in print_list
print(item, file=file, end="")
UnicodeEncodeError: 'ascii' codec can't encode character '\U0001f499' in position 148: ordinal not in range(128)
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/lib/python3.4/logging/__init__.py", line 980, in emit
stream.write(msg)
UnicodeEncodeError: 'ascii' codec can't encode character '\U0001f499' in position 170: ordinal not in range(128)
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/local/lib/python3.4/dist-packages/flask/app.py", line 1836, in __call__
return self.wsgi_app(environ, start_response)
File "/usr/local/lib/python3.4/dist-packages/newrelic-2.60.0.46/newrelic/api/web_transaction.py", line 1342, in _nr_wsgi_application_wrapper_
result = wrapped(*args, **kwargs)
File "/usr/local/lib/python3.4/dist-packages/flask/app.py", line 1820, in wsgi_app
response = self.make_response(self.handle_exception(e))
File "/usr/local/lib/python3.4/dist-packages/newrelic-2.60.0.46/newrelic/hooks/framework_flask.py", line 86, in _nr_wrapper_Flask_handle_exception_
return wrapped(*args, **kwargs)
File "/usr/local/lib/python3.4/dist-packages/flask/app.py", line 1403, in handle_exception
reraise(exc_type, exc_value, tb)
File "/usr/local/lib/python3.4/dist-packages/flask/_compat.py", line 33, in reraise
raise value
File "/usr/local/lib/python3.4/dist-packages/flask/app.py", line 1817, in wsgi_app
response = self.full_dispatch_request()
File "/usr/local/lib/python3.4/dist-packages/flask/app.py", line 1477, in full_dispatch_request
rv = self.handle_user_exception(e)
File "/usr/local/lib/python3.4/dist-packages/newrelic-2.60.0.46/newrelic/hooks/framework_flask.py", line 86, in _nr_wrapper_Flask_handle_exception_
return wrapped(*args, **kwargs)
File "/usr/local/lib/python3.4/dist-packages/flask/app.py", line 1379, in handle_user_exception
return handler(e)
File "/usr/local/lib/python3.4/dist-packages/newrelic-2.60.0.46/newrelic/hooks/framework_flask.py", line 105, in _nr_wrapper_error_handler_
return wrapped(*args, **kwargs)
File "./main.py", line 45, in handle_unknowns
return handle_error_as_http(ex)
File "/api/shared/libs/http/errors.py", line 183, in handle_error_as_http
status_code=status_code)
File "/api/shared/libs/http/errors.py", line 84, in make_json_error
log_stacktrace()
File "/api/shared/libs/http/errors.py", line 57, in log_stacktrace
logger.error(line.replace('\n', ''))
File "/usr/lib/python3.4/logging/__init__.py", line 1303, in error
self._log(ERROR, msg, args, **kwargs)
File "/usr/lib/python3.4/logging/__init__.py", line 1409, in _log
self.handle(record)
File "/usr/lib/python3.4/logging/__init__.py", line 1419, in handle
self.callHandlers(record)
File "/usr/lib/python3.4/logging/__init__.py", line 1481, in callHandlers
hdlr.handle(record)
File "/usr/lib/python3.4/logging/__init__.py", line 853, in handle
self.emit(record)
File "/usr/lib/python3.4/logging/__init__.py", line 984, in emit
self.handleError(record)
File "/usr/lib/python3.4/logging/__init__.py", line 906, in handleError
traceback.print_exception(t, v, tb, None, sys.stderr)
File "/usr/lib/python3.4/traceback.py", line 170, in print_exception
print(line, file=file, end="")
UnicodeEncodeError: 'ascii' codec can't encode character '\U0001f499' in position 148: ordinal not in range(128)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment