On Wed, May 04, 2005 at 03:29:33PM +0000, M.Utku K. wrote:
> James William Pye <[EMAIL PROTECTED]> wrote in
> news:[EMAIL PROTECTED]: 
> > Why should reinitialization be allowed at all? Seems to me that this
> > feature should be exclusively reserved for an embedding application to
> > handle the fatal in an application specific way; ie ereport(FATAL,()) in
> > PostgreSQL, which quickly exits after some cleanup. Why should an
> > extension module be allowed to set this, or reset it?
> 
> What if more than one extension needs it ?

I agree with James; As I imagine this feature, it is for programs that
embed Python, not for extensions.  Whether the hook would be written to
prevent this from being done, or whether it would just be documented as
"for embedders only", I don't care.

In my own application, I didn't use a setter function, I just created a
new global variable.  This works fine for me.  It doesn't prevent the
(abusive, in my view) hooking of the error handler by any old extension,
but since my application doesn't currently import shared modules it
doesn't matter.

--- /tmp/Python-2.3/Python/pythonrun.c  2003-07-15 20:54:38.000000000 -0500
+++ ./pythonrun.c       2005-04-11 13:32:39.000000000 -0500
@@ -1435,9 +1435,14 @@
 
 /* Print fatal error message and abort */
 
+void (*Py_FatalErrorHandler)(const char *msg) = NULL;
 void
 Py_FatalError(const char *msg)
 {
+        if(Py_FatalErrorHandler != NULL) { 
+                Py_FatalErrorHandler(msg);
+                fprintf(stderr, "PyFatalErrorHandler returned\n");
+        }
        fprintf(stderr, "Fatal Python error: %s\n", msg);
 #ifdef MS_WINDOWS
        OutputDebugString("Fatal Python error: ");

Attachment: pgpmJ9g1tfE0g.pgp
Description: PGP signature

_______________________________________________
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com

Reply via email to