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

M.-A. Lemburg python-dev@python.org
Wed, 03 Jan 2001 13:29:16 -0800


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

Modified Files:
	unicodeobject.c 
Log Message:
This patch changes the default behaviour of the builtin charmap
codec to not apply Latin-1 mappings for keys which are not found
in the mapping dictionaries, but instead treat them as undefined
mappings.

The patch was originally written by Martin v. Loewis with some
additional (cosmetic) changes and an updated test script
by Marc-Andre Lemburg.

The standard codecs were recreated from the most current files
available at the Unicode.org site using the Tools/scripts/gencodec.py
tool.

This patch closes the bugs #116285 and #119960.



Index: unicodeobject.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Objects/unicodeobject.c,v
retrieving revision 2.70
retrieving revision 2.71
diff -C2 -r2.70 -r2.71
*** unicodeobject.c	2000/12/19 22:49:06	2.70
--- unicodeobject.c	2001/01/03 21:29:14	2.71
***************
*** 1971,1979 ****
  	if (x == NULL) {
  	    if (PyErr_ExceptionMatches(PyExc_LookupError)) {
! 		/* No mapping found: default to Latin-1 mapping */
  		PyErr_Clear();
! 		*p++ = (Py_UNICODE)ch;
! 		continue;
! 	    }
  	    goto onError;
  	}
--- 1971,1979 ----
  	if (x == NULL) {
  	    if (PyErr_ExceptionMatches(PyExc_LookupError)) {
! 		/* No mapping found means: mapping is undefined. */
  		PyErr_Clear();
! 		x = Py_None;
! 		Py_INCREF(x);
! 	    } else
  	    goto onError;
  	}
***************
*** 2087,2100 ****
  	if (x == NULL) {
  	    if (PyErr_ExceptionMatches(PyExc_LookupError)) {
! 		/* No mapping found: default to Latin-1 mapping if possible */
  		PyErr_Clear();
! 		if (ch < 256) {
! 		    *s++ = (char)ch;
! 		    continue;
! 		}
! 		else if (!charmap_encoding_error(&p, &s, errors,
! 				     "missing character mapping"))
! 		    continue;
! 	    }
  	    goto onError;
  	}
--- 2087,2095 ----
  	if (x == NULL) {
  	    if (PyErr_ExceptionMatches(PyExc_LookupError)) {
! 		/* No mapping found means: mapping is undefined. */
  		PyErr_Clear();
! 		x = Py_None;
! 		Py_INCREF(x);
! 	    } else
  	    goto onError;
  	}