[Python-checkins] CVS: python/dist/src/Python bltinmodule.c,2.212,2.213

Guido van Rossum gvanrossum@users.sourceforge.net
Tue, 26 Jun 2001 16:12:27 -0700


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

Modified Files:
	bltinmodule.c 
Log Message:
Cosmetic changes to MvL's change to unichr():

- the correct range for the error message is range(0x110000);

- put the 4-byte Unicode-size code inside the same else branch as the
  2-byte code, rather generating unreachable code in the 2-byte case.

- Don't hide the 'else' behine the '}'.

(I would prefer that in 4-byte mode, any value should be accepted, but
reasonable people can argue about that, so I'll put that off.)


Index: bltinmodule.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Python/bltinmodule.c,v
retrieving revision 2.212
retrieving revision 2.213
diff -C2 -r2.212 -r2.213
*** bltinmodule.c	2001/06/26 22:22:37	2.212
--- bltinmodule.c	2001/06/26 23:12:25	2.213
***************
*** 316,320 ****
  	if (x < 0 || x > 0x10ffff) {
  		PyErr_SetString(PyExc_ValueError,
! 				"unichr() arg not in range(0x10ffff)");
  		return NULL;
  	}
--- 316,320 ----
  	if (x < 0 || x > 0x10ffff) {
  		PyErr_SetString(PyExc_ValueError,
! 				"unichr() arg not in range(0x110000)");
  		return NULL;
  	}
***************
*** 324,328 ****
  		s[0] = (Py_UNICODE) x;
  		return PyUnicode_FromUnicode(s, 1);
! 	} else {
  #if Py_UNICODE_SIZE == 2
  		/* UCS-4 character.  store as two surrogate characters */
--- 324,329 ----
  		s[0] = (Py_UNICODE) x;
  		return PyUnicode_FromUnicode(s, 1);
! 	}
! 	else {
  #if Py_UNICODE_SIZE == 2
  		/* UCS-4 character.  store as two surrogate characters */
***************
*** 331,338 ****
  		s[1] = 0xDC00 + (Py_UNICODE) (x & 0x03FF);
  		return PyUnicode_FromUnicode(s, 2);
  #endif
  	}
- 	s[0] = (Py_UNICODE)x;
- 	return PyUnicode_FromUnicode(s, 1);
  }
  
--- 332,340 ----
  		s[1] = 0xDC00 + (Py_UNICODE) (x & 0x03FF);
  		return PyUnicode_FromUnicode(s, 2);
+ #else
+ 		s[0] = (Py_UNICODE)x;
+ 		return PyUnicode_FromUnicode(s, 1);
  #endif
  	}
  }