[Python-checkins] CVS: python/dist/src/Modules _tkinter.c,1.98,1.99

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


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

Modified Files:
	_tkinter.c 
Log Message:
When the UTF-8 conversion to Unicode fails, return an 8-bit string
instead.  This seems more robust than returning an Unicode string with
some unconverted charcters in it.

This still doesn't support getting truly binary data out of Tcl, since
we look for the trailing null byte; but the old (pre-Unicode) code did
this too, so apparently there's no need.  (Plus, I really don't feel
like finding out how Tcl deals with this in each version.)


Index: _tkinter.c
===================================================================
RCS file: /projects/cvsroot/python/dist/src/Modules/_tkinter.c,v
retrieving revision 1.98
retrieving revision 1.99
diff -C2 -r1.98 -r1.99
*** _tkinter.c	2000/05/04 15:07:16	1.98
--- _tkinter.c	2000/05/04 15:55:17	1.99
***************
*** 655,659 ****
  			/* Convert UTF-8 to Unicode string */
  			p = strchr(p, '\0');
! 			res = PyUnicode_DecodeUTF8(s, (int)(p-s), "ignore");
  		}
  	}
--- 655,663 ----
  			/* Convert UTF-8 to Unicode string */
  			p = strchr(p, '\0');
! 			res = PyUnicode_DecodeUTF8(s, (int)(p-s), "strict");
! 			if (res == NULL) {
! 				PyErr_Clear();
! 				res = PyString_FromStringAndSize(s, (int)(p-s));
! 			}
  		}
  	}