Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"AttributeError: 'long' object has no attribute 'encode'" after updating to 3.3.0 #2956

Closed
edmorley opened this issue Nov 27, 2017 · 4 comments
Labels
status: critical grave problem or usability issue that affects lots of users type: regression indicates a problem that was introduced in a release which was working previously

Comments

@edmorley
Copy link

edmorley commented Nov 27, 2017

Hi!

Our PR updating us from pytest 3.2.5 to 3.3.0 (mozilla/treeherder#2993) is failing, with:

...
INTERNALERROR>   File "/home/travis/venv/lib/python2.7/site-packages/_pytest/warnings.py", line 94, in pytest_runtest_protocol
INTERNALERROR>     yield
INTERNALERROR>   File "/opt/python/2.7.14/lib/python2.7/contextlib.py", line 24, in __exit__
INTERNALERROR>     self.gen.next()
INTERNALERROR>   File "/home/travis/venv/lib/python2.7/site-packages/_pytest/warnings.py", line 75, in catch_warnings_for_item
INTERNALERROR>     new_args = [compat.ascii_escaped(m) for m in warn_msg.args]
INTERNALERROR>   File "/home/travis/venv/lib/python2.7/site-packages/_pytest/compat.py", line 187, in ascii_escaped
INTERNALERROR>     return val.encode('unicode-escape')
INTERNALERROR> AttributeError: 'long' object has no attribute 'encode'

(Full log: https://travis-ci.org/mozilla/treeherder/jobs/308166122#L706)

This is using:

  • Ubuntu 14.04
  • Python 2.7.14
  • pytest 3.3.0
  • pluggy 0.6.0
  • pytest-selenium 1.11.2
  • pytest-django 3.1.2
  • pytest-html 1.16.0
  • pytest-metadata 1.5.0
  • pytest-variables 1.7.0
  • pytest-base-url 1.4.1

Is this a possible regression from #2810?

@nicoddemus
Copy link
Member

Thanks @edmorley for writing!

Hmm that's strange, it seems one of the arguments of the warning objects is a long object.

@nicoddemus nicoddemus added status: critical grave problem or usability issue that affects lots of users type: regression indicates a problem that was introduced in a release which was working previously labels Nov 28, 2017
@nicoddemus
Copy link
Member

Here's a reproducer:

import warnings

import pytest


@pytest.mark.filterwarnings('always')
def test():
    warnings.warn(UserWarning(1, u'foo'))

@nicoddemus
Copy link
Member

Opened #2958 with a fix. 👍

nicoddemus added a commit to nicoddemus/pytest that referenced this issue Nov 28, 2017
@edmorley
Copy link
Author

Many thanks for looking into this!

It's a bit late now, but in case you were curious, the warnings that must be triggering this are these:
https://travis-ci.org/mozilla/treeherder/jobs/308178684#L678

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: critical grave problem or usability issue that affects lots of users type: regression indicates a problem that was introduced in a release which was working previously
Projects
None yet
Development

No branches or pull requests

2 participants