diff Python/getargs.c @ 19343:7257e87e0720 legacy-trunk

Patch #445762: Support --disable-unicode - Do not compile unicodeobject, unicodectype, and unicodedata if Unicode is disabled - check for Py_USING_UNICODE in all places that use Unicode functions - disables unicode literals, and the builtin functions - add the types.StringTypes list - remove Unicode literals from most tests.
author Martin v. Löwis <martin@v.loewis.de>
date Fri, 17 Aug 2001 18:39:25 +0000
parents 9b291ca6546c
children 3e7897822459
line wrap: on
line diff
--- a/Python/getargs.c	Fri Aug 17 17:36:00 2001 +0000
+++ b/Python/getargs.c	Fri Aug 17 18:39:25 2001 +0000
@@ -566,6 +566,7 @@
 				*p = PyString_AS_STRING(arg);
 				*q = PyString_GET_SIZE(arg);
 			}
+#ifdef Py_USING_UNICODE
 			else if (PyUnicode_Check(arg)) {
 				arg = UNICODE_DEFAULT_ENCODING(arg);
 				if (arg == NULL)
@@ -574,6 +575,7 @@
 				*p = PyString_AS_STRING(arg);
 				*q = PyString_GET_SIZE(arg);
 			}
+#endif
 			else { /* any buffer-like object */
 				char *buf;
 				int count = convertbuffer(arg, p, &buf);
@@ -587,6 +589,7 @@
 			
 			if (PyString_Check(arg))
 				*p = PyString_AS_STRING(arg);
+#ifdef Py_USING_UNICODE
 			else if (PyUnicode_Check(arg)) {
 				arg = UNICODE_DEFAULT_ENCODING(arg);
 				if (arg == NULL)
@@ -594,6 +597,7 @@
 							  arg, msgbuf);
 				*p = PyString_AS_STRING(arg);
 			}
+#endif
 			else
 				return converterr("string", arg, msgbuf);
 			if ((int)strlen(*p) != PyString_Size(arg))
@@ -616,6 +620,7 @@
 				*p = PyString_AS_STRING(arg);
 				*q = PyString_GET_SIZE(arg);
 			}
+#ifdef Py_USING_UNICODE
 			else if (PyUnicode_Check(arg)) {
 				arg = UNICODE_DEFAULT_ENCODING(arg);
 				if (arg == NULL)
@@ -624,6 +629,7 @@
 				*p = PyString_AS_STRING(arg);
 				*q = PyString_GET_SIZE(arg);
 			}
+#endif
 			else { /* any buffer-like object */
 				char *buf;
 				int count = convertbuffer(arg, p, &buf);
@@ -640,6 +646,7 @@
 				*p = 0;
 			else if (PyString_Check(arg))
 				*p = PyString_AsString(arg);
+#ifdef Py_USING_UNICODE
 			else if (PyUnicode_Check(arg)) {
 				arg = UNICODE_DEFAULT_ENCODING(arg);
 				if (arg == NULL)
@@ -647,6 +654,7 @@
 							  arg, msgbuf);
 				*p = PyString_AS_STRING(arg);
 			}
+#endif
 			else
 				return converterr("string or None", 
 						  arg, msgbuf);
@@ -670,13 +678,15 @@
 	case 'e': {/* encoded string */
 		char **buffer;
 		const char *encoding;
-		PyObject *u, *s;
+		PyObject *s;
 		int size, recode_strings;
 
 		/* Get 'e' parameter: the encoding name */
 		encoding = (const char *)va_arg(*p_va, const char *);
+#ifdef Py_USING_UNICODE
 		if (encoding == NULL)
 			encoding = PyUnicode_GetDefaultEncoding();
+#endif
 			
 		/* Get output buffer parameter:
 		   's' (recode all objects via Unicode) or
@@ -702,6 +712,9 @@
 			Py_INCREF(s);
 		}
 		else {
+#ifdef Py_USING_UNICODE
+		    	PyObject *u;
+
 			/* Convert object to Unicode */
 			u = PyUnicode_FromObject(arg);
 			if (u == NULL)
@@ -723,6 +736,9 @@
 					"(encoder failed to return a string)",
 					arg, msgbuf);
 			}
+#else
+			return converterr("string<e>", arg, msgbuf);
+#endif
 		}
 		size = PyString_GET_SIZE(s);
 
@@ -808,6 +824,7 @@
 		break;
 	}
 
+#ifdef Py_USING_UNICODE
 	case 'u': {/* raw unicode buffer (Py_UNICODE *) */
 		if (*format == '#') { /* any buffer-like object */
 			void **p = (void **)va_arg(*p_va, char **);
@@ -829,6 +846,7 @@
 		}
 		break;
 	}
+#endif
 
 	case 'S': { /* string object */
 		PyObject **p = va_arg(*p_va, PyObject **);
@@ -839,6 +857,7 @@
 		break;
 	}
 	
+#ifdef Py_USING_UNICODE
 	case 'U': { /* Unicode object */
 		PyObject **p = va_arg(*p_va, PyObject **);
 		if (PyUnicode_Check(arg))
@@ -847,6 +866,7 @@
 			return converterr("unicode", arg, msgbuf);
 		break;
 	}
+#endif
 	
 	case 'O': { /* object */
 		PyTypeObject *type;