[Python-checkins] python/dist/src/Python compile.c,2.243,2.244

gvanrossum@users.sourceforge.net gvanrossum@users.sourceforge.net
Tue, 28 May 2002 11:47:31 -0700


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

Modified Files:
	compile.c 
Log Message:
Accept u"..." literals even when Unicode is disabled.  But these
literals must not contain \u, \U or \N escapes.  (XXX Should they also
not contain non-ASCII characters?)


Index: compile.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Python/compile.c,v
retrieving revision 2.243
retrieving revision 2.244
diff -C2 -d -r2.243 -r2.244
*** compile.c	24 May 2002 15:47:06 -0000	2.243
--- compile.c	28 May 2002 18:47:29 -0000	2.244
***************
*** 1131,1147 ****
  	int quote = first;
  	int rawmode = 0;
- #ifdef Py_USING_UNICODE
  	int unicode = 0;
! #endif
  	if (isalpha(quote) || quote == '_') {
  		if (quote == 'u' || quote == 'U') {
- #ifdef Py_USING_UNICODE
  			quote = *++s;
  			unicode = 1;
- #else
- 			com_error(com, PyExc_SyntaxError,
- 				  "Unicode literals not supported in this Python");
- 			return NULL;
- #endif
  		}
  		if (quote == 'r' || quote == 'R') {
--- 1131,1140 ----
  	int quote = first;
  	int rawmode = 0;
  	int unicode = 0;
! 
  	if (isalpha(quote) || quote == '_') {
  		if (quote == 'u' || quote == 'U') {
  			quote = *++s;
  			unicode = 1;
  		}
  		if (quote == 'r' || quote == 'R') {
***************
*** 1251,1254 ****
--- 1244,1259 ----
  				  "invalid \\x escape");
  			return NULL;
+ #ifndef Py_USING_UNICODE
+ 		case 'u':
+ 		case 'U':
+ 		case 'N':
+ 			if (unicode) {
+ 				Py_DECREF(v);
+ 				com_error(com, PyExc_ValueError,
+ 					  "Unicode escapes not legal "
+ 					  "when Unicode disabled");
+ 				return NULL;
+ 			}
+ #endif
  		default:
  			*p++ = '\\';