Mercurial > cpython-lru_cache-weakref
diff Python/ast.c @ 47527:52294af4b663 legacy-trunk
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.
| author | Gregory P. Smith <greg@mad-scientist.com> |
|---|---|
| date | Mon, 09 Jun 2008 04:58:54 +0000 |
| parents | 53253f36014e |
| children | 1c964ed35ef9 |
line wrap: on
line diff
--- a/Python/ast.c Mon Jun 09 01:28:30 2008 +0000 +++ b/Python/ast.c Mon Jun 09 04:58:54 2008 +0000 @@ -46,7 +46,7 @@ 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 @@ 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 @@ /* 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 @@ } --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 @@ 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 @@ 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 @@ 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 @@ 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; }
