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.
This commit is contained in:
Gregory P. Smith 2008-06-09 04:58:54 +00:00
parent e98839a1f4
commit dd96db63f6
173 changed files with 2275 additions and 2280 deletions

View file

@ -46,7 +46,7 @@ static PyObject *parsestrplus(struct compiling *, const node *n);
static identifier
new_identifier(const char* n, PyArena *arena) {
PyObject* id = PyBytes_InternFromString(n);
PyObject* id = PyString_InternFromString(n);
PyArena_AddPyObject(arena, id);
return id;
}
@ -1291,7 +1291,7 @@ ast_for_atom(struct compiling *c, const node *n)
if (errstr) {
char *s = "";
char buf[128];
s = PyBytes_AsString(errstr);
s = PyString_AsString(errstr);
PyOS_snprintf(buf, sizeof(buf), "(unicode error) %s", s);
ast_error(n, buf);
} else {
@ -2333,10 +2333,10 @@ alias_for_import_name(struct compiling *c, const node *n)
/* length of string plus one for the dot */
len += strlen(STR(CHILD(n, i))) + 1;
len--; /* the last name doesn't have a dot */
str = PyBytes_FromStringAndSize(NULL, len);
str = PyString_FromStringAndSize(NULL, len);
if (!str)
return NULL;
s = PyBytes_AS_STRING(str);
s = PyString_AS_STRING(str);
if (!s)
return NULL;
for (i = 0; i < NCH(n); i += 2) {
@ -2347,13 +2347,13 @@ alias_for_import_name(struct compiling *c, const node *n)
}
--s;
*s = '\0';
PyBytes_InternInPlace(&str);
PyString_InternInPlace(&str);
PyArena_AddPyObject(c->c_arena, str);
return alias(str, NULL, c->c_arena);
}
break;
case STAR:
str = PyBytes_InternFromString("*");
str = PyString_InternFromString("*");
PyArena_AddPyObject(c->c_arena, str);
return alias(str, NULL, c->c_arena);
default:
@ -3201,10 +3201,10 @@ decode_unicode(struct compiling *c, const char *s, size_t len, int rawmode, cons
u = NULL;
} else {
/* "\XX" may become "\u005c\uHHLL" (12 bytes) */
u = PyBytes_FromStringAndSize((char *)NULL, len * 4);
u = PyString_FromStringAndSize((char *)NULL, len * 4);
if (u == NULL)
return NULL;
p = buf = PyBytes_AsString(u);
p = buf = PyString_AsString(u);
end = s + len;
while (s < end) {
if (*s == '\\') {
@ -3223,8 +3223,8 @@ decode_unicode(struct compiling *c, const char *s, size_t len, int rawmode, cons
Py_DECREF(u);
return NULL;
}
r = PyBytes_AsString(w);
rn = PyBytes_Size(w);
r = PyString_AsString(w);
rn = PyString_Size(w);
assert(rn % 2 == 0);
for (i = 0; i < rn; i += 2) {
sprintf(p, "\\u%02x%02x",
@ -3323,11 +3323,11 @@ parsestr(struct compiling *c, const char *s)
return v;
#endif
} else {
return PyBytes_FromStringAndSize(s, len);
return PyString_FromStringAndSize(s, len);
}
}
return PyBytes_DecodeEscape(s, len, NULL, unicode,
return PyString_DecodeEscape(s, len, NULL, unicode,
need_encoding ? c->c_encoding : NULL);
}
@ -3348,8 +3348,8 @@ parsestrplus(struct compiling *c, const node *n)
s = parsestr(c, STR(CHILD(n, i)));
if (s == NULL)
goto onError;
if (PyBytes_Check(v) && PyBytes_Check(s)) {
PyBytes_ConcatAndDel(&v, s);
if (PyString_Check(v) && PyString_Check(s)) {
PyString_ConcatAndDel(&v, s);
if (v == NULL)
goto onError;
}