-
-
Notifications
You must be signed in to change notification settings - Fork 18.5k
ENH: Keep original stack when exception happened in dataframe.apply #4254
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
Conversation
Can you show stack traces before and after your change? |
Before: After This change will help me to location issue in formula_util.py, line 65, in getCR function quickly. PS: pyformulas.py process_similar function is the function being applied to dataframe. |
+1 this is essential for everyday work and the opaque behaviour was a major deterrent for apply/map/transform/groupby operations. |
can you post a complete example (and cut down the traceback to the a couple of the last lines) ideally if you produce 2 (or more) examples that show different exceptions from the function (e.g. say I am thinking we might have a couple of tests that verify this |
A trivial example (so post the existing and new errors)
|
I don't think there is need for tests, this is the standard way of re-raise exception: |
the reason for tests are to verify standard pandas behavior, how did you know that a future change preserves this behavior? that is the reason for tests (as the current behavior is wrong) |
Oh, you mean create a new test case in But that would be a new pull request, right? And, I can't figure out a way to write a test case for asserting error stack at the moment, as the stack calling the test itself maybe changed. >_< There is also no point to checking the exception type being raise, and raise/ raise e give the same type of exception. |
I mean add onto this PR (add another commit) You don't need to assert the stack, just assert that the exception raises (AND the error message) is what you except the example I gave above you give a very specific error message (which is different from what I posted). It is very important to test this as certain higher level operations catch various exceptions and pass them on or raise as needed. This change even though looks very trivial could cause real changes if say you have an embedded apply and something is (maybe erroreously) relying upon a raised exception here's how to do this (this is testing that the constructors raise correctly)
|
Sorry, but I don't understand. My PR is about preserving the call stack, not about the exception being raise nor its error message. The exception raised and the error message is exactly the same before and after my patch. |
is that ALWAYS the case? are the error messages different? |
@jreback The errors messages are the same before & after this patch. |
ahhh...I thought the applied function error was not bubbling up....so ok then... |
^_^ |
@Wuvist can you set up travis? if u need help doing that i can show u how. thanks |
travis? The CI tools? I'm willing to try it. ^_^ but, how does travis related to this PR? |
in this case it is probably trivial. but it is good practice. so pls hook up. see contributing.md for a howto thanks! |
@Wuvist if you have time to rebase this and setup travis - it'd be nice to have this fix. |
closing in favor of #4549 |
when using raise e, the error stack app user received will begin in _apply_standard method.
Use raise instead, so that user could received error stack in funv(v) call. Easier for user to debug.