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

Guido van Rossum python-dev@python.org
Wed, 3 May 2000 07:03:27 -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:

Fixes the MBCS codec to work correctly with zero length strings.


Index: unicodeobject.c
===================================================================
RCS file: /projects/cvsroot/python/dist/src/Objects/unicodeobject.c,v
retrieving revision 2.13
retrieving revision 2.14
diff -C2 -r2.13 -r2.14
*** unicodeobject.c	2000/05/01 21:27:20	2.13
--- unicodeobject.c	2000/05/03 11:03:24	2.14
***************
*** 1556,1560 ****
      /* 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);
  
--- 1556,1560 ----
      /* 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);
  
***************
*** 1579,1585 ****
      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);
--- 1579,1590 ----
      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);