mirror of
https://github.com/python/cpython.git
synced 2025-07-28 05:34:31 +00:00
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:
parent
e98839a1f4
commit
dd96db63f6
173 changed files with 2275 additions and 2280 deletions
|
@ -87,9 +87,9 @@ ste_repr(PySTEntryObject *ste)
|
|||
|
||||
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 int symtable_implicit_arg(struct symtable *st, int pos);
|
|||
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 @@ analyze_name(PySTEntryObject *ste, PyObject *dict, PyObject *name, long flags,
|
|||
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 @@ check_unoptimized(const PySTEntryObject* ste) {
|
|||
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 @@ symtable_add_def(struct symtable *st, PyObject *name, int flag)
|
|||
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 @@ symtable_new_tmpname(struct symtable *st)
|
|||
|
||||
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 @@ symtable_visit_stmt(struct symtable *st, stmt_ty s)
|
|||
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 @@ symtable_visit_expr(struct symtable *st, expr_ty e)
|
|||
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 @@ symtable_visit_alias(struct symtable *st, alias_ty a)
|
|||
*/
|
||||
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 @@ symtable_visit_alias(struct symtable *st, alias_ty a)
|
|||
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;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue