[Python-checkins] CVS: python/dist/src/Objects unicodeobject.c,2.27,2.28

M.-A. Lemburg python-dev@python.org
2000年6月18日 15:25:24 -0700


Update of /cvsroot/python/python/dist/src/Objects
In directory slayer.i.sourceforge.net:/tmp/cvs-serv19475/Objects
Modified Files:
	unicodeobject.c 
Log Message:
Marc-Andre Lemburg <mal@lemburg.com>:
Fixed a bug in PyUnicode_Count() which would have caused a
core dump in case of substring coercion failure.
Synchronized .count() with the string method of the same name
to return len(s)+1 for s.count('').
Index: unicodeobject.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Objects/unicodeobject.c,v
retrieving revision 2.27
retrieving revision 2.28
diff -C2 -r2.27 -r2.28
*** unicodeobject.c	2000年06月17日 20:31:17	2.27
--- unicodeobject.c	2000年06月18日 22:25:22	2.28
***************
*** 2107,2110 ****
--- 2107,2113 ----
 int count = 0;
 
+ if (substring->length == 0)
+ 	return (end - start + 1);
+ 
 end -= substring->length;
 
***************
*** 2131,2135 ****
 substr = PyUnicode_FromObject(substr);
 if (substr == NULL) {
! 	Py_DECREF(substr);
 	return -1;
 }
--- 2134,2138 ----
 substr = PyUnicode_FromObject(substr);
 if (substr == NULL) {
! 	Py_DECREF(str);
 	return -1;
 }
***************
*** 3087,3095 ****
 	return NULL;
 
- if (substring->length == 0) {
- 	Py_DECREF(substring);
- return PyInt_FromLong((long) 0);
- }
- 
 if (start < 0)
 start += self->length;
--- 3090,3093 ----

AltStyle によって変換されたページ (->オリジナル) /