gh-146092: Raise MemoryError on allocation failure in _zoneinfo#146165
gh-146092: Raise MemoryError on allocation failure in _zoneinfo#146165vstinner wants to merge 2 commits intopython:mainfrom
Conversation
Modules/_zoneinfo.c
Outdated
|
|
||
| DayRule *rv = PyMem_Calloc(1, sizeof(DayRule)); | ||
| if (rv == NULL) { | ||
| PyErr_NoMemory(); |
There was a problem hiding this comment.
parse_tz_str will then also raise a PyExc_ValueError, this will be confusing for users.
There was a problem hiding this comment.
Oh, I didn't want to raise MemoryError in parse_transition_rule(). I revert this change.
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. |
PyErr_NoMemoryin_zoneinfoload_dataandts_to_local#146092