[Python-checkins] CVS: python/dist/src/Objects abstract.c,2.71,2.72 complexobject.c,2.38,2.39 floatobject.c,2.85,2.86 intobject.c,2.61,2.62 longobject.c,1.91,1.92 object.c,2.138,2.139 stringobject.c,2.123,2.124
Martin v. L?wis
loewis@users.sourceforge.net
Fri, 17 Aug 2001 11:39:27 -0700
- Previous message: [Python-checkins] CVS: python/dist/src/Modules _codecsmodule.c,2.8,2.9 _sre.c,2.62,2.63 _tkinter.c,1.118,1.119 cPickle.c,2.61,2.62 pyexpat.c,2.47,2.48
- Next message: [Python-checkins] CVS: python/dist/src/Python bltinmodule.c,2.226,2.227 compile.c,2.217,2.218 getargs.c,2.61,2.62 marshal.c,1.64,1.65 modsupport.c,2.57,2.58 pythonrun.c,2.146,2.147 sysmodule.c,2.91,2.92
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
Update of /cvsroot/python/python/dist/src/Objects
In directory usw-pr-cvs1:/tmp/cvs-serv28889/Objects
Modified Files:
abstract.c complexobject.c floatobject.c intobject.c
longobject.c object.c stringobject.c
Log Message:
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.
Index: abstract.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Objects/abstract.c,v
retrieving revision 2.71
retrieving revision 2.72
diff -C2 -d -r2.71 -r2.72
*** abstract.c 2001/08/08 05:00:18 2.71
--- abstract.c 2001/08/17 18:39:25 2.72
***************
*** 584,589 ****
--- 584,591 ----
if (PyString_Check(v))
return PyString_Format(v, w);
+ #ifdef Py_USING_UNICODE
else if (PyUnicode_Check(v))
return PyUnicode_Format(v, w);
+ #endif
return binary_op(v, w, NB_SLOT(nb_remainder), "%");
}
***************
*** 708,713 ****
--- 710,717 ----
if (PyString_Check(v))
return PyString_Format(v, w);
+ #ifdef Py_USING_UNICODE
else if (PyUnicode_Check(v))
return PyUnicode_Format(v, w);
+ #endif
else
return binary_iop(v, w, NB_SLOT(nb_inplace_remainder),
***************
*** 822,829 ****
--- 826,835 ----
return int_from_string(PyString_AS_STRING(o),
PyString_GET_SIZE(o));
+ #ifdef Py_USING_UNICODE
if (PyUnicode_Check(o))
return PyInt_FromUnicode(PyUnicode_AS_UNICODE(o),
PyUnicode_GET_SIZE(o),
10);
+ #endif
m = o->ob_type->tp_as_number;
if (m && m->nb_int)
***************
*** 874,877 ****
--- 880,884 ----
return long_from_string(PyString_AS_STRING(o),
PyString_GET_SIZE(o));
+ #ifdef Py_USING_UNICODE
if (PyUnicode_Check(o))
/* The above check is done in PyLong_FromUnicode(). */
***************
*** 879,882 ****
--- 886,890 ----
PyUnicode_GET_SIZE(o),
10);
+ #endif
m = o->ob_type->tp_as_number;
if (m && m->nb_long)
Index: complexobject.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Objects/complexobject.c,v
retrieving revision 2.38
retrieving revision 2.39
diff -C2 -d -r2.38 -r2.39
*** complexobject.c 2001/08/16 13:15:00 2.38
--- complexobject.c 2001/08/17 18:39:25 2.39
***************
*** 612,616 ****
int sign;
char buffer[256]; /* For errors */
- char s_buffer[256];
int len;
--- 612,615 ----
***************
*** 619,623 ****
--- 618,624 ----
len = PyString_GET_SIZE(v);
}
+ #ifdef Py_USING_UNICODE
else if (PyUnicode_Check(v)) {
+ char s_buffer[256];
if (PyUnicode_GET_SIZE(v) >= sizeof(s_buffer)) {
PyErr_SetString(PyExc_ValueError,
***************
*** 633,636 ****
--- 634,638 ----
len = (int)strlen(s);
}
+ #endif
else if (PyObject_AsCharBuffer(v, &s, &len)) {
PyErr_SetString(PyExc_TypeError,
Index: floatobject.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Objects/floatobject.c,v
retrieving revision 2.85
retrieving revision 2.86
diff -C2 -d -r2.85 -r2.86
*** floatobject.c 2001/08/08 05:00:18 2.85
--- floatobject.c 2001/08/17 18:39:25 2.86
***************
*** 110,114 ****
--- 110,116 ----
double x;
char buffer[256]; /* for errors */
+ #ifdef Py_USING_UNICODE
char s_buffer[256]; /* for objects convertible to a char buffer */
+ #endif
int len;
***************
*** 119,122 ****
--- 121,125 ----
len = PyString_GET_SIZE(v);
}
+ #ifdef Py_USING_UNICODE
else if (PyUnicode_Check(v)) {
if (PyUnicode_GET_SIZE(v) >= sizeof(s_buffer)) {
***************
*** 133,136 ****
--- 136,140 ----
len = (int)strlen(s);
}
+ #endif
else if (PyObject_AsCharBuffer(v, &s, &len)) {
PyErr_SetString(PyExc_TypeError,
Index: intobject.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Objects/intobject.c,v
retrieving revision 2.61
retrieving revision 2.62
diff -C2 -d -r2.61 -r2.62
*** intobject.c 2001/08/08 05:00:18 2.61
--- intobject.c 2001/08/17 18:39:25 2.62
***************
*** 203,206 ****
--- 203,207 ----
}
+ #ifdef Py_USING_UNICODE
PyObject *
PyInt_FromUnicode(Py_UNICODE *s, int length, int base)
***************
*** 217,220 ****
--- 218,222 ----
return PyInt_FromString(buffer, NULL, base);
}
+ #endif
/* Methods */
***************
*** 766,773 ****
--- 768,777 ----
if (PyString_Check(x))
return PyInt_FromString(PyString_AS_STRING(x), NULL, base);
+ #ifdef Py_USING_UNICODE
if (PyUnicode_Check(x))
return PyInt_FromUnicode(PyUnicode_AS_UNICODE(x),
PyUnicode_GET_SIZE(x),
base);
+ #endif
PyErr_SetString(PyExc_TypeError,
"int() can't convert non-string with explicit base");
Index: longobject.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Objects/longobject.c,v
retrieving revision 1.91
retrieving revision 1.92
diff -C2 -d -r1.91 -r1.92
*** longobject.c 2001/08/08 05:00:18 1.91
--- longobject.c 2001/08/17 18:39:25 1.92
***************
*** 972,975 ****
--- 972,976 ----
}
+ #ifdef Py_USING_UNICODE
PyObject *
PyLong_FromUnicode(Py_UNICODE *u, int length, int base)
***************
*** 987,990 ****
--- 988,992 ----
return PyLong_FromString(buffer, NULL, base);
}
+ #endif
/* forward */
***************
*** 2055,2062 ****
--- 2057,2066 ----
else if (PyString_Check(x))
return PyLong_FromString(PyString_AS_STRING(x), NULL, base);
+ #ifdef Py_USING_UNICODE
else if (PyUnicode_Check(x))
return PyLong_FromUnicode(PyUnicode_AS_UNICODE(x),
PyUnicode_GET_SIZE(x),
base);
+ #endif
else {
PyErr_SetString(PyExc_TypeError,
Index: object.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Objects/object.c,v
retrieving revision 2.138
retrieving revision 2.139
diff -C2 -d -r2.138 -r2.139
*** object.c 2001/08/16 08:17:26 2.138
--- object.c 2001/08/17 18:39:25 2.139
***************
*** 247,250 ****
--- 247,251 ----
if (res == NULL)
return NULL;
+ #ifdef Py_USING_UNICODE
if (PyUnicode_Check(res)) {
PyObject* str;
***************
*** 256,259 ****
--- 257,261 ----
return NULL;
}
+ #endif
if (!PyString_Check(res)) {
PyErr_Format(PyExc_TypeError,
***************
*** 284,287 ****
--- 286,290 ----
if (res == NULL)
return NULL;
+ #ifdef Py_USING_UNICODE
if (PyUnicode_Check(res)) {
PyObject* str;
***************
*** 293,296 ****
--- 296,300 ----
return NULL;
}
+ #endif
if (!PyString_Check(res)) {
PyErr_Format(PyExc_TypeError,
***************
*** 303,306 ****
--- 307,311 ----
}
+ #ifdef Py_USING_UNICODE
PyObject *
PyObject_Unicode(PyObject *v)
***************
*** 351,354 ****
--- 356,360 ----
return res;
}
+ #endif
***************
*** 524,527 ****
--- 530,534 ----
}
+ #ifdef Py_USING_UNICODE
/* Special case for Unicode */
if (PyUnicode_Check(v) || PyUnicode_Check(w)) {
***************
*** 538,541 ****
--- 545,549 ----
PyErr_Clear();
}
+ #endif
/* None is smaller than anything */
***************
*** 1033,1036 ****
--- 1041,1045 ----
PyTypeObject *tp = v->ob_type;
+ #ifdef Py_USING_UNICODE
/* The Unicode to string conversion is done here because the
existing tp_getattro slots expect a string object as name
***************
*** 1041,1044 ****
--- 1050,1055 ----
return NULL;
}
+ #endif
+
if (!PyString_Check(name)) {
PyErr_SetString(PyExc_TypeError,
***************
*** 1074,1077 ****
--- 1085,1089 ----
int err;
+ #ifdef Py_USING_UNICODE
/* The Unicode to string conversion is done here because the
existing tp_setattro slots expect a string object as name
***************
*** 1082,1086 ****
return -1;
}
! else if (!PyString_Check(name)){
PyErr_SetString(PyExc_TypeError,
"attribute name must be string");
--- 1094,1100 ----
return -1;
}
! else
! #endif
! if (!PyString_Check(name)){
PyErr_SetString(PyExc_TypeError,
"attribute name must be string");
Index: stringobject.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Objects/stringobject.c,v
retrieving revision 2.123
retrieving revision 2.124
diff -C2 -d -r2.123 -r2.124
*** stringobject.c 2001/08/16 13:15:00 2.123
--- stringobject.c 2001/08/17 18:39:25 2.124
***************
*** 174,179 ****
}
! if (encoding == NULL)
encoding = PyUnicode_GetDefaultEncoding();
/* Decode via the codec registry */
--- 174,185 ----
}
! if (encoding == NULL) {
! #ifdef Py_USING_UNICODE
encoding = PyUnicode_GetDefaultEncoding();
+ #else
+ PyErr_SetString(PyExc_ValueError, "no encoding specified");
+ goto onError;
+ #endif
+ }
/* Decode via the codec registry */
***************
*** 198,201 ****
--- 204,208 ----
goto onError;
+ #ifdef Py_USING_UNICODE
/* Convert Unicode to a string using the default encoding */
if (PyUnicode_Check(v)) {
***************
*** 206,209 ****
--- 213,217 ----
goto onError;
}
+ #endif
if (!PyString_Check(v)) {
PyErr_Format(PyExc_TypeError,
***************
*** 246,251 ****
}
! if (encoding == NULL)
encoding = PyUnicode_GetDefaultEncoding();
/* Encode via the codec registry */
--- 254,265 ----
}
! if (encoding == NULL) {
! #ifdef Py_USING_UNICODE
encoding = PyUnicode_GetDefaultEncoding();
+ #else
+ PyErr_SetString(PyExc_ValueError, "no encoding specified");
+ goto onError;
+ #endif
+ }
/* Encode via the codec registry */
***************
*** 270,273 ****
--- 284,288 ----
goto onError;
+ #ifdef Py_USING_UNICODE
/* Convert Unicode to a string using the default encoding */
if (PyUnicode_Check(v)) {
***************
*** 278,281 ****
--- 293,297 ----
goto onError;
}
+ #endif
if (!PyString_Check(v)) {
PyErr_Format(PyExc_TypeError,
***************
*** 345,348 ****
--- 361,365 ----
if (!PyString_Check(obj)) {
+ #ifdef Py_USING_UNICODE
if (PyUnicode_Check(obj)) {
obj = _PyUnicode_AsDefaultEncodedString(obj, NULL);
***************
*** 350,354 ****
return -1;
}
! else {
PyErr_Format(PyExc_TypeError,
"expected string or Unicode object, "
--- 367,373 ----
return -1;
}
! else
! #endif
! {
PyErr_Format(PyExc_TypeError,
"expected string or Unicode object, "
***************
*** 478,483 ****
--- 497,504 ----
register PyStringObject *op;
if (!PyString_Check(bb)) {
+ #ifdef Py_USING_UNICODE
if (PyUnicode_Check(bb))
return PyUnicode_Concat((PyObject *)a, bb);
+ #endif
PyErr_Format(PyExc_TypeError,
"cannot add type \"%.200s\" to string",
***************
*** 587,592 ****
--- 608,615 ----
register char *s, *end;
register char c;
+ #ifdef Py_USING_UNICODE
if (PyUnicode_Check(el))
return PyUnicode_Contains(a, el);
+ #endif
if (!PyString_Check(el) || PyString_Size(el) != 1) {
PyErr_SetString(PyExc_TypeError,
***************
*** 869,874 ****
--- 892,899 ----
n = PyString_GET_SIZE(subobj);
}
+ #ifdef Py_USING_UNICODE
else if (PyUnicode_Check(subobj))
return PyUnicode_Split((PyObject *)self, subobj, maxsplit);
+ #endif
else if (PyObject_AsCharBuffer(subobj, &sub, &n))
return NULL;
***************
*** 970,973 ****
--- 995,999 ----
item = PySequence_Fast_GET_ITEM(seq, i);
if (!PyString_Check(item)){
+ #ifdef Py_USING_UNICODE
if (PyUnicode_Check(item)) {
/* Defer to Unicode join.
***************
*** 981,984 ****
--- 1007,1011 ----
return result;
}
+ #endif
PyErr_Format(PyExc_TypeError,
"sequence item %i: expected string,"
***************
*** 1047,1052 ****
--- 1074,1081 ----
n = PyString_GET_SIZE(subobj);
}
+ #ifdef Py_USING_UNICODE
else if (PyUnicode_Check(subobj))
return PyUnicode_Find((PyObject *)self, subobj, i, last, 1);
+ #endif
else if (PyObject_AsCharBuffer(subobj, &sub, &n))
return -2;
***************
*** 1382,1385 ****
--- 1411,1415 ----
n = PyString_GET_SIZE(subobj);
}
+ #ifdef Py_USING_UNICODE
else if (PyUnicode_Check(subobj)) {
int count;
***************
*** 1390,1393 ****
--- 1420,1424 ----
return PyInt_FromLong((long) count);
}
+ #endif
else if (PyObject_AsCharBuffer(subobj, &sub, &n))
return NULL;
***************
*** 1482,1485 ****
--- 1513,1517 ----
tablen = PyString_GET_SIZE(tableobj);
}
+ #ifdef Py_USING_UNICODE
else if (PyUnicode_Check(tableobj)) {
/* Unicode .translate() does not support the deletechars
***************
*** 1493,1496 ****
--- 1525,1529 ----
return PyUnicode_Translate((PyObject *)self, tableobj, NULL);
}
+ #endif
else if (PyObject_AsCharBuffer(tableobj, &table1, &tablen))
return NULL;
***************
*** 1501,1504 ****
--- 1534,1538 ----
dellen = PyString_GET_SIZE(delobj);
}
+ #ifdef Py_USING_UNICODE
else if (PyUnicode_Check(delobj)) {
PyErr_SetString(PyExc_TypeError,
***************
*** 1506,1509 ****
--- 1540,1544 ----
return NULL;
}
+ #endif
else if (PyObject_AsCharBuffer(delobj, &del_table, &dellen))
return NULL;
***************
*** 1730,1736 ****
--- 1765,1773 ----
sub_len = PyString_GET_SIZE(subobj);
}
+ #ifdef Py_USING_UNICODE
else if (PyUnicode_Check(subobj))
return PyUnicode_Replace((PyObject *)self,
subobj, replobj, count);
+ #endif
else if (PyObject_AsCharBuffer(subobj, &sub, &sub_len))
return NULL;
***************
*** 1740,1746 ****
--- 1777,1785 ----
repl_len = PyString_GET_SIZE(replobj);
}
+ #ifdef Py_USING_UNICODE
else if (PyUnicode_Check(replobj))
return PyUnicode_Replace((PyObject *)self,
subobj, replobj, count);
+ #endif
else if (PyObject_AsCharBuffer(replobj, &repl, &repl_len))
return NULL;
***************
*** 1793,1796 ****
--- 1832,1836 ----
plen = PyString_GET_SIZE(subobj);
}
+ #ifdef Py_USING_UNICODE
else if (PyUnicode_Check(subobj)) {
int rc;
***************
*** 1802,1805 ****
--- 1842,1846 ----
return PyInt_FromLong((long) rc);
}
+ #endif
else if (PyObject_AsCharBuffer(subobj, &prefix, &plen))
return NULL;
***************
*** 1851,1854 ****
--- 1892,1896 ----
slen = PyString_GET_SIZE(subobj);
}
+ #ifdef Py_USING_UNICODE
else if (PyUnicode_Check(subobj)) {
int rc;
***************
*** 1860,1863 ****
--- 1902,1906 ----
return PyInt_FromLong((long) rc);
}
+ #endif
else if (PyObject_AsCharBuffer(subobj, &suffix, &slen))
return NULL;
***************
*** 2877,2881 ****
int fmtcnt, rescnt, reslen, arglen, argidx;
int args_owned = 0;
! PyObject *result, *orig_args, *v, *w;
PyObject *dict = NULL;
if (format == NULL || !PyString_Check(format) || args == NULL) {
--- 2920,2927 ----
int fmtcnt, rescnt, reslen, arglen, argidx;
int args_owned = 0;
! PyObject *result, *orig_args;
! #ifdef Py_USING_UNICODE
! PyObject *v, *w;
! #endif
PyObject *dict = NULL;
if (format == NULL || !PyString_Check(format) || args == NULL) {
***************
*** 2927,2932 ****
--- 2973,2980 ----
int len;
char formatbuf[FORMATBUFLEN]; /* For format{float,int,char}() */
+ #ifdef Py_USING_UNICODE
char *fmt_start = fmt;
int argidx_start = argidx;
+ #endif
fmt++;
***************
*** 3079,3082 ****
--- 3127,3131 ----
case 's':
case 'r':
+ #ifdef Py_USING_UNICODE
if (PyUnicode_Check(v)) {
fmt = fmt_start;
***************
*** 3084,3087 ****
--- 3133,3137 ----
goto unicode;
}
+ #endif
if (c == 's')
temp = PyObject_Str(v);
***************
*** 3241,3244 ****
--- 3291,3295 ----
return result;
+ #ifdef Py_USING_UNICODE
unicode:
if (args_owned) {
***************
*** 3285,3288 ****
--- 3336,3340 ----
Py_DECREF(args);
return w;
+ #endif /* Py_USING_UNICODE */
error:
- Previous message: [Python-checkins] CVS: python/dist/src/Modules _codecsmodule.c,2.8,2.9 _sre.c,2.62,2.63 _tkinter.c,1.118,1.119 cPickle.c,2.61,2.62 pyexpat.c,2.47,2.48
- Next message: [Python-checkins] CVS: python/dist/src/Python bltinmodule.c,2.226,2.227 compile.c,2.217,2.218 getargs.c,2.61,2.62 marshal.c,1.64,1.65 modsupport.c,2.57,2.58 pythonrun.c,2.146,2.147 sysmodule.c,2.91,2.92
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]