diff options
author | Guido van Rossum <guido@python.org> | 2007-05-03 17:49:24 (GMT) |
---|---|---|
committer | Guido van Rossum <guido@python.org> | 2007-05-03 17:49:24 (GMT) |
commit | 8d30cc0144a6a94e06f3a115b07afa6314466cfd (patch) | |
tree | 0c0b2f3d75cca4173ec3e8e2962682affbd2e886 /Objects | |
parent | 938ef57e267838dcfbfb0d51d9bd40caece1c5db (diff) | |
download | cpython-8d30cc0144a6a94e06f3a115b07afa6314466cfd.zip cpython-8d30cc0144a6a94e06f3a115b07afa6314466cfd.tar.gz cpython-8d30cc0144a6a94e06f3a115b07afa6314466cfd.tar.bz2 |
Get rid of all #ifdef Py_USING_UNICODE (it is always present now).
(With the help of unifdef from freshmeat.)
Diffstat (limited to 'Objects')
-rw-r--r-- | Objects/abstract.c | 2 | ||||
-rw-r--r-- | Objects/complexobject.c | 4 | ||||
-rw-r--r-- | Objects/exceptions.c | 6 | ||||
-rw-r--r-- | Objects/fileobject.c | 10 | ||||
-rw-r--r-- | Objects/floatobject.c | 4 | ||||
-rw-r--r-- | Objects/intobject.c | 4 | ||||
-rw-r--r-- | Objects/longobject.c | 4 | ||||
-rw-r--r-- | Objects/object.c | 18 | ||||
-rw-r--r-- | Objects/stringobject.c | 87 | ||||
-rw-r--r-- | Objects/typeobject.c | 4 |
10 files changed, 5 insertions, 138 deletions
diff --git a/Objects/abstract.c b/Objects/abstract.c index 5a34b96..645fd95 100644 --- a/Objects/abstract.c +++ b/Objects/abstract.c @@ -931,13 +931,11 @@ PyNumber_Long(PyObject *o) */ 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(). */ return PyLong_FromUnicode(PyUnicode_AS_UNICODE(o), PyUnicode_GET_SIZE(o), 10); -#endif if (!PyObject_AsCharBuffer(o, &buffer, &buffer_len)) return long_from_string(buffer, buffer_len); diff --git a/Objects/complexobject.c b/Objects/complexobject.c index 82dd7c1..b65a982 100644 --- a/Objects/complexobject.c +++ b/Objects/complexobject.c @@ -696,16 +696,13 @@ complex_subtype_from_string(PyTypeObject *type, PyObject *v) int sw_error=0; int sign; char buffer[256]; /* For errors */ -#ifdef Py_USING_UNICODE char s_buffer[256]; -#endif Py_ssize_t len; if (PyString_Check(v)) { s = PyString_AS_STRING(v); len = PyString_GET_SIZE(v); } -#ifdef Py_USING_UNICODE else if (PyUnicode_Check(v)) { if (PyUnicode_GET_SIZE(v) >= (Py_ssize_t)sizeof(s_buffer)) { PyErr_SetString(PyExc_ValueError, @@ -720,7 +717,6 @@ complex_subtype_from_string(PyTypeObject *type, PyObject *v) s = s_buffer; len = strlen(s); } -#endif else if (PyObject_AsCharBuffer(v, &s, &len)) { PyErr_SetString(PyExc_TypeError, "complex() arg is not a string"); diff --git a/Objects/exceptions.c b/Objects/exceptions.c index 2b05cc5..e30e9df 100644 --- a/Objects/exceptions.c +++ b/Objects/exceptions.c @@ -1183,7 +1183,6 @@ SimpleExtendsException(PyExc_StandardError, ValueError, SimpleExtendsException(PyExc_ValueError, UnicodeError, "Unicode related error."); -#ifdef Py_USING_UNICODE static int get_int(PyObject *attr, Py_ssize_t *value, const char *name) { @@ -1788,7 +1787,6 @@ PyUnicodeTranslateError_Create( return PyObject_CallFunction(PyExc_UnicodeTranslateError, "u#nns", object, length, start, end, reason); } -#endif /* @@ -1989,11 +1987,9 @@ _PyExc_Init(void) PRE_INIT(KeyError) PRE_INIT(ValueError) PRE_INIT(UnicodeError) -#ifdef Py_USING_UNICODE PRE_INIT(UnicodeEncodeError) PRE_INIT(UnicodeDecodeError) PRE_INIT(UnicodeTranslateError) -#endif PRE_INIT(AssertionError) PRE_INIT(ArithmeticError) PRE_INIT(FloatingPointError) @@ -2051,11 +2047,9 @@ _PyExc_Init(void) POST_INIT(KeyError) POST_INIT(ValueError) POST_INIT(UnicodeError) -#ifdef Py_USING_UNICODE POST_INIT(UnicodeEncodeError) POST_INIT(UnicodeDecodeError) POST_INIT(UnicodeTranslateError) -#endif POST_INIT(AssertionError) POST_INIT(ArithmeticError) POST_INIT(FloatingPointError) diff --git a/Objects/fileobject.c b/Objects/fileobject.c index d12e132..50b3cd6 100644 --- a/Objects/fileobject.c +++ b/Objects/fileobject.c @@ -412,7 +412,6 @@ static PyObject * file_repr(PyFileObject *f) { if (PyUnicode_Check(f->f_name)) { -#ifdef Py_USING_UNICODE PyObject *ret = NULL; PyObject *name = PyUnicode_AsUnicodeEscapeString(f->f_name); const char *name_str = name ? PyString_AsString(name) : "?"; @@ -423,7 +422,6 @@ file_repr(PyFileObject *f) f); Py_XDECREF(name); return ret; -#endif } else { return PyString_FromFormat("<%s file '%s', mode '%s' at %p>", f->f_fp == NULL ? "closed" : "open", @@ -1337,7 +1335,6 @@ PyFile_GetLine(PyObject *f, int n) } } } -#ifdef Py_USING_UNICODE if (n < 0 && result != NULL && PyUnicode_Check(result)) { Py_UNICODE *s = PyUnicode_AS_UNICODE(result); Py_ssize_t len = PyUnicode_GET_SIZE(result); @@ -1358,7 +1355,6 @@ PyFile_GetLine(PyObject *f, int n) } } } -#endif return result; } @@ -2124,15 +2120,12 @@ PyFile_WriteObject(PyObject *v, PyObject *f, int flags) } else if (PyFile_Check(f)) { FILE *fp = PyFile_AsFile(f); -#ifdef Py_USING_UNICODE PyObject *enc = ((PyFileObject*)f)->f_encoding; int result; -#endif if (fp == NULL) { err_closed(); return -1; } -#ifdef Py_USING_UNICODE if ((flags & Py_PRINT_RAW) && PyUnicode_Check(v) && enc != Py_None) { char *cenc = PyString_AS_STRING(enc); @@ -2146,9 +2139,6 @@ PyFile_WriteObject(PyObject *v, PyObject *f, int flags) result = PyObject_Print(value, fp, flags); Py_DECREF(value); return result; -#else - return PyObject_Print(v, fp, flags); -#endif } writer = PyObject_GetAttrString(f, "write"); if (writer == NULL) diff --git a/Objects/floatobject.c b/Objects/floatobject.c index 9e6db54..fde2380 100644 --- a/Objects/floatobject.c +++ b/Objects/floatobject.c @@ -68,16 +68,13 @@ PyFloat_FromString(PyObject *v) const char *s, *last, *end; double x; char buffer[256]; /* for errors */ -#ifdef Py_USING_UNICODE char s_buffer[256]; /* for objects convertible to a char buffer */ -#endif Py_ssize_t len; if (PyString_Check(v)) { s = PyString_AS_STRING(v); len = PyString_GET_SIZE(v); } -#ifdef Py_USING_UNICODE else if (PyUnicode_Check(v)) { if (PyUnicode_GET_SIZE(v) >= (Py_ssize_t)sizeof(s_buffer)) { PyErr_SetString(PyExc_ValueError, @@ -92,7 +89,6 @@ PyFloat_FromString(PyObject *v) s = s_buffer; len = strlen(s); } -#endif else if (PyObject_AsCharBuffer(v, &s, &len)) { PyErr_SetString(PyExc_TypeError, "float() argument must be a string or a number"); diff --git a/Objects/intobject.c b/Objects/intobject.c index 932b616..0aae6ac 100644 --- a/Objects/intobject.c +++ b/Objects/intobject.c @@ -387,7 +387,6 @@ PyInt_FromString(char *s, char **pend, int base) return PyInt_FromLong(x); } -#ifdef Py_USING_UNICODE PyObject * PyInt_FromUnicode(Py_UNICODE *s, Py_ssize_t length, int base) { @@ -405,7 +404,6 @@ PyInt_FromUnicode(Py_UNICODE *s, Py_ssize_t length, int base) PyMem_FREE(buffer); return result; } -#endif /* Methods */ @@ -986,12 +984,10 @@ int_new(PyTypeObject *type, PyObject *args, PyObject *kwds) } return PyInt_FromString(string, 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"); return NULL; diff --git a/Objects/longobject.c b/Objects/longobject.c index 95abfdd..61e5bed 100644 --- a/Objects/longobject.c +++ b/Objects/longobject.c @@ -1939,7 +1939,6 @@ digit beyond the first. return NULL; } -#ifdef Py_USING_UNICODE PyObject * PyLong_FromUnicode(Py_UNICODE *u, Py_ssize_t length, int base) { @@ -1957,7 +1956,6 @@ PyLong_FromUnicode(Py_UNICODE *u, Py_ssize_t length, int base) PyMem_FREE(buffer); return result; } -#endif /* forward */ static PyLongObject *x_divrem @@ -3538,12 +3536,10 @@ long_new(PyTypeObject *type, PyObject *args, PyObject *kwds) } 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, "int() can't convert non-string with explicit base"); diff --git a/Objects/object.c b/Objects/object.c index 0bf0c60..ada1d1e 100644 --- a/Objects/object.c +++ b/Objects/object.c @@ -361,7 +361,6 @@ PyObject_Repr(PyObject *v) res = (*v->ob_type->tp_repr)(v); if (res == NULL) return NULL; -#ifdef Py_USING_UNICODE if (PyUnicode_Check(res)) { PyObject* str; str = PyUnicode_AsEncodedString(res, NULL, NULL); @@ -371,7 +370,6 @@ PyObject_Repr(PyObject *v) else return NULL; } -#endif if (!PyString_Check(res)) { PyErr_Format(PyExc_TypeError, "__repr__ returned non-string (type %.200s)", @@ -394,12 +392,10 @@ _PyObject_Str(PyObject *v) Py_INCREF(v); return v; } -#ifdef Py_USING_UNICODE if (PyUnicode_CheckExact(v)) { Py_INCREF(v); return v; } -#endif if (v->ob_type->tp_str == NULL) return PyObject_Repr(v); @@ -407,9 +403,7 @@ _PyObject_Str(PyObject *v) if (res == NULL) return NULL; type_ok = PyString_Check(res); -#ifdef Py_USING_UNICODE type_ok = type_ok || PyUnicode_Check(res); -#endif if (!type_ok) { PyErr_Format(PyExc_TypeError, "__str__ returned non-string (type %.200s)", @@ -426,7 +420,6 @@ PyObject_Str(PyObject *v) PyObject *res = _PyObject_Str(v); if (res == NULL) return NULL; -#ifdef Py_USING_UNICODE if (PyUnicode_Check(res)) { PyObject* str; str = PyUnicode_AsEncodedString(res, NULL, NULL); @@ -436,12 +429,10 @@ PyObject_Str(PyObject *v) else return NULL; } -#endif assert(PyString_Check(res)); return res; } -#ifdef Py_USING_UNICODE PyObject * PyObject_Unicode(PyObject *v) { @@ -502,7 +493,6 @@ PyObject_Unicode(PyObject *v) } return res; } -#endif /* The new comparison philosophy is: we completely separate three-way @@ -895,7 +885,6 @@ PyObject_GetAttr(PyObject *v, PyObject *name) PyTypeObject *tp = v->ob_type; if (!PyString_Check(name)) { -#ifdef Py_USING_UNICODE /* The Unicode to string conversion is done here because the existing tp_getattro slots expect a string object as name and we wouldn't want to break those. */ @@ -905,7 +894,6 @@ PyObject_GetAttr(PyObject *v, PyObject *name) return NULL; } else -#endif { PyErr_Format(PyExc_TypeError, "attribute name must be string, not '%.200s'", @@ -942,7 +930,6 @@ PyObject_SetAttr(PyObject *v, PyObject *name, PyObject *value) int err; if (!PyString_Check(name)){ -#ifdef Py_USING_UNICODE /* The Unicode to string conversion is done here because the existing tp_setattro slots expect a string object as name and we wouldn't want to break those. */ @@ -952,7 +939,6 @@ PyObject_SetAttr(PyObject *v, PyObject *name, PyObject *value) return -1; } else -#endif { PyErr_Format(PyExc_TypeError, "attribute name must be string, not '%.200s'", @@ -1039,7 +1025,6 @@ PyObject_GenericGetAttr(PyObject *obj, PyObject *name) PyObject **dictptr; if (!PyString_Check(name)){ -#ifdef Py_USING_UNICODE /* The Unicode to string conversion is done here because the existing tp_setattro slots expect a string object as name and we wouldn't want to break those. */ @@ -1049,7 +1034,6 @@ PyObject_GenericGetAttr(PyObject *obj, PyObject *name) return NULL; } else -#endif { PyErr_Format(PyExc_TypeError, "attribute name must be string, not '%.200s'", @@ -1157,7 +1141,6 @@ PyObject_GenericSetAttr(PyObject *obj, PyObject *name, PyObject *value) int res = -1; if (!PyString_Check(name)){ -#ifdef Py_USING_UNICODE /* The Unicode to string conversion is done here because the existing tp_setattro slots expect a string object as name and we wouldn't want to break those. */ @@ -1167,7 +1150,6 @@ PyObject_GenericSetAttr(PyObject *obj, PyObject *name, PyObject *value) return -1; } else -#endif { PyErr_Format(PyExc_TypeError, "attribute name must be string, not '%.200s'", diff --git a/Objects/stringobject.c b/Objects/stringobject.c index 68bf703..248070f 100644 --- a/Objects/stringobject.c +++ b/Objects/stringobject.c @@ -379,12 +379,7 @@ PyObject *PyString_AsDecodedObject(PyObject *str, } 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 */ @@ -408,7 +403,6 @@ PyObject *PyString_AsDecodedString(PyObject *str, if (v == NULL) goto onError; -#ifdef Py_USING_UNICODE /* Convert Unicode to a string using the default encoding */ if (PyUnicode_Check(v)) { PyObject *temp = v; @@ -417,7 +411,6 @@ PyObject *PyString_AsDecodedString(PyObject *str, if (v == NULL) goto onError; } -#endif if (!PyString_Check(v)) { PyErr_Format(PyExc_TypeError, "decoder did not return a string object (type=%.400s)", @@ -459,12 +452,7 @@ PyObject *PyString_AsEncodedObject(PyObject *str, } 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 */ @@ -488,7 +476,6 @@ PyObject *PyString_AsEncodedString(PyObject *str, if (v == NULL) goto onError; -#ifdef Py_USING_UNICODE /* Convert Unicode to a string using the default encoding */ if (PyUnicode_Check(v)) { PyObject *temp = v; @@ -497,7 +484,6 @@ PyObject *PyString_AsEncodedString(PyObject *str, if (v == NULL) goto onError; } -#endif if (!PyString_Check(v)) { PyErr_Format(PyExc_TypeError, "encoder did not return a string object (type=%.400s)", @@ -560,7 +546,6 @@ PyObject *PyString_DecodeEscape(const char *s, while (s < end) { if (*s != '\\') { non_esc: -#ifdef Py_USING_UNICODE if (recode_encoding && (*s & 0x80)) { PyObject *u, *w; char *r; @@ -589,9 +574,6 @@ PyObject *PyString_DecodeEscape(const char *s, } else { *p++ = *s++; } -#else - *p++ = *s++; -#endif continue; } s++; @@ -663,17 +645,6 @@ PyObject *PyString_DecodeEscape(const char *s, errors); goto failed; } -#ifndef Py_USING_UNICODE - case 'u': - case 'U': - case 'N': - if (unicode) { - PyErr_SetString(PyExc_ValueError, - "Unicode escapes not legal " - "when Unicode disabled"); - goto failed; - } -#endif default: *p++ = '\\'; s--; @@ -739,17 +710,15 @@ PyString_AsStringAndSize(register PyObject *obj, } if (!PyString_Check(obj)) { -#ifdef Py_USING_UNICODE if (PyUnicode_Check(obj)) { obj = _PyUnicode_AsDefaultEncodedString(obj, NULL); if (obj == NULL) return -1; } else -#endif { PyErr_Format(PyExc_TypeError, - "expected string or Unicode object, " + "expected str object, " "%.200s found", obj->ob_type->tp_name); return -1; } @@ -944,10 +913,8 @@ string_concat(register PyStringObject *a, register PyObject *bb) register Py_ssize_t size; register PyStringObject *op; if (!PyString_Check(bb)) { -#ifdef Py_USING_UNICODE if (PyUnicode_Check(bb)) return PyUnicode_Concat((PyObject *)a, bb); -#endif if (PyBytes_Check(bb)) return PyBytes_Concat((PyObject *)a, bb); PyErr_Format(PyExc_TypeError, @@ -1068,10 +1035,8 @@ static int string_contains(PyObject *str_obj, PyObject *sub_obj) { if (!PyString_CheckExact(sub_obj)) { -#ifdef Py_USING_UNICODE if (PyUnicode_Check(sub_obj)) return PyUnicode_Contains(str_obj, sub_obj); -#endif if (!PyString_Check(sub_obj)) { PyErr_Format(PyExc_TypeError, "'in <string>' requires string as left operand, " @@ -1477,10 +1442,8 @@ string_split(PyStringObject *self, PyObject *args) sub = PyString_AS_STRING(subobj); 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; @@ -1543,10 +1506,8 @@ string_partition(PyStringObject *self, PyObject *sep_obj) sep = PyString_AS_STRING(sep_obj); sep_len = PyString_GET_SIZE(sep_obj); } -#ifdef Py_USING_UNICODE else if (PyUnicode_Check(sep_obj)) return PyUnicode_Partition((PyObject *) self, sep_obj); -#endif else if (PyObject_AsCharBuffer(sep_obj, &sep, &sep_len)) return NULL; @@ -1574,10 +1535,8 @@ string_rpartition(PyStringObject *self, PyObject *sep_obj) sep = PyString_AS_STRING(sep_obj); sep_len = PyString_GET_SIZE(sep_obj); } -#ifdef Py_USING_UNICODE else if (PyUnicode_Check(sep_obj)) return PyUnicode_Partition((PyObject *) self, sep_obj); -#endif else if (PyObject_AsCharBuffer(sep_obj, &sep, &sep_len)) return NULL; @@ -1684,10 +1643,8 @@ string_rsplit(PyStringObject *self, PyObject *args) sub = PyString_AS_STRING(subobj); n = PyString_GET_SIZE(subobj); } -#ifdef Py_USING_UNICODE else if (PyUnicode_Check(subobj)) return PyUnicode_RSplit((PyObject *)self, subobj, maxsplit); -#endif else if (PyObject_AsCharBuffer(subobj, &sub, &n)) return NULL; @@ -1774,7 +1731,6 @@ string_join(PyStringObject *self, PyObject *orig) const size_t old_sz = sz; item = PySequence_Fast_GET_ITEM(seq, i); if (!PyString_Check(item)){ -#ifdef Py_USING_UNICODE if (PyUnicode_Check(item)) { /* Defer to Unicode join. * CAUTION: There's no gurantee that the @@ -1786,7 +1742,6 @@ string_join(PyStringObject *self, PyObject *orig) Py_DECREF(seq); return result; } -#endif PyErr_Format(PyExc_TypeError, "sequence item %zd: expected string," " %.80s found", @@ -1868,11 +1823,9 @@ string_find_internal(PyStringObject *self, PyObject *args, int dir) sub = PyString_AS_STRING(subobj); sub_len = PyString_GET_SIZE(subobj); } -#ifdef Py_USING_UNICODE else if (PyUnicode_Check(subobj)) return PyUnicode_Find( (PyObject *)self, subobj, start, end, dir); -#endif else if (PyObject_AsCharBuffer(subobj, &sub, &sub_len)) /* XXX - the "expected a character buffer object" is pretty confusing for a non-expert. remap to something else ? */ @@ -2041,7 +1994,6 @@ do_argstrip(PyStringObject *self, int striptype, PyObject *args) if (sep != NULL && sep != Py_None) { if (PyString_Check(sep)) return do_xstrip(self, striptype, sep); -#ifdef Py_USING_UNICODE else if (PyUnicode_Check(sep)) { PyObject *uniself = PyUnicode_FromObject((PyObject *)self); PyObject *res; @@ -2052,13 +2004,8 @@ do_argstrip(PyStringObject *self, int striptype, PyObject *args) Py_DECREF(uniself); return res; } -#endif PyErr_Format(PyExc_TypeError, -#ifdef Py_USING_UNICODE - "%s arg must be None, str or unicode", -#else "%s arg must be None or str", -#endif STRIPNAME(striptype)); return NULL; } @@ -2068,7 +2015,7 @@ do_argstrip(PyStringObject *self, int striptype, PyObject *args) PyDoc_STRVAR(strip__doc__, -"S.strip([chars]) -> string or unicode\n\ +"S.strip([chars]) -> str\n\ \n\ Return a copy of the string S with leading and trailing\n\ whitespace removed.\n\ @@ -2086,7 +2033,7 @@ string_strip(PyStringObject *self, PyObject *args) PyDoc_STRVAR(lstrip__doc__, -"S.lstrip([chars]) -> string or unicode\n\ +"S.lstrip([chars]) -> str\n\ \n\ Return a copy of the string S with leading whitespace removed.\n\ If chars is given and not None, remove characters in chars instead.\n\ @@ -2103,7 +2050,7 @@ string_lstrip(PyStringObject *self, PyObject *args) PyDoc_STRVAR(rstrip__doc__, -"S.rstrip([chars]) -> string or unicode\n\ +"S.rstrip([chars]) -> str\n\ \n\ Return a copy of the string S with trailing whitespace removed.\n\ If chars is given and not None, remove characters in chars instead.\n\ @@ -2281,7 +2228,6 @@ string_count(PyStringObject *self, PyObject *args) sub = PyString_AS_STRING(sub_obj); sub_len = PyString_GET_SIZE(sub_obj); } -#ifdef Py_USING_UNICODE else if (PyUnicode_Check(sub_obj)) { Py_ssize_t count; count = PyUnicode_Count((PyObject *)self, sub_obj, start, end); @@ -2290,7 +2236,6 @@ string_count(PyStringObject *self, PyObject *args) else return PyInt_FromSsize_t(count); } -#endif else if (PyObject_AsCharBuffer(sub_obj, &sub, &sub_len)) return NULL; @@ -2367,7 +2312,6 @@ string_translate(PyStringObject *self, PyObject *args) table = NULL; tablen = 256; } -#ifdef Py_USING_UNICODE else if (PyUnicode_Check(tableobj)) { /* Unicode .translate() does not support the deletechars parameter; instead a mapping to None will cause characters @@ -2379,7 +2323,6 @@ string_translate(PyStringObject *self, PyObject *args) } return PyUnicode_Translate((PyObject *)self, tableobj, NULL); } -#endif else if (PyObject_AsCharBuffer(tableobj, &table, &tablen)) return NULL; @@ -2394,13 +2337,11 @@ string_translate(PyStringObject *self, PyObject *args) del_table = PyString_AS_STRING(delobj); dellen = PyString_GET_SIZE(delobj); } -#ifdef Py_USING_UNICODE else if (PyUnicode_Check(delobj)) { PyErr_SetString(PyExc_TypeError, "deletions are implemented differently for unicode"); return NULL; } -#endif else if (PyObject_AsCharBuffer(delobj, &del_table, &dellen)) return NULL; } @@ -3069,11 +3010,9 @@ string_replace(PyStringObject *self, PyObject *args) from_s = PyString_AS_STRING(from); from_len = PyString_GET_SIZE(from); } -#ifdef Py_USING_UNICODE if (PyUnicode_Check(from)) return PyUnicode_Replace((PyObject *)self, from, to, count); -#endif else if (PyObject_AsCharBuffer(from, &from_s, &from_len)) return NULL; @@ -3081,11 +3020,9 @@ string_replace(PyStringObject *self, PyObject *args) to_s = PyString_AS_STRING(to); to_len = PyString_GET_SIZE(to); } -#ifdef Py_USING_UNICODE else if (PyUnicode_Check(to)) return PyUnicode_Replace((PyObject *)self, from, to, count); -#endif else if (PyObject_AsCharBuffer(to, &to_s, &to_len)) return NULL; @@ -3113,11 +3050,9 @@ _string_tailmatch(PyStringObject *self, PyObject *substr, Py_ssize_t start, sub = PyString_AS_STRING(substr); slen = PyString_GET_SIZE(substr); } -#ifdef Py_USING_UNICODE else if (PyUnicode_Check(substr)) return PyUnicode_Tailmatch((PyObject *)self, substr, start, end, direction); -#endif else if (PyObject_AsCharBuffer(substr, &sub, &slen)) return -1; str = PyString_AS_STRING(self); @@ -4009,7 +3944,7 @@ static PyObject *str_iter(PyObject *seq); PyTypeObject PyString_Type = { PyObject_HEAD_INIT(&PyType_Type) 0, - "str8", + "str", sizeof(PyStringObject), sizeof(char), string_dealloc, /* tp_dealloc */ @@ -4458,9 +4393,7 @@ PyString_Format(PyObject *format, PyObject *args) Py_ssize_t reslen, rescnt, fmtcnt; 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) { PyErr_BadInternalCall(); @@ -4512,10 +4445,8 @@ PyString_Format(PyObject *format, PyObject *args) Py_ssize_t len; char formatbuf[FORMATBUFLEN]; /* For format{float,int,char}() */ -#ifdef Py_USING_UNICODE char *fmt_start = fmt; Py_ssize_t argidx_start = argidx; -#endif fmt++; if (*fmt == '(') { @@ -4669,22 +4600,18 @@ PyString_Format(PyObject *format, PyObject *args) len = 1; break; case 's': -#ifdef Py_USING_UNICODE if (PyUnicode_Check(v)) { fmt = fmt_start; argidx = argidx_start; goto unicode; } -#endif temp = _PyObject_Str(v); -#ifdef Py_USING_UNICODE if (temp != NULL && PyUnicode_Check(temp)) { Py_DECREF(temp); fmt = fmt_start; argidx = argidx_start; goto unicode; } -#endif /* Fall through */ case 'r': if (c == 'r') @@ -4749,13 +4676,11 @@ PyString_Format(PyObject *format, PyObject *args) fill = '0'; break; case 'c': -#ifdef Py_USING_UNICODE if (PyUnicode_Check(v)) { fmt = fmt_start; argidx = argidx_start; goto unicode; } -#endif pbuf = formatbuf; len = formatchar(pbuf, sizeof(formatbuf), v); if (len < 0) @@ -4864,7 +4789,6 @@ PyString_Format(PyObject *format, PyObject *args) _PyString_Resize(&result, reslen - rescnt); return result; -#ifdef Py_USING_UNICODE unicode: if (args_owned) { Py_DECREF(args); @@ -4909,7 +4833,6 @@ PyString_Format(PyObject *format, PyObject *args) Py_DECREF(v); Py_DECREF(args); return w; -#endif /* Py_USING_UNICODE */ error: Py_DECREF(result); diff --git a/Objects/typeobject.c b/Objects/typeobject.c index bf77bea..f743196 100644 --- a/Objects/typeobject.c +++ b/Objects/typeobject.c @@ -1505,7 +1505,6 @@ valid_identifier(PyObject *s) return 1; } -#ifdef Py_USING_UNICODE /* Replace Unicode objects in slots. */ static PyObject * @@ -1539,7 +1538,6 @@ _unicode_to_string(PyObject *slots, Py_ssize_t nslots) } return slots; } -#endif /* Forward */ static int @@ -1713,7 +1711,6 @@ type_new(PyTypeObject *metatype, PyObject *args, PyObject *kwds) return NULL; } -#ifdef Py_USING_UNICODE tmp = _unicode_to_string(slots, nslots); if (tmp == NULL) goto bad_slots; @@ -1721,7 +1718,6 @@ type_new(PyTypeObject *metatype, PyObject *args, PyObject *kwds) Py_DECREF(slots); slots = tmp; } -#endif /* Check for valid slot names and two special cases */ for (i = 0; i < nslots; i++) { PyObject *tmp = PyTuple_GET_ITEM(slots, i); |