-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
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
REF: array_to_datetime catch overflows in one place #24049
Conversation
Codecov Report
@@ Coverage Diff @@
## master #24049 +/- ##
==========================================
- Coverage 42.45% 42.45% -0.01%
==========================================
Files 161 161
Lines 51562 51561 -1
==========================================
- Hits 21892 21888 -4
- Misses 29670 29673 +3
Continue to review full report at Codecov.
|
Codecov Report
@@ Coverage Diff @@
## master #24049 +/- ##
=======================================
Coverage 42.45% 42.45%
=======================================
Files 161 161
Lines 51562 51562
=======================================
Hits 21892 21892
Misses 29670 29670
Continue to review full report at Codecov.
|
so what i think you should really do, is instead of nesting this further, move all that you have inside the try/except (in order to catch OutOfBounds), and put it in another function, then have maybe something like
|
Works for me. This hypothetical function would look a lot like
I'm not wild about using TypeError for flow-control here because it obscures cases when a TypeError is raised naturally. #24032 is an orthogonal refactor that I think improves the situation. Following that I'll take a look at implementing your suggestion here. |
yep
oh, that's what the original does, didn't actually mean to change anything. |
Yah, its 24032 that does change the behavior. I'm pretty sure the suggestion you made here will need tweaking after 24032, and I think that's a more important change, so should go first. |
ok, #24032 merged. rebase this and will look. |
I'm putting this together now and think the suggestion will work, but there are a bunch of state variables (seen_datetime, seen_integer, seen_string, out_tzoffset_vals) to keep track of, so it is getting pretty pointer-y. We should consider whether this refactor is worthwhile in its current form without separating out a new function. |
right it’s nice and clean but might involve some duplicated code but i think reducing nesting is worth that it becomes easier to reason about |
So I've gotten a version working with the new function separated out, but it adds enough non-pythonic complication that I'd rather leave the status quo than push it. If there's consensus that this PR as-is is an improvement on master then let's go for that, otherwise I'll close. #23675 and #23885 are much higher priorities. |
ok this is a net improvment. that function is a bear. but if you have time / maybe open an issue to refactor even more. |
The diff is big, but all this is doing is changing:
to:
Orthogonal to #24032, will need rebasing following #24031. All three of these should go before #24006.