[Python-Dev] Need to hook Py_FatalError

M.Utku K. m.u.k.2 at gawab.com
Wed May 4 11:35:42 CEST 2005


Hi,

Josiah Carlson <jcarlson at uci.edu> wrote in
news:20050503132639.6492.JCARLSON at uci.edu: 

>>> strip....
>> IMHO this should be left to hooker(apparerently not right word, but you
>> get the point :) ). If he allocates more mem. or does heavy stuff, that
>> will just fail. Anyway abort() is a failure too. Either abort() will
>> end the process or OS will on such a critical error.
> 
> I'm not talking about doing memory-intensive callbacks, I'm talking
> about the function call itself.
> 
>>From what I understand, any function call in Python requires a memory
> allocation. This is trivially true in the case of rentrant Python calls;
> which requires the allocation of a frame object from heap memory, and in
> the case of all calls, from C stack memory. If you cannot allocate a
> frame for __del__ method calling (one of the error conditions), you
> certainly aren't going to be able to call a Python callback (no heap
> memory), and may not have enough stack memory required by your logging
> function; even if it is written in C (especially if you construct a
> nontrivial portion of the message in memory before it is printed).
> 
> If I'm wrong, I'd like to hear it, but I'm still waiting for your patch
> on sourceforge.
>  - Josiah


Wait a minute I guess I wasn't clear on that: The callback will be only in C 
level smtg like "PySetFatalError_CallBack" , there will be no way to hook it 
from Python because as you said Python may have crashed hard like "Can't 
initialize type".

Best regards.



More information about the Python-Dev mailing list