[Python-checkins] CVS: python/dist/src/Modules almodule.c,1.30,1.31 cdmodule.c,1.23,1.24 errnomodule.c,2.13,2.14 fcntlmodule.c,2.24,2.25 linuxaudiodev.c,2.7,2.8 mathmodule.c,2.53,2.54 mpzmodule.c,2.31,2.32 parsermodule.c,2.54,2.55 pcremodule.c,2.23,2.24 puremodule.c,2.3,2.4 shamodule.c,2.10,2.11 stropmodule.c,2.72,2.73 syslogmodule.c,2.16,2.17 timemodule.c,2.101,2.102 timingmodule.c,2.7,2.8

Barry Warsaw python-dev@python.org
Fri, 1 Sep 2000 02:01:36 -0700


Update of /cvsroot/python/python/dist/src/Modules
In directory slayer.i.sourceforge.net:/tmp/cvs-serv17453

Modified Files:
	almodule.c cdmodule.c errnomodule.c fcntlmodule.c 
	linuxaudiodev.c mathmodule.c mpzmodule.c parsermodule.c 
	pcremodule.c puremodule.c shamodule.c stropmodule.c 
	syslogmodule.c timemodule.c timingmodule.c 
Log Message:
Do the absolute minimal amount of modifications to eradicate
Py_FatalError() from module initialization functions.  The importing
mechanism already checks for PyErr_Occurred() after module importation
and it Does The Right Thing.

Unfortunately, the following either were not compiled or tested by the
regression suite, due to issues with my development platform:

	almodule.c
	cdmodule.c
	mpzmodule.c
	puremodule.c
	timingmodule.c



Index: almodule.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Modules/almodule.c,v
retrieving revision 1.30
retrieving revision 1.31
diff -C2 -r1.30 -r1.31
*** almodule.c	2000/07/21 06:00:07	1.30
--- almodule.c	2000/09/01 09:01:32	1.31
***************
*** 3243,3250 ****
  #endif /* OLD_INTERFACE */
  	
! 	/* Check for errors */
! 	if (PyErr_Occurred()) {
! 	  error:
! 		Py_FatalError("can't initialize module al");
! 	}
  }
--- 3243,3247 ----
  #endif /* OLD_INTERFACE */
  	
!   error:
! 	return;
  }

Index: cdmodule.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Modules/cdmodule.c,v
retrieving revision 1.23
retrieving revision 1.24
diff -C2 -r1.23 -r1.24
*** cdmodule.c	2000/07/21 06:00:07	1.23
--- cdmodule.c	2000/09/01 09:01:32	1.24
***************
*** 803,808 ****
  	PyDict_SetItemString(d, "CDROM", PyInt_FromLong((long) CD_CDROM));
  #endif
- 
- 	if (PyErr_Occurred())
- 		Py_FatalError("can't initialize module cd");
  }
--- 803,805 ----

Index: errnomodule.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Modules/errnomodule.c,v
retrieving revision 2.13
retrieving revision 2.14
diff -C2 -r2.13 -r2.14
*** errnomodule.c	2000/07/21 06:00:07	2.13
--- errnomodule.c	2000/09/01 09:01:32	2.14
***************
*** 36,50 ****
  _inscode(PyObject *d, PyObject *de, char *name, int code)
  {
! 	PyObject *u;
! 	PyObject *v;
  
! 	u = PyString_FromString(name);
! 	v = PyInt_FromLong((long) code);
! 
! 	if (!u || !v) {
! 		/* Don't bother reporting this error */
! 		PyErr_Clear();
! 	}
! 	else {
  		/* insert in modules dict */
  		PyDict_SetItem(d, u, v);
--- 36,47 ----
  _inscode(PyObject *d, PyObject *de, char *name, int code)
  {
! 	PyObject *u = PyString_FromString(name);
! 	PyObject *v = PyInt_FromLong((long) code);
  
! 	/* Don't bother checking for errors; they'll be caught at the end
! 	 * of the module initialization function by the caller of
! 	 * initerrno().
! 	 */
! 	if (u && v) {
  		/* insert in modules dict */
  		PyDict_SetItem(d, u, v);
***************
*** 77,82 ****
  	d = PyModule_GetDict(m);
  	de = PyDict_New();
! 	if (de == NULL || PyDict_SetItemString(d, "errorcode", de))
! 		Py_FatalError("can't initialize errno module");
  
  /* Macro so I don't have to edit each and every line below... */
--- 74,79 ----
  	d = PyModule_GetDict(m);
  	de = PyDict_New();
! 	if (!d || !de || PyDict_SetItemString(d, "errorcode", de) < 0)
! 		return;
  
  /* Macro so I don't have to edit each and every line below... */

Index: fcntlmodule.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Modules/fcntlmodule.c,v
retrieving revision 2.24
retrieving revision 2.25
diff -C2 -r2.24 -r2.25
*** fcntlmodule.c	2000/08/02 20:46:51	2.24
--- fcntlmodule.c	2000/09/01 09:01:32	2.25
***************
*** 329,335 ****
  	d = PyModule_GetDict(m);
  	all_ins(d);
- 
- 	/* Check for errors */
- 	if (PyErr_Occurred())
- 		Py_FatalError("can't initialize module fcntl");
  }
--- 329,331 ----

Index: linuxaudiodev.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Modules/linuxaudiodev.c,v
retrieving revision 2.7
retrieving revision 2.8
diff -C2 -r2.7 -r2.8
*** linuxaudiodev.c	2000/08/31 18:11:07	2.7
--- linuxaudiodev.c	2000/09/01 09:01:32	2.8
***************
*** 443,450 ****
      Py_DECREF(x);
  
!     /* Check for errors */
!     if (PyErr_Occurred()) {
!     error:
!         Py_FatalError("can't initialize module linuxaudiodev");
!     }
  }
--- 443,447 ----
      Py_DECREF(x);
  
!   error:
!     return;
  }

Index: mathmodule.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Modules/mathmodule.c,v
retrieving revision 2.53
retrieving revision 2.54
diff -C2 -r2.53 -r2.54
*** mathmodule.c	2000/08/10 04:23:30	2.53
--- mathmodule.c	2000/09/01 09:01:32	2.54
***************
*** 269,275 ****
                  goto finally;
  	Py_DECREF(v);
- 	return;
  
    finally:
!         Py_FatalError("can't initialize math module");
  }
--- 269,274 ----
                  goto finally;
  	Py_DECREF(v);
  
    finally:
! 	return;
  }

Index: mpzmodule.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Modules/mpzmodule.c,v
retrieving revision 2.31
retrieving revision 2.32
diff -C2 -r2.31 -r2.32
*** mpzmodule.c	2000/07/21 06:00:07	2.31
--- mpzmodule.c	2000/09/01 09:01:32	2.32
***************
*** 1730,1742 ****
  	/* create some frequently used constants */
  	if ((mpz_value_zero = newmpzobject()) == NULL)
! 		Py_FatalError("initmpz: can't initialize mpz constants");
  	mpz_set_ui(&mpz_value_zero->mpz, (unsigned long int)0);
  
  	if ((mpz_value_one = newmpzobject()) == NULL)
! 		Py_FatalError("initmpz: can't initialize mpz constants");
  	mpz_set_ui(&mpz_value_one->mpz, (unsigned long int)1);
  
  	if ((mpz_value_mone = newmpzobject()) == NULL)
! 		Py_FatalError("initmpz: can't initialize mpz constants");
  	mpz_set_si(&mpz_value_mone->mpz, (long)-1);
  
--- 1730,1742 ----
  	/* create some frequently used constants */
  	if ((mpz_value_zero = newmpzobject()) == NULL)
! 		goto finally;
  	mpz_set_ui(&mpz_value_zero->mpz, (unsigned long int)0);
  
  	if ((mpz_value_one = newmpzobject()) == NULL)
! 		goto finally;
  	mpz_set_ui(&mpz_value_one->mpz, (unsigned long int)1);
  
  	if ((mpz_value_mone = newmpzobject()) == NULL)
! 		goto finally;
  	mpz_set_si(&mpz_value_mone->mpz, (long)-1);
  
***************
*** 1745,1750 ****
  		PyDict_SetItemString(dict, "MPZType", (PyObject*)&MPZtype);
  	}
! 
  } /* initmpz() */
  #ifdef MAKEDUMMYINT
  int _mpz_dummy_int;	/* XXX otherwise, we're .bss-less (DYNLOAD->Jack?) */
--- 1745,1752 ----
  		PyDict_SetItemString(dict, "MPZType", (PyObject*)&MPZtype);
  	}
!   finally:
! 	return;
  } /* initmpz() */
+ 
  #ifdef MAKEDUMMYINT
  int _mpz_dummy_int;	/* XXX otherwise, we're .bss-less (DYNLOAD->Jack?) */

Index: parsermodule.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Modules/parsermodule.c,v
retrieving revision 2.54
retrieving revision 2.55
diff -C2 -r2.54 -r2.55
*** parsermodule.c	2000/08/26 07:38:06	2.54
--- parsermodule.c	2000/09/01 09:01:32	2.55
***************
*** 2863,2871 ****
  
      if ((parser_error == 0)
!         || (PyDict_SetItemString(dict, "ParserError", parser_error) != 0)) {
!         /*
!          *  This is serious.
!          */
!         Py_FatalError("can't define parser.ParserError");
      }
      /*
--- 2863,2870 ----
  
      if ((parser_error == 0)
!         || (PyDict_SetItemString(dict, "ParserError", parser_error) != 0))
!     {
! 	    /* caller will check PyErr_Occurred() */
! 	    return;
      }
      /*

Index: pcremodule.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Modules/pcremodule.c,v
retrieving revision 2.23
retrieving revision 2.24
diff -C2 -r2.23 -r2.24
*** pcremodule.c	2000/07/21 06:00:07	2.23
--- pcremodule.c	2000/09/01 09:01:32	2.24
***************
*** 651,658 ****
  	insint(d, "VERBOSE", PCRE_EXTENDED);
  	insint(d, "LOCALE", PCRE_LOCALE);
- 	
- 	/* Check for errors */
- 	if (PyErr_Occurred())
- 		Py_FatalError("can't initialize module pcre");
  }
  
--- 651,654 ----

Index: puremodule.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Modules/puremodule.c,v
retrieving revision 2.3
retrieving revision 2.4
diff -C2 -r2.3 -r2.4
*** puremodule.c	2000/08/18 05:13:47	2.3
--- puremodule.c	2000/09/01 09:01:32	2.4
***************
*** 984,988 ****
  	PyDict_SetItemString(d, "QUANTIFY_VERSION", Py_None);
  #endif
- 	if (PyErr_Occurred())
- 		Py_FatalError("couldn't initialize the pure module");
  }
--- 984,986 ----

Index: shamodule.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Modules/shamodule.c,v
retrieving revision 2.10
retrieving revision 2.11
diff -C2 -r2.10 -r2.11
*** shamodule.c	2000/08/15 06:03:35	2.10
--- shamodule.c	2000/09/01 09:01:32	2.11
***************
*** 560,566 ****
                                  blocks */ 
      insint("digestsize", 20);
- 
-     /* Check for errors */
-     if (PyErr_Occurred())
-         Py_FatalError("can't initialize module SHA");
  }
--- 560,562 ----

Index: stropmodule.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Modules/stropmodule.c,v
retrieving revision 2.72
retrieving revision 2.73
diff -C2 -r2.72 -r2.73
*** stropmodule.c	2000/08/03 02:34:44	2.72
--- stropmodule.c	2000/09/01 09:01:32	2.73
***************
*** 1245,1250 ****
  		Py_DECREF(s);
  	}
- 
- 	if (PyErr_Occurred())
- 		Py_FatalError("can't initialize module strop");
  }
--- 1245,1247 ----

Index: syslogmodule.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Modules/syslogmodule.c,v
retrieving revision 2.16
retrieving revision 2.17
diff -C2 -r2.16 -r2.17
*** syslogmodule.c	2000/07/21 06:00:07	2.16
--- syslogmodule.c	2000/09/01 09:01:32	2.17
***************
*** 233,239 ****
  	ins(d, "LOG_UUCP",	LOG_UUCP);
  	ins(d, "LOG_NEWS",	LOG_NEWS);
- 
- 	/* Check for errors */
- 	if (PyErr_Occurred())
- 		Py_FatalError("can't initialize module syslog");
  }
--- 233,235 ----

Index: timemodule.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Modules/timemodule.c,v
retrieving revision 2.101
retrieving revision 2.102
diff -C2 -r2.101 -r2.102
*** timemodule.c	2000/08/15 18:52:33	2.101
--- timemodule.c	2000/09/01 09:01:32	2.102
***************
*** 513,524 ****
  ins(PyObject *d, char *name, PyObject *v)
  {
! 	if (v == NULL)
! 		Py_FatalError("Can't initialize time module -- NULL value");
! 	if (PyDict_SetItemString(d, name, v) != 0)
! 		Py_FatalError(
! 		"Can't initialize time module -- PyDict_SetItemString failed");
! 	Py_DECREF(v);
  }
  
  static char module_doc[] =
  "This module provides various functions to manipulate time values.\n\
--- 513,525 ----
  ins(PyObject *d, char *name, PyObject *v)
  {
! 	/* Don't worry too much about errors, they'll be caught by the
! 	 * caller of inittime().
! 	 */
! 	if (v)
! 		PyDict_SetItemString(d, name, v);
! 	Py_XDECREF(v);
  }
  
+ 
  static char module_doc[] =
  "This module provides various functions to manipulate time values.\n\
***************
*** 648,653 ****
  #endif /* HAVE_TM_ZONE */
  #endif /* !HAVE_TZNAME || __GLIBC__ */
- 	if (PyErr_Occurred())
- 		Py_FatalError("Can't initialize time module");
  }
  
--- 649,652 ----

Index: timingmodule.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Modules/timingmodule.c,v
retrieving revision 2.7
retrieving revision 2.8
diff -C2 -r2.7 -r2.8
*** timingmodule.c	2000/07/21 06:00:07	2.7
--- timingmodule.c	2000/09/01 09:01:32	2.8
***************
*** 73,77 ****
  {
  	(void)Py_InitModule("timing", timing_methods);
- 	if (PyErr_Occurred())
- 		Py_FatalError("can't initialize module timing");
  }
--- 73,75 ----