diff options
Diffstat (limited to 'Objects/dictobject.c')
-rw-r--r-- | Objects/dictobject.c | 78 |
1 files changed, 39 insertions, 39 deletions
diff --git a/Objects/dictobject.c b/Objects/dictobject.c index 6b15131..9b14e63 100644 --- a/Objects/dictobject.c +++ b/Objects/dictobject.c @@ -224,7 +224,7 @@ PyDict_New(void) { register PyDictObject *mp; if (dummy == NULL) { /* Auto-initialize dummy */ - dummy = PyBytes_FromString("<dummy key>"); + dummy = PyString_FromString("<dummy key>"); if (dummy == NULL) return NULL; #ifdef SHOW_CONVERSION_COUNTS @@ -373,7 +373,7 @@ lookdict(PyDictObject *mp, PyObject *key, register long hash) * this assumption allows testing for errors during PyObject_RichCompareBool() * to be dropped; string-string comparisons never raise exceptions. This also * means we don't need to go through PyObject_RichCompareBool(); we can always - * use _PyBytes_Eq() directly. + * use _PyString_Eq() directly. * * This is valuable because dicts with only string keys are very common. */ @@ -391,7 +391,7 @@ lookdict_string(PyDictObject *mp, PyObject *key, register long hash) including subclasses of str; e.g., one reason to subclass strings is to override __eq__, and for speed we don't cater to that here. */ - if (!PyBytes_CheckExact(key)) { + if (!PyString_CheckExact(key)) { #ifdef SHOW_CONVERSION_COUNTS ++converted; #endif @@ -405,7 +405,7 @@ lookdict_string(PyDictObject *mp, PyObject *key, register long hash) if (ep->me_key == dummy) freeslot = ep; else { - if (ep->me_hash == hash && _PyBytes_Eq(ep->me_key, key)) + if (ep->me_hash == hash && _PyString_Eq(ep->me_key, key)) return ep; freeslot = NULL; } @@ -420,7 +420,7 @@ lookdict_string(PyDictObject *mp, PyObject *key, register long hash) if (ep->me_key == key || (ep->me_hash == hash && ep->me_key != dummy - && _PyBytes_Eq(ep->me_key, key))) + && _PyString_Eq(ep->me_key, key))) return ep; if (ep->me_key == dummy && freeslot == NULL) freeslot = ep; @@ -626,8 +626,8 @@ PyDict_GetItem(PyObject *op, PyObject *key) PyThreadState *tstate; if (!PyDict_Check(op)) return NULL; - if (!PyBytes_CheckExact(key) || - (hash = ((PyBytesObject *) key)->ob_shash) == -1) + if (!PyString_CheckExact(key) || + (hash = ((PyStringObject *) key)->ob_shash) == -1) { hash = PyObject_Hash(key); if (hash == -1) { @@ -680,8 +680,8 @@ PyDict_SetItem(register PyObject *op, PyObject *key, PyObject *value) assert(key); assert(value); mp = (PyDictObject *)op; - if (PyBytes_CheckExact(key)) { - hash = ((PyBytesObject *)key)->ob_shash; + if (PyString_CheckExact(key)) { + hash = ((PyStringObject *)key)->ob_shash; if (hash == -1) hash = PyObject_Hash(key); } @@ -728,8 +728,8 @@ PyDict_DelItem(PyObject *op, PyObject *key) return -1; } assert(key); - if (!PyBytes_CheckExact(key) || - (hash = ((PyBytesObject *) key)->ob_shash) == -1) { + if (!PyString_CheckExact(key) || + (hash = ((PyStringObject *) key)->ob_shash) == -1) { hash = PyObject_Hash(key); if (hash == -1) return -1; @@ -982,11 +982,11 @@ dict_repr(PyDictObject *mp) i = Py_ReprEnter((PyObject *)mp); if (i != 0) { - return i > 0 ? PyBytes_FromString("{...}") : NULL; + return i > 0 ? PyString_FromString("{...}") : NULL; } if (mp->ma_used == 0) { - result = PyBytes_FromString("{}"); + result = PyString_FromString("{}"); goto Done; } @@ -994,7 +994,7 @@ dict_repr(PyDictObject *mp) if (pieces == NULL) goto Done; - colon = PyBytes_FromString(": "); + colon = PyString_FromString(": "); if (colon == NULL) goto Done; @@ -1006,8 +1006,8 @@ dict_repr(PyDictObject *mp) /* Prevent repr from deleting value during key format. */ Py_INCREF(value); s = PyObject_Repr(key); - PyBytes_Concat(&s, colon); - PyBytes_ConcatAndDel(&s, PyObject_Repr(value)); + PyString_Concat(&s, colon); + PyString_ConcatAndDel(&s, PyObject_Repr(value)); Py_DECREF(value); if (s == NULL) goto Done; @@ -1019,29 +1019,29 @@ dict_repr(PyDictObject *mp) /* Add "{}" decorations to the first and last items. */ assert(PyList_GET_SIZE(pieces) > 0); - s = PyBytes_FromString("{"); + s = PyString_FromString("{"); if (s == NULL) goto Done; temp = PyList_GET_ITEM(pieces, 0); - PyBytes_ConcatAndDel(&s, temp); + PyString_ConcatAndDel(&s, temp); PyList_SET_ITEM(pieces, 0, s); if (s == NULL) goto Done; - s = PyBytes_FromString("}"); + s = PyString_FromString("}"); if (s == NULL) goto Done; temp = PyList_GET_ITEM(pieces, PyList_GET_SIZE(pieces) - 1); - PyBytes_ConcatAndDel(&temp, s); + PyString_ConcatAndDel(&temp, s); PyList_SET_ITEM(pieces, PyList_GET_SIZE(pieces) - 1, temp); if (temp == NULL) goto Done; /* Paste them all together with ", " between. */ - s = PyBytes_FromString(", "); + s = PyString_FromString(", "); if (s == NULL) goto Done; - result = _PyBytes_Join(s, pieces); + result = _PyString_Join(s, pieces); Py_DECREF(s); Done: @@ -1064,8 +1064,8 @@ dict_subscript(PyDictObject *mp, register PyObject *key) long hash; PyDictEntry *ep; assert(mp->ma_table != NULL); - if (!PyBytes_CheckExact(key) || - (hash = ((PyBytesObject *) key)->ob_shash) == -1) { + if (!PyString_CheckExact(key) || + (hash = ((PyStringObject *) key)->ob_shash) == -1) { hash = PyObject_Hash(key); if (hash == -1) return NULL; @@ -1081,7 +1081,7 @@ dict_subscript(PyDictObject *mp, register PyObject *key) static PyObject *missing_str = NULL; if (missing_str == NULL) missing_str = - PyBytes_InternFromString("__missing__"); + PyString_InternFromString("__missing__"); missing = _PyType_Lookup(Py_TYPE(mp), missing_str); if (missing != NULL) return PyObject_CallFunctionObjArgs(missing, @@ -1794,8 +1794,8 @@ dict_contains(register PyDictObject *mp, PyObject *key) long hash; PyDictEntry *ep; - if (!PyBytes_CheckExact(key) || - (hash = ((PyBytesObject *) key)->ob_shash) == -1) { + if (!PyString_CheckExact(key) || + (hash = ((PyStringObject *) key)->ob_shash) == -1) { hash = PyObject_Hash(key); if (hash == -1) return NULL; @@ -1827,8 +1827,8 @@ dict_get(register PyDictObject *mp, PyObject *args) if (!PyArg_UnpackTuple(args, "get", 1, 2, &key, &failobj)) return NULL; - if (!PyBytes_CheckExact(key) || - (hash = ((PyBytesObject *) key)->ob_shash) == -1) { + if (!PyString_CheckExact(key) || + (hash = ((PyStringObject *) key)->ob_shash) == -1) { hash = PyObject_Hash(key); if (hash == -1) return NULL; @@ -1856,8 +1856,8 @@ dict_setdefault(register PyDictObject *mp, PyObject *args) if (!PyArg_UnpackTuple(args, "setdefault", 1, 2, &key, &failobj)) return NULL; - if (!PyBytes_CheckExact(key) || - (hash = ((PyBytesObject *) key)->ob_shash) == -1) { + if (!PyString_CheckExact(key) || + (hash = ((PyStringObject *) key)->ob_shash) == -1) { hash = PyObject_Hash(key); if (hash == -1) return NULL; @@ -1902,8 +1902,8 @@ dict_pop(PyDictObject *mp, PyObject *args) "pop(): dictionary is empty"); return NULL; } - if (!PyBytes_CheckExact(key) || - (hash = ((PyBytesObject *) key)->ob_shash) == -1) { + if (!PyString_CheckExact(key) || + (hash = ((PyStringObject *) key)->ob_shash) == -1) { hash = PyObject_Hash(key); if (hash == -1) return NULL; @@ -2148,8 +2148,8 @@ PyDict_Contains(PyObject *op, PyObject *key) PyDictObject *mp = (PyDictObject *)op; PyDictEntry *ep; - if (!PyBytes_CheckExact(key) || - (hash = ((PyBytesObject *) key)->ob_shash) == -1) { + if (!PyString_CheckExact(key) || + (hash = ((PyStringObject *) key)->ob_shash) == -1) { hash = PyObject_Hash(key); if (hash == -1) return -1; @@ -2275,7 +2275,7 @@ PyObject * PyDict_GetItemString(PyObject *v, const char *key) { PyObject *kv, *rv; - kv = PyBytes_FromString(key); + kv = PyString_FromString(key); if (kv == NULL) return NULL; rv = PyDict_GetItem(v, kv); @@ -2288,10 +2288,10 @@ PyDict_SetItemString(PyObject *v, const char *key, PyObject *item) { PyObject *kv; int err; - kv = PyBytes_FromString(key); + kv = PyString_FromString(key); if (kv == NULL) return -1; - PyBytes_InternInPlace(&kv); /* XXX Should we really? */ + PyString_InternInPlace(&kv); /* XXX Should we really? */ err = PyDict_SetItem(v, kv, item); Py_DECREF(kv); return err; @@ -2302,7 +2302,7 @@ PyDict_DelItemString(PyObject *v, const char *key) { PyObject *kv; int err; - kv = PyBytes_FromString(key); + kv = PyString_FromString(key); if (kv == NULL) return -1; err = PyDict_DelItem(v, kv); |