Skip to content

Fix internal error when filtering tracebacks where one entry was generated by an exec() statement #1093

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

Merged
merged 2 commits into from
Oct 1, 2015

Conversation

nicoddemus
Copy link
Member

Fix #995

@RonnyPfannschmidt
Copy link
Member

Why cast a nonpath to local path?

IMHO this needs a comment and a output match in the testcase

return entry.path != cutdir1 and not entry.path.relto(cutdir2)
# ensure entry.path is always a py.path.local object
# see https://bitbucket.org/pytest-dev/py/issues/71
path = py.path.local(entry.path)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I kind of agree with ronny that it is not clear we want to cast to a path here.
What about if not isinstance(entry.path, py.path.local): return False?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should move this discussion to the issue I opened in py, for recording purposes.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe we should not use entry.path but rather entry.frame.code.raw.co_filename and detect "<...>" (a typical way to mark dynamic code) before entering the cut/filter logic with py.path.local(co_filename). When we detect dynamic code we should simply not filter it (i.e. return False) because we can't tell where it originated from.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, I will implement this change later then.

That aside, how about adding a entry.frame.code.is_generated() to abstract this away from clients and not having them hard-coding the "<...>"-detection logic?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sounds like a item for after moving py.code into _pytest

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Implemented the explicit dynamic code detection as we agreed. 😄

@RonnyPfannschmidt
Copy link
Member

we need to return None there and have checks for none

@nicoddemus
Copy link
Member Author

we need to return None there and have checks for none

I disagree, please see my comment in the py issue.

@RonnyPfannschmidt
Copy link
Member

i like holgers suggestion of checking the exact co_filename for generated code indicators

RonnyPfannschmidt added a commit that referenced this pull request Oct 1, 2015
Fix internal error when filtering tracebacks where one entry was generated by an exec() statement
Fixes #995
@RonnyPfannschmidt RonnyPfannschmidt merged commit b7fd3f0 into pytest-dev:master Oct 1, 2015
@nicoddemus nicoddemus deleted the relto-bug branch October 2, 2015 02:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants