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

Guido van Rossum python-dev@python.org
Thu, 4 May 2000 11:52:23 -0400 (EDT)


Update of /projects/cvsroot/python/dist/src/Objects
In directory eric:/projects/python/develop/guido/src/Objects

Modified Files:
	unicodeobject.c 
Log Message:
Mark Hammond should get his act into gear (his words :-).  Zero length
strings _are_ valid!


Index: unicodeobject.c
===================================================================
RCS file: /projects/cvsroot/python/dist/src/Objects/unicodeobject.c,v
retrieving revision 2.17
retrieving revision 2.18
diff -C2 -r2.17 -r2.18
*** unicodeobject.c	2000/05/03 23:58:29	2.17
--- unicodeobject.c	2000/05/04 15:52:20	2.18
***************
*** 1555,1559 ****
      /* First get the size of the result */
      DWORD usize = MultiByteToWideChar(CP_ACP, 0, s, size, NULL, 0);
!     if (usize==0)
          return PyErr_SetFromWindowsErrWithFilename(0, NULL);
  
--- 1555,1559 ----
      /* First get the size of the result */
      DWORD usize = MultiByteToWideChar(CP_ACP, 0, s, size, NULL, 0);
!     if (size > 0 && usize==0)
          return PyErr_SetFromWindowsErrWithFilename(0, NULL);
  
***************
*** 1578,1584 ****
      PyObject *repr;
      char *s;
  
      /* First get the size of the result */
!     DWORD mbcssize = WideCharToMultiByte(CP_ACP, 0, p, size, NULL, 0, NULL, NULL);
      if (mbcssize==0)
          return PyErr_SetFromWindowsErrWithFilename(0, NULL);
--- 1578,1589 ----
      PyObject *repr;
      char *s;
+     DWORD mbcssize;
  
+     /* If there are no characters, bail now! */
+     if (size==0)
+ 	    return PyString_FromString("");
+ 
      /* First get the size of the result */
!     mbcssize = WideCharToMultiByte(CP_ACP, 0, p, size, NULL, 0, NULL, NULL);
      if (mbcssize==0)
          return PyErr_SetFromWindowsErrWithFilename(0, NULL);