gh-146092: Raise MemoryError on allocation failure in _zoneinfo#146165
gh-146092: Raise MemoryError on allocation failure in _zoneinfo#146165vstinner merged 3 commits intopython:mainfrom
Conversation
parse_transition_rule() is only used in parse_tz_str() and parse_tz_str() raises ValueError on parse_transition_rule() failure. Other parse_transition_rule() error paths don't set an exception. So I didn't add PyErr_NoMemory() in parse_transition_rule(). |
Can you please clarify why? The |
I tried that but I ended up with strange exceptions from a subfunction. |
|
Oh yes, I see, I was able to reproduce that. Instead we could do: if (parse_transition_rule(&p, transitions[i])) {
- PyErr_Format(PyExc_ValueError,
- "Malformed transition rule in TZ string: %R",
- tz_str_obj);
+ if (!PyErr_ExceptionMatches(PyExc_MemoryError)) {
+ PyErr_Format(PyExc_ValueError,
+ "Malformed transition rule in TZ string: %R",
+ tz_str_obj);
+ }
goto error;
}
}Since |
|
Ok, I updated parse_transition_rule() to raise MemoryError and use |
|
@StanFromIreland: Please review the updated PR. |
|
Thanks @vstinner for the PR 🌮🎉.. I'm working now to backport this PR to: 3.13, 3.14. |
…pythonGH-146165) (cherry picked from commit 6450b1d) Co-authored-by: Victor Stinner <vstinner@python.org>
…pythonGH-146165) (cherry picked from commit 6450b1d) Co-authored-by: Victor Stinner <vstinner@python.org>
|
GH-146223 is a backport of this pull request to the 3.14 branch. |
|
Merged, thanks for your reviews! |
|
GH-146224 is a backport of this pull request to the 3.13 branch. |
PyErr_NoMemoryin_zoneinfoload_dataandts_to_local#146092