Skip to content

InternalError: AttributeError: 'str' object has no attribute 'relto' #1133

Closed
@nicoddemus

Description

@nicoddemus

It seems there are other situations where Entry.path might return strings rather than py.path.local objects than just generated code. This is happening on pytest-qt AppVeyor on Python 2.7. 👻

I have modified my local code to print entry.path:

def filter_traceback(entry):
    # entry.path might sometimes return a str() object when the entry
    # points to dynamically generated code
    # see https://bitbucket.org/pytest-dev/py/issues/71
    raw_filename = entry.frame.code.raw.co_filename
    is_generated = '<' in raw_filename and '>' in raw_filename
    if is_generated:
        return False
    print('BRUNO', entry.path)
    return entry.path != cutdir1 and not entry.path.relto(cutdir2)

And this is what I see:

('BRUNO', 'pytestqt\\logging.py')

Not sure how to reproduce it, but anyway it seems to me we should take in account that entry.path might not be a py.path.local object. This fixes my test suite:

def filter_traceback(entry):
    # entry.path might sometimes return a str() object when the entry
    # points to dynamically generated code
    # see https://bitbucket.org/pytest-dev/py/issues/71
    raw_filename = entry.frame.code.raw.co_filename
    is_generated = '<' in raw_filename and '>' in raw_filename
    if is_generated:
        return False    
    p = py.path.local(entry.path)
    return p != cutdir1 and not p.relto(cutdir2)

@RonnyPfannschmidt @hpk42 any ideas?

============================= test session starts =============================
platform win32 -- Python 2.7.10, pytest-2.8.2, py-1.4.30, pluggy-0.3.1
PyQt4 4.11.4 -- Qt runtime 4.8.7 -- Qt compiled 4.8.7
rootdir: c:\users\bruno\appdata\local\temp\pytest-of-Bruno\pytest-2433\testdir\test_logging_mark_with_invalid_argument0, inifile:
plugins: qt-1.7.0
collected 1 items

test_logging_mark_with_invalid_argument.py ('BRUNO', local('X:\\pytest-qt\\.tox\\py27-pyqt4\\lib\\site-packages\\_pytest\\runner.py'))
('BRUNO', local('X:\\pytest-qt\\.tox\\py27-pyqt4\\lib\\site-packages\\_pytest\\runner.py'))
('BRUNO', local('X:\\pytest-qt\\.tox\\py27-pyqt4\\lib\\site-packages\\_pytest\\vendored_packages\\pluggy.py'))
('BRUNO', local('X:\\pytest-qt\\.tox\\py27-pyqt4\\lib\\site-packages\\_pytest\\vendored_packages\\pluggy.py'))
('BRUNO', local('X:\\pytest-qt\\.tox\\py27-pyqt4\\lib\\site-packages\\_pytest\\vendored_packages\\pluggy.py'))
('BRUNO', local('X:\\pytest-qt\\.tox\\py27-pyqt4\\lib\\site-packages\\_pytest\\vendored_packages\\pluggy.py'))
('BRUNO', local('X:\\pytest-qt\\.tox\\py27-pyqt4\\lib\\site-packages\\_pytest\\vendored_packages\\pluggy.py'))
('BRUNO', local('X:\\pytest-qt\\.tox\\py27-pyqt4\\lib\\site-packages\\_pytest\\vendored_packages\\pluggy.py'))
('BRUNO', local('X:\\pytest-qt\\.tox\\py27-pyqt4\\lib\\site-packages\\_pytest\\vendored_packages\\pluggy.py'))
('BRUNO', local('X:\\pytest-qt\\.tox\\py27-pyqt4\\lib\\site-packages\\_pytest\\vendored_packages\\pluggy.py'))
('BRUNO', local('X:\\pytest-qt\\.tox\\py27-pyqt4\\lib\\site-packages\\_pytest\\vendored_packages\\pluggy.py'))
('BRUNO', local('X:\\pytest-qt\\.tox\\py27-pyqt4\\lib\\site-packages\\_pytest\\vendored_packages\\pluggy.py'))
('BRUNO', local('X:\\pytest-qt\\.tox\\py27-pyqt4\\lib\\site-packages\\_pytest\\vendored_packages\\pluggy.py'))
('BRUNO', local('X:\\pytest-qt\\.tox\\py27-pyqt4\\lib\\site-packages\\_pytest\\vendored_packages\\pluggy.py'))
('BRUNO', 'pytestqt\\logging.py')

INTERNALERROR> Traceback (most recent call last):
INTERNALERROR>   File "X:\pytest-qt\.tox\py27-pyqt4\lib\site-packages\_pytest\main.py", line 90, in wrap_session
INTERNALERROR>     session.exitstatus = doit(config, session) or 0
INTERNALERROR>   File "X:\pytest-qt\.tox\py27-pyqt4\lib\site-packages\_pytest\main.py", line 121, in _main
INTERNALERROR>     config.hook.pytest_runtestloop(session=session)
INTERNALERROR>   File "X:\pytest-qt\.tox\py27-pyqt4\lib\site-packages\_pytest\vendored_packages\pluggy.py", line 724, in __call__
INTERNALERROR>     return self._hookexec(self, self._nonwrappers + self._wrappers, kwargs)
INTERNALERROR>   File "X:\pytest-qt\.tox\py27-pyqt4\lib\site-packages\_pytest\vendored_packages\pluggy.py", line 338, in _hookexec
INTERNALERROR>     return self._inner_hookexec(hook, methods, kwargs)
INTERNALERROR>   File "X:\pytest-qt\.tox\py27-pyqt4\lib\site-packages\_pytest\vendored_packages\pluggy.py", line 301, in __call__
INTERNALERROR>     return outcome.get_result()
INTERNALERROR>   File "X:\pytest-qt\.tox\py27-pyqt4\lib\site-packages\_pytest\vendored_packages\pluggy.py", line 279, in get_result
INTERNALERROR>     _reraise(*ex)  # noqa
INTERNALERROR>   File "X:\pytest-qt\.tox\py27-pyqt4\lib\site-packages\_pytest\vendored_packages\pluggy.py", line 264, in __init__
INTERNALERROR>     self.result = func()
INTERNALERROR>   File "X:\pytest-qt\.tox\py27-pyqt4\lib\site-packages\_pytest\vendored_packages\pluggy.py", line 299, in <lambda>
INTERNALERROR>     outcome = _CallOutcome(lambda: self.oldcall(hook, hook_impls, kwargs))
INTERNALERROR>   File "X:\pytest-qt\.tox\py27-pyqt4\lib\site-packages\_pytest\vendored_packages\pluggy.py", line 333, in <lambda>
INTERNALERROR>     _MultiCall(methods, kwargs, hook.spec_opts).execute()
INTERNALERROR>   File "X:\pytest-qt\.tox\py27-pyqt4\lib\site-packages\_pytest\vendored_packages\pluggy.py", line 596, in execute
INTERNALERROR>     res = hook_impl.function(*args)
INTERNALERROR>   File "X:\pytest-qt\.tox\py27-pyqt4\lib\site-packages\_pytest\main.py", line 146, in pytest_runtestloop
INTERNALERROR>     item.config.hook.pytest_runtest_protocol(item=item, nextitem=nextitem)
INTERNALERROR>   File "X:\pytest-qt\.tox\py27-pyqt4\lib\site-packages\_pytest\vendored_packages\pluggy.py", line 724, in __call__
INTERNALERROR>     return self._hookexec(self, self._nonwrappers + self._wrappers, kwargs)
INTERNALERROR>   File "X:\pytest-qt\.tox\py27-pyqt4\lib\site-packages\_pytest\vendored_packages\pluggy.py", line 338, in _hookexec
INTERNALERROR>     return self._inner_hookexec(hook, methods, kwargs)
INTERNALERROR>   File "X:\pytest-qt\.tox\py27-pyqt4\lib\site-packages\_pytest\vendored_packages\pluggy.py", line 301, in __call__
INTERNALERROR>     return outcome.get_result()
INTERNALERROR>   File "X:\pytest-qt\.tox\py27-pyqt4\lib\site-packages\_pytest\vendored_packages\pluggy.py", line 279, in get_result
INTERNALERROR>     _reraise(*ex)  # noqa
INTERNALERROR>   File "X:\pytest-qt\.tox\py27-pyqt4\lib\site-packages\_pytest\vendored_packages\pluggy.py", line 264, in __init__
INTERNALERROR>     self.result = func()
INTERNALERROR>   File "X:\pytest-qt\.tox\py27-pyqt4\lib\site-packages\_pytest\vendored_packages\pluggy.py", line 299, in <lambda>
INTERNALERROR>     outcome = _CallOutcome(lambda: self.oldcall(hook, hook_impls, kwargs))
INTERNALERROR>   File "X:\pytest-qt\.tox\py27-pyqt4\lib\site-packages\_pytest\vendored_packages\pluggy.py", line 333, in <lambda>
INTERNALERROR>     _MultiCall(methods, kwargs, hook.spec_opts).execute()
INTERNALERROR>   File "X:\pytest-qt\.tox\py27-pyqt4\lib\site-packages\_pytest\vendored_packages\pluggy.py", line 595, in execute
INTERNALERROR>     return _wrapped_call(hook_impl.function(*args), self.execute)
INTERNALERROR>   File "X:\pytest-qt\.tox\py27-pyqt4\lib\site-packages\_pytest\vendored_packages\pluggy.py", line 253, in _wrapped_call
INTERNALERROR>     return call_outcome.get_result()
INTERNALERROR>   File "X:\pytest-qt\.tox\py27-pyqt4\lib\site-packages\_pytest\vendored_packages\pluggy.py", line 279, in get_result
INTERNALERROR>     _reraise(*ex)  # noqa
INTERNALERROR>   File "X:\pytest-qt\.tox\py27-pyqt4\lib\site-packages\_pytest\vendored_packages\pluggy.py", line 264, in __init__
INTERNALERROR>     self.result = func()
INTERNALERROR>   File "X:\pytest-qt\.tox\py27-pyqt4\lib\site-packages\_pytest\vendored_packages\pluggy.py", line 596, in execute
INTERNALERROR>     res = hook_impl.function(*args)
INTERNALERROR>   File "X:\pytest-qt\.tox\py27-pyqt4\lib\site-packages\_pytest\runner.py", line 65, in pytest_runtest_protocol
INTERNALERROR>     runtestprotocol(item, nextitem=nextitem)
INTERNALERROR>   File "X:\pytest-qt\.tox\py27-pyqt4\lib\site-packages\_pytest\runner.py", line 72, in runtestprotocol
INTERNALERROR>     rep = call_and_report(item, "setup", log)
INTERNALERROR>   File "X:\pytest-qt\.tox\py27-pyqt4\lib\site-packages\_pytest\runner.py", line 121, in call_and_report
INTERNALERROR>     report = hook.pytest_runtest_makereport(item=item, call=call)
INTERNALERROR>   File "X:\pytest-qt\.tox\py27-pyqt4\lib\site-packages\_pytest\vendored_packages\pluggy.py", line 724, in __call__
INTERNALERROR>     return self._hookexec(self, self._nonwrappers + self._wrappers, kwargs)
INTERNALERROR>   File "X:\pytest-qt\.tox\py27-pyqt4\lib\site-packages\_pytest\vendored_packages\pluggy.py", line 338, in _hookexec
INTERNALERROR>     return self._inner_hookexec(hook, methods, kwargs)
INTERNALERROR>   File "X:\pytest-qt\.tox\py27-pyqt4\lib\site-packages\_pytest\vendored_packages\pluggy.py", line 301, in __call__
INTERNALERROR>     return outcome.get_result()
INTERNALERROR>   File "X:\pytest-qt\.tox\py27-pyqt4\lib\site-packages\_pytest\vendored_packages\pluggy.py", line 279, in get_result
INTERNALERROR>     _reraise(*ex)  # noqa
INTERNALERROR>   File "X:\pytest-qt\.tox\py27-pyqt4\lib\site-packages\_pytest\vendored_packages\pluggy.py", line 264, in __init__
INTERNALERROR>     self.result = func()
INTERNALERROR>   File "X:\pytest-qt\.tox\py27-pyqt4\lib\site-packages\_pytest\vendored_packages\pluggy.py", line 299, in <lambda>
INTERNALERROR>     outcome = _CallOutcome(lambda: self.oldcall(hook, hook_impls, kwargs))
INTERNALERROR>   File "X:\pytest-qt\.tox\py27-pyqt4\lib\site-packages\_pytest\vendored_packages\pluggy.py", line 333, in <lambda>
INTERNALERROR>     _MultiCall(methods, kwargs, hook.spec_opts).execute()
INTERNALERROR>   File "X:\pytest-qt\.tox\py27-pyqt4\lib\site-packages\_pytest\vendored_packages\pluggy.py", line 595, in execute
INTERNALERROR>     return _wrapped_call(hook_impl.function(*args), self.execute)
INTERNALERROR>   File "X:\pytest-qt\.tox\py27-pyqt4\lib\site-packages\_pytest\vendored_packages\pluggy.py", line 253, in _wrapped_call
INTERNALERROR>     return call_outcome.get_result()
INTERNALERROR>   File "X:\pytest-qt\.tox\py27-pyqt4\lib\site-packages\_pytest\vendored_packages\pluggy.py", line 279, in get_result
INTERNALERROR>     _reraise(*ex)  # noqa
INTERNALERROR>   File "X:\pytest-qt\.tox\py27-pyqt4\lib\site-packages\_pytest\vendored_packages\pluggy.py", line 264, in __init__
INTERNALERROR>     self.result = func()
INTERNALERROR>   File "X:\pytest-qt\.tox\py27-pyqt4\lib\site-packages\_pytest\vendored_packages\pluggy.py", line 595, in execute
INTERNALERROR>     return _wrapped_call(hook_impl.function(*args), self.execute)
INTERNALERROR>   File "X:\pytest-qt\.tox\py27-pyqt4\lib\site-packages\_pytest\vendored_packages\pluggy.py", line 249, in _wrapped_call
INTERNALERROR>     wrap_controller.send(call_outcome)
INTERNALERROR>   File "X:\pytest-qt\.tox\py27-pyqt4\lib\site-packages\_pytest\skipping.py", line 170, in pytest_runtest_makereport
INTERNALERROR>     rep = outcome.get_result()
INTERNALERROR>   File "X:\pytest-qt\.tox\py27-pyqt4\lib\site-packages\_pytest\vendored_packages\pluggy.py", line 279, in get_result
INTERNALERROR>     _reraise(*ex)  # noqa
INTERNALERROR>   File "X:\pytest-qt\.tox\py27-pyqt4\lib\site-packages\_pytest\vendored_packages\pluggy.py", line 264, in __init__
INTERNALERROR>     self.result = func()
INTERNALERROR>   File "X:\pytest-qt\.tox\py27-pyqt4\lib\site-packages\_pytest\vendored_packages\pluggy.py", line 596, in execute
INTERNALERROR>     res = hook_impl.function(*args)
INTERNALERROR>   File "X:\pytest-qt\.tox\py27-pyqt4\lib\site-packages\_pytest\runner.py", line 227, in pytest_runtest_makereport
INTERNALERROR>     style=item.config.option.tbstyle)
INTERNALERROR>   File "X:\pytest-qt\.tox\py27-pyqt4\lib\site-packages\_pytest\python.py", line 726, in _repr_failure_py
INTERNALERROR>     style=style)
INTERNALERROR>   File "X:\pytest-qt\.tox\py27-pyqt4\lib\site-packages\_pytest\main.py", line 397, in _repr_failure_py
INTERNALERROR>     self._prunetraceback(excinfo)
INTERNALERROR>   File "X:\pytest-qt\.tox\py27-pyqt4\lib\site-packages\_pytest\python.py", line 709, in _prunetraceback
INTERNALERROR>     ntraceback = ntraceback.filter(filter_traceback)
INTERNALERROR>   File "X:\pytest-qt\.tox\py27-pyqt4\lib\site-packages\py\_code\code.py", line 299, in filter
INTERNALERROR>     return Traceback(filter(fn, self))
INTERNALERROR>   File "X:\pytest-qt\.tox\py27-pyqt4\lib\site-packages\_pytest\python.py", line 60, in filter_traceback
INTERNALERROR>     return entry.path != cutdir1 and not entry.path.relto(cutdir2)
INTERNALERROR> AttributeError: 'str' object has no attribute 'relto'

Metadata

Metadata

Assignees

No one assigned

    Labels

    type: bugproblem that needs to be addressed

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions