[Python-checkins] CVS: python/dist/src/Python exceptions.c,1.27,1.28

Jeremy Hylton jhylton@users.sourceforge.net
Wed, 28 Nov 2001 12:24:35 -0800


Update of /cvsroot/python/python/dist/src/Python
In directory usw-pr-cvs1:/tmp/cvs-serv4433

Modified Files:
	exceptions.c 
Log Message:
Use PyOS_snprintf instead of sprintf.

Just being sure.  The old code looks like it was safe, but there's no
harm in double-checking.


Index: exceptions.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Python/exceptions.c,v
retrieving revision 1.27
retrieving revision 1.28
diff -C2 -d -r1.27 -r1.28
*** exceptions.c	2001/10/05 21:50:08	1.27
--- exceptions.c	2001/11/28 20:24:33	1.28
***************
*** 811,829 ****
  		bufsize += PyString_GET_SIZE(filename);
  
! 	    buffer = PyMem_Malloc(bufsize);
  	    if (buffer != NULL) {
  		if (have_filename && have_lineno)
! 		    sprintf(buffer, "%s (%s, line %ld)",
! 			    PyString_AS_STRING(str),
! 			    my_basename(PyString_AS_STRING(filename)),
! 			    PyInt_AsLong(lineno));
  		else if (have_filename)
! 		    sprintf(buffer, "%s (%s)",
! 			    PyString_AS_STRING(str),
! 			    my_basename(PyString_AS_STRING(filename)));
  		else if (have_lineno)
! 		    sprintf(buffer, "%s (line %ld)",
! 			    PyString_AS_STRING(str),
! 			    PyInt_AsLong(lineno));
  
  		result = PyString_FromString(buffer);
--- 811,829 ----
  		bufsize += PyString_GET_SIZE(filename);
  
! 	    buffer = PyMem_MALLOC(bufsize);
  	    if (buffer != NULL) {
  		if (have_filename && have_lineno)
! 		    PyOS_snprintf(buffer, bufsize, "%s (%s, line %ld)",
! 				  PyString_AS_STRING(str),
! 				  my_basename(PyString_AS_STRING(filename)),
! 				  PyInt_AsLong(lineno));
  		else if (have_filename)
! 		    PyOS_snprintf(buffer, bufsize, "%s (%s)",
! 				  PyString_AS_STRING(str),
! 				  my_basename(PyString_AS_STRING(filename)));
  		else if (have_lineno)
! 		    PyOS_snprintf(buffer, bufsize, "%s (line %ld)",
! 				  PyString_AS_STRING(str),
! 				  PyInt_AsLong(lineno));
  
  		result = PyString_FromString(buffer);