Skip to content

UnicodeEncodeError in warnings capture #2436

@coldnight

Description

@coldnight
  • Include a detailed description of the bug or suggestion
    We run tests in a CI server, but somethings it failed because the below internal error:
INTERNALERROR> Traceback (most recent call last):
INTERNALERROR>   File "/buildbot/worker/agent-admin_auto-test/build/.tox/py27/lib/python2.7/site-packages/_pytest/main.py", line 105, in wrap_session
INTERNALERROR>     session.exitstatus = doit(config, session) or 0
INTERNALERROR>   File "/buildbot/worker/agent-admin_auto-test/build/.tox/py27/lib/python2.7/site-packages/_pytest/main.py", line 141, in _main
INTERNALERROR>     config.hook.pytest_runtestloop(session=session)
INTERNALERROR>   File "/buildbot/worker/agent-admin_auto-test/build/.tox/py27/lib/python2.7/site-packages/_pytest/vendored_packages/pluggy.py", line 745, in __call__
INTERNALERROR>     return self._hookexec(self, self._nonwrappers + self._wrappers, kwargs)
INTERNALERROR>   File "/buildbot/worker/agent-admin_auto-test/build/.tox/py27/lib/python2.7/site-packages/_pytest/vendored_packages/pluggy.py", line 339, in _hookexec
INTERNALERROR>     return self._inner_hookexec(hook, methods, kwargs)
INTERNALERROR>   File "/buildbot/worker/agent-admin_auto-test/build/.tox/py27/lib/python2.7/site-packages/_pytest/vendored_packages/pluggy.py", line 334, in <lambda>
INTERNALERROR>     _MultiCall(methods, kwargs, hook.spec_opts).execute()
INTERNALERROR>   File "/buildbot/worker/agent-admin_auto-test/build/.tox/py27/lib/python2.7/site-packages/_pytest/vendored_packages/pluggy.py", line 613, in execute
INTERNALERROR>     return _wrapped_call(hook_impl.function(*args), self.execute)
INTERNALERROR>   File "/buildbot/worker/agent-admin_auto-test/build/.tox/py27/lib/python2.7/site-packages/_pytest/vendored_packages/pluggy.py", line 250, in _wrapped_call
INTERNALERROR>     wrap_controller.send(call_outcome)
INTERNALERROR>   File "/buildbot/worker/agent-admin_auto-test/build/.tox/py27/lib/python2.7/site-packages/_pytest/vendored_packages/pluggy.py", line 280, in get_result
INTERNALERROR>     _reraise(*ex)  # noqa
INTERNALERROR>   File "/buildbot/worker/agent-admin_auto-test/build/.tox/py27/lib/python2.7/site-packages/_pytest/vendored_packages/pluggy.py", line 265, in __init__
INTERNALERROR>     self.result = func()
INTERNALERROR>   File "/buildbot/worker/agent-admin_auto-test/build/.tox/py27/lib/python2.7/site-packages/_pytest/vendored_packages/pluggy.py", line 614, in execute
INTERNALERROR>     res = hook_impl.function(*args)
INTERNALERROR>   File "/buildbot/worker/agent-admin_auto-test/build/.tox/py27/lib/python2.7/site-packages/_pytest/main.py", line 164, in pytest_runtestloop
INTERNALERROR>     item.config.hook.pytest_runtest_protocol(item=item, nextitem=nextitem)
INTERNALERROR>   File "/buildbot/worker/agent-admin_auto-test/build/.tox/py27/lib/python2.7/site-packages/_pytest/vendored_packages/pluggy.py", line 745, in __call__
INTERNALERROR>     return self._hookexec(self, self._nonwrappers + self._wrappers, kwargs)
INTERNALERROR>   File "/buildbot/worker/agent-admin_auto-test/build/.tox/py27/lib/python2.7/site-packages/_pytest/vendored_packages/pluggy.py", line 339, in _hookexec
INTERNALERROR>     return self._inner_hookexec(hook, methods, kwargs)
INTERNALERROR>   File "/buildbot/worker/agent-admin_auto-test/build/.tox/py27/lib/python2.7/site-packages/_pytest/vendored_packages/pluggy.py", line 334, in <lambda>
INTERNALERROR>     _MultiCall(methods, kwargs, hook.spec_opts).execute()
INTERNALERROR>   File "/buildbot/worker/agent-admin_auto-test/build/.tox/py27/lib/python2.7/site-packages/_pytest/vendored_packages/pluggy.py", line 613, in execute
INTERNALERROR>     return _wrapped_call(hook_impl.function(*args), self.execute)
INTERNALERROR>   File "/buildbot/worker/agent-admin_auto-test/build/.tox/py27/lib/python2.7/site-packages/_pytest/vendored_packages/pluggy.py", line 250, in _wrapped_call
INTERNALERROR>     wrap_controller.send(call_outcome)
INTERNALERROR>   File "/buildbot/worker/agent-admin_auto-test/build/.tox/py27/lib/python2.7/site-packages/_pytest/warnings.py", line 73, in pytest_runtest_protocol
INTERNALERROR>     yield
INTERNALERROR>   File "/usr/local/lib/python2.7/contextlib.py", line 24, in __exit__
INTERNALERROR>     self.gen.next()
INTERNALERROR>   File "/buildbot/worker/agent-admin_auto-test/build/.tox/py27/lib/python2.7/site-packages/_pytest/warnings.py", line 66, in catch_warnings_for_item
INTERNALERROR>     warning.filename, warning.lineno, warning.line)
INTERNALERROR>   File "/buildbot/worker/agent-admin_auto-test/build/.tox/py27/lib/python2.7/warnings.py", line 50, in formatwarning
INTERNALERROR>     s =  "%s: %s: %s\n" % (lineno, category.__name__, message)
INTERNALERROR> UnicodeEncodeError: 'ascii' codec can't encode characters in position 35-37: ordinal not in range(128)

This problem is weird, sometimes happened and sometimes not. So I don't know why, and I can't let it happened again manually.

  • pip list of the virtual environment you are using
amqp (2.1.4)
appdirs (1.4.3)
backports-abc (0.5)
better-exceptions (0.1.8)
billiard (3.5.0.2)
celery (4.0.2)
certifi (2017.4.17)
common (2.4.8)
contextlib2 (0.5.5)
coverage (4.4.1)
decorator (4.0.11)
enum34 (1.1.6)
funcsigs (1.0.2)
gredis (0.0.8)
hashids (1.2.0)
Jinja2 (2.9.6)
kombu (4.0.2)
MarkupSafe (1.0)
mock (2.0.0)
modcov (0.0.3.dev30)
MySQL-python (1.2.5)
olefile (0.44)
packaging (16.8)
pbr (3.0.1)
Pillow (4.1.1)
pip (9.0.1)
py (1.4.33)
py-dateutil (2.2)
pycrypto (2.6.1)
pycurl (7.43.0)
pyparsing (2.2.0)
pytest (3.1.0)
pytest-cov (2.5.1)
pytz (2017.2)
qrcode (5.3)
raven (6.0.0)
redis (2.10.5)
requests (2.14.2)
setuptools (35.0.2)
singledispatch (3.4.0.3)
six (1.10.0)
SQLAlchemy (1.1.10)
sqlalchemy-migrate (0.11.0)
sqlparse (0.2.3)
suds-jurko (0.6)
Tempita (0.5.2)
tornado (4.5.1)
vine (1.1.3)
wheel (0.29.0)
wheezy.captcha (0.1.44)
xlrd (1.0.0)
xlwt (1.2.0)
  • pytest and operating system versions
$ .tox/py27/bin/pytest --version
This is pytest version 3.1.0, imported from /buildbot/worker/agent-admin_auto-test/build/.tox/py27/lib/python2.7/site-packages/pytest.pyc
setuptools registered plugins:
  pytest-cov-2.5.1 at /buildbot/worker/agent-admin_auto-test/build/.tox/py27/lib/python2.7/site-packages/pytest_cov/plugin.py
  celery-4.0.2 at /buildbot/worker/agent-admin_auto-test/build/.tox/py27/lib/python2.7/site-packages/celery/contrib/pytest.py

$ uname -a
Linux d4ad8bbd6105 4.4.0-78-generic #99-Ubuntu SMP Thu Apr 27 15:29:09 UTC 2017 x86_64 GNU/Linux
  • Minimal example if possible

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions