diff options
author | Victor Stinner <victor.stinner@haypocalc.com> | 2011-12-11 20:44:00 (GMT) |
---|---|---|
committer | Victor Stinner <victor.stinner@haypocalc.com> | 2011-12-11 20:44:00 (GMT) |
commit | 382955ff4e84276c4d52751154001f3cfa5b938d (patch) | |
tree | b8a2ab352207ccb878554fc34358e5bef480b35f /Objects | |
parent | 785938eebdcf39d6ee54005e38afc474fdb5e1ea (diff) | |
download | cpython-382955ff4e84276c4d52751154001f3cfa5b938d.zip cpython-382955ff4e84276c4d52751154001f3cfa5b938d.tar.gz cpython-382955ff4e84276c4d52751154001f3cfa5b938d.tar.bz2 |
Use directly unicode_empty instead of PyUnicode_New(0, 0)
Diffstat (limited to 'Objects')
-rw-r--r-- | Objects/unicodeobject.c | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/Objects/unicodeobject.c b/Objects/unicodeobject.c index cc4da2a..591c81b 100644 --- a/Objects/unicodeobject.c +++ b/Objects/unicodeobject.c @@ -2122,8 +2122,10 @@ PyObject * PyUnicode_FromWideChar(register const wchar_t *w, Py_ssize_t size) { if (w == NULL) { - if (size == 0) - return PyUnicode_New(0, 0); + if (size == 0) { + Py_INCREF(unicode_empty); + return unicode_empty; + } PyErr_BadInternalCall(); return NULL; } @@ -4557,7 +4559,8 @@ PyUnicode_DecodeUTF8Stateful(const char *s, if (size == 0) { if (consumed) *consumed = 0; - return (PyObject *)PyUnicode_New(0, 0); + Py_INCREF(unicode_empty); + return unicode_empty; } maxchar = utf8_max_char_size_and_char_count(s, size, &unicode_size); @@ -12906,7 +12909,8 @@ unicode_subscript(PyObject* self, PyObject* item) } if (slicelength <= 0) { - return PyUnicode_New(0, 0); + Py_INCREF(unicode_empty); + return unicode_empty; } else if (start == 0 && step == 1 && slicelength == PyUnicode_GET_LENGTH(self) && PyUnicode_CheckExact(self)) { @@ -13582,8 +13586,10 @@ unicode_new(PyTypeObject *type, PyObject *args, PyObject *kwds) if (!PyArg_ParseTupleAndKeywords(args, kwds, "|Oss:str", kwlist, &x, &encoding, &errors)) return NULL; - if (x == NULL) - return PyUnicode_New(0, 0); + if (x == NULL) { + Py_INCREF(unicode_empty); + return unicode_empty; + } if (encoding == NULL && errors == NULL) return PyObject_Str(x); else |