Mercurial > cpython-lru_cache-weakref
diff Python/symtable.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 | 4fe192d48960 |
| children | 2d76af7f7702 |
line wrap: on
line diff
--- a/Python/symtable.c Mon Jun 09 01:28:30 2008 +0000 +++ b/Python/symtable.c Mon Jun 09 04:58:54 2008 +0000 @@ -87,9 +87,9 @@ PyOS_snprintf(buf, sizeof(buf), "<symtable entry %.100s(%ld), line %d>", - PyBytes_AS_STRING(ste->ste_name), + PyString_AS_STRING(ste->ste_name), PyInt_AS_LONG(ste->ste_id), ste->ste_lineno); - return PyBytes_FromString(buf); + return PyString_FromString(buf); } static void @@ -180,7 +180,7 @@ static identifier top = NULL, lambda = NULL, genexpr = NULL; #define GET_IDENTIFIER(VAR) \ - ((VAR) ? (VAR) : ((VAR) = PyBytes_InternFromString(# VAR))) + ((VAR) ? (VAR) : ((VAR) = PyString_InternFromString(# VAR))) #define DUPLICATE_ARGUMENT \ "duplicate argument '%s' in function definition" @@ -372,7 +372,7 @@ if (flags & DEF_PARAM) { PyErr_Format(PyExc_SyntaxError, "name '%s' is local and global", - PyBytes_AS_STRING(name)); + PyString_AS_STRING(name)); return 0; } SET_SCOPE(dict, name, GLOBAL_EXPLICIT); @@ -487,19 +487,19 @@ PyOS_snprintf(buf, sizeof(buf), "import * is not allowed in function '%.100s' " "because it is %s", - PyBytes_AS_STRING(ste->ste_name), trailer); + PyString_AS_STRING(ste->ste_name), trailer); break; case OPT_BARE_EXEC: PyOS_snprintf(buf, sizeof(buf), "unqualified exec is not allowed in function " "'%.100s' it %s", - PyBytes_AS_STRING(ste->ste_name), trailer); + PyString_AS_STRING(ste->ste_name), trailer); break; default: PyOS_snprintf(buf, sizeof(buf), "function '%.100s' uses import * and bare exec, " "which are illegal because it %s", - PyBytes_AS_STRING(ste->ste_name), trailer); + PyString_AS_STRING(ste->ste_name), trailer); break; } @@ -800,7 +800,7 @@ if ((flag & DEF_PARAM) && (val & DEF_PARAM)) { /* Is it better to use 'mangled' or 'name' here? */ PyErr_Format(PyExc_SyntaxError, DUPLICATE_ARGUMENT, - PyBytes_AsString(name)); + PyString_AsString(name)); PyErr_SyntaxLocation(st->st_filename, st->st_cur->ste_lineno); goto error; @@ -914,7 +914,7 @@ PyOS_snprintf(tmpname, sizeof(tmpname), "_[%d]", ++st->st_cur->ste_tmpname); - tmp = PyBytes_InternFromString(tmpname); + tmp = PyString_InternFromString(tmpname); if (!tmp) return 0; if (!symtable_add_def(st, tmp, DEF_LOCAL)) @@ -1065,7 +1065,7 @@ asdl_seq *seq = s->v.Global.names; for (i = 0; i < asdl_seq_LEN(seq); i++) { identifier name = (identifier)asdl_seq_GET(seq, i); - char *c_name = PyBytes_AS_STRING(name); + char *c_name = PyString_AS_STRING(name); long cur = symtable_lookup(st, name); if (cur < 0) return 0; @@ -1218,7 +1218,7 @@ static int symtable_implicit_arg(struct symtable *st, int pos) { - PyObject *id = PyBytes_FromFormat(".%d", pos); + PyObject *id = PyString_FromFormat(".%d", pos); if (id == NULL) return 0; if (!symtable_add_def(st, id, DEF_PARAM)) { @@ -1326,10 +1326,10 @@ */ PyObject *store_name; PyObject *name = (a->asname == NULL) ? a->name : a->asname; - const char *base = PyBytes_AS_STRING(name); + const char *base = PyString_AS_STRING(name); char *dot = strchr(base, '.'); if (dot) { - store_name = PyBytes_FromStringAndSize(base, dot - base); + store_name = PyString_FromStringAndSize(base, dot - base); if (!store_name) return 0; } @@ -1337,7 +1337,7 @@ store_name = name; Py_INCREF(store_name); } - if (strcmp(PyBytes_AS_STRING(name), "*")) { + if (strcmp(PyString_AS_STRING(name), "*")) { int r = symtable_add_def(st, store_name, DEF_IMPORT); Py_DECREF(store_name); return r;
