This reverts r63675 based on the discussion in this thread:
http://mail.python.org/pipermail/python-dev/2008-June/079988.html
Python 2.6 should stick with PyString_* in its codebase. The PyBytes_* names
in the spirit of 3.0 are available via a #define only. See the email thread.
diff --git a/Objects/setobject.c b/Objects/setobject.c
index 5e8e05d..371d8c1 100644
--- a/Objects/setobject.c
+++ b/Objects/setobject.c
@@ -151,7 +151,7 @@
/*
* Hacked up version of set_lookkey which can assume keys are always strings;
- * This means we can always use _PyBytes_Eq directly and not have to check to
+ * This means we can always use _PyString_Eq directly and not have to check to
* see if the comparison altered the table.
*/
static setentry *
@@ -168,7 +168,7 @@
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)) {
so->lookup = set_lookkey;
return set_lookkey(so, key, hash);
}
@@ -179,7 +179,7 @@
if (entry->key == dummy)
freeslot = entry;
else {
- if (entry->hash == hash && _PyBytes_Eq(entry->key, key))
+ if (entry->hash == hash && _PyString_Eq(entry->key, key))
return entry;
freeslot = NULL;
}
@@ -194,7 +194,7 @@
if (entry->key == key
|| (entry->hash == hash
&& entry->key != dummy
- && _PyBytes_Eq(entry->key, key)))
+ && _PyString_Eq(entry->key, key)))
return entry;
if (entry->key == dummy && freeslot == NULL)
freeslot = entry;
@@ -381,8 +381,8 @@
register long hash;
register Py_ssize_t n_used;
- 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;
@@ -428,8 +428,8 @@
PyObject *old_key;
assert (PyAnySet_Check(so));
- 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;
@@ -618,7 +618,7 @@
if (status != 0) {
if (status < 0)
return NULL;
- return PyBytes_FromFormat("%s(...)", so->ob_type->tp_name);
+ return PyString_FromFormat("%s(...)", so->ob_type->tp_name);
}
keys = PySequence_List((PyObject *)so);
@@ -629,8 +629,8 @@
if (listrepr == NULL)
goto done;
- result = PyBytes_FromFormat("%s(%s)", so->ob_type->tp_name,
- PyBytes_AS_STRING(listrepr));
+ result = PyString_FromFormat("%s(%s)", so->ob_type->tp_name,
+ PyString_AS_STRING(listrepr));
Py_DECREF(listrepr);
done:
Py_ReprLeave((PyObject*)so);
@@ -685,8 +685,8 @@
long hash;
setentry *entry;
- 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;
@@ -983,7 +983,7 @@
register PySetObject *so = NULL;
if (dummy == NULL) { /* Auto-initialize dummy */
- dummy = PyBytes_FromString("<dummy key>");
+ dummy = PyString_FromString("<dummy key>");
if (dummy == NULL)
return NULL;
}
@@ -2322,7 +2322,7 @@
/* Exercise direct iteration */
i = 0, count = 0;
while (_PySet_Next((PyObject *)dup, &i, &x)) {
- s = PyBytes_AsString(x);
+ s = PyString_AsString(x);
assert(s && (s[0] == 'a' || s[0] == 'b' || s[0] == 'c'));
count++;
}