Skip to content

py.code.Code "path" attribute not always a py.path.local object #71

Closed
@pytestbot

Description

@pytestbot

Sometimes the path attribute of a py.code.Code object is not a py.local.path object but a plain string, usually due to a traceback entry not being located in a real file but as a result of an exec statement.

import sys
def test_entry_not_path():
    try:
        ns = {}
        exec('def foo(): raise ValueError', ns)
        ns['foo']()
    except ValueError:
        _, _, tb = sys.exc_info()
    tb = py.code.Traceback(tb)
    assert isinstance(tb[-1].path, py.path.local)

This caused a regression in pytest, as seen in #995.

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