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

Removed raise_from_traceback #29174

Merged
merged 8 commits into from
Oct 26, 2019

Conversation

WillAyd
Copy link
Member

@WillAyd WillAyd commented Oct 22, 2019

ref #29170

This is a pretty old compat function that I think actually hides the errors we are looking for when run via load scheduling. I've converted to a mixture of raise...from and raise (e).with_traceback() depending on what was available. Not sure it matters too much either way

Let's see...

@WillAyd WillAyd added 2/3 Compat Error Reporting Incorrect or improved errors from pandas labels Oct 23, 2019
@@ -912,11 +909,9 @@ def _parse(flavor, io, match, attrs, encoding, displayed_only, **kwargs):
"different flavor.".format(flav)
)

retained = caught
raise
Copy link
Member

Choose a reason for hiding this comment

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

does this change the current behavior? for/else is a pretty obscure idiom that i dont have intuition for

Copy link
Member

Choose a reason for hiding this comment

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

Also if you're inclined to tighten the except Exception above while in the neighborhood, that'd be cool

Copy link
Member Author

Choose a reason for hiding this comment

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

The else clause in for...else would only get executed if there was no break in the for block. In this cause it would break if no exception was raised in the try...else

Come to think of it we could get rid of the try...else now too. I'll see what that looks like after this CI run completes (mostly want to see if it helps with the HTML issue visibility)

Copy link
Member Author

Choose a reason for hiding this comment

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

Actually misread that. This goes through a fallback pattern of the various parsers trying one after the next. I erroneously just raised on first available - might not be well tested...

For now just reverted; can open a follow up for clean up and except Exception handling as you mentioned

@WillAyd
Copy link
Member Author

WillAyd commented Oct 23, 2019

Looks like this does actually preserve the traceback:

https://travis-ci.org/pandas-dev/pandas/jobs/601566770#L2267

@@ -2533,7 +2533,7 @@ def exception_matches(self, exc_type, exc_value, trace_back):
pat=self.regexp.pattern, val=val
)
e = AssertionError(msg)
raise_with_traceback(e, trace_back)
raise e.with_traceback(trace_back)
Copy link
Member

Choose a reason for hiding this comment

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

since assert_raises_regex has been deprecated internally, can we just remove the complete _AssertRaisesContextmanager class.

Copy link
Member Author

Choose a reason for hiding this comment

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

Not overly familiar with this code but seems very logical...I'll give it a shot and see what happens

Copy link
Member Author

Choose a reason for hiding this comment

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

Hmm well thinking this through some more some of our pandas.util.testing items have leaked into the public API, so we might want to deprecate first. I'll open an issue to discuss

Copy link
Member

Choose a reason for hiding this comment

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

It was publicly deprecated in 0.24, so with the new version policy, I think ok to remove in 1.0

Copy link
Member Author

Choose a reason for hiding this comment

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

Ah... missed that. Makes sense - thanks

@jbrockmendel
Copy link
Member

unused sys import

@WillAyd WillAyd added this to the 1.0 milestone Oct 23, 2019
@WillAyd
Copy link
Member Author

WillAyd commented Oct 25, 2019

Comments addressed and all green here

@jbrockmendel
Copy link
Member

LGTM

Copy link
Member

@simonjayhawkins simonjayhawkins left a comment

Choose a reason for hiding this comment

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

Thanks @WillAyd I'll merge this as-is, but as a follow-up could you remove the code check and add the deprecation to whatsnew.

@simonjayhawkins simonjayhawkins merged commit a38a004 into pandas-dev:master Oct 26, 2019
@jreback
Copy link
Contributor

jreback commented Oct 26, 2019

normally on a deprecation removal we should have the whatsnew note along with all of the changes in the same PR as otherwise it’s harder to track / follow

@WillAyd WillAyd deleted the remove-raise-with-tb branch October 28, 2019 20:37
HawkinsBA pushed a commit to HawkinsBA/pandas that referenced this pull request Oct 29, 2019
@gfyoung
Copy link
Member

gfyoung commented Oct 29, 2019

Nice to see this removed as a result of our move to pytest !

Reksbril pushed a commit to Reksbril/pandas that referenced this pull request Nov 18, 2019
Reksbril pushed a commit to Reksbril/pandas that referenced this pull request Nov 18, 2019
moi90 added a commit to moi90/pandas that referenced this pull request Dec 9, 2019
proost pushed a commit to proost/pandas that referenced this pull request Dec 19, 2019
proost pushed a commit to proost/pandas that referenced this pull request Dec 19, 2019
proost pushed a commit to proost/pandas that referenced this pull request Dec 19, 2019
proost pushed a commit to proost/pandas that referenced this pull request Dec 19, 2019
bongolegend pushed a commit to bongolegend/pandas that referenced this pull request Jan 1, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Error Reporting Incorrect or improved errors from pandas
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants