summaryrefslogtreecommitdiffstats
path: root/Python
diff options
context:
space:
mode:
authorGregory P. Smith <greg@mad-scientist.com>2008-06-09 04:58:54 (GMT)
committerGregory P. Smith <greg@mad-scientist.com>2008-06-09 04:58:54 (GMT)
commitdd96db63f689e2f0d8ae5a1436b3b3395eec7de5 (patch)
treeb2299acac9ce44fc488fc7b2ae2a44548cd5fbb8 /Python
parente98839a1f48b2915f1cc747884e64f4d6e4c8e7a (diff)
downloadcpython-dd96db63f689e2f0d8ae5a1436b3b3395eec7de5.zip
cpython-dd96db63f689e2f0d8ae5a1436b3b3395eec7de5.tar.gz
cpython-dd96db63f689e2f0d8ae5a1436b3b3395eec7de5.tar.bz2
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.
Diffstat (limited to 'Python')
-rw-r--r--Python/Python-ast.c28
-rw-r--r--Python/_warnings.c56
-rw-r--r--Python/ast.c28
-rw-r--r--Python/bltinmodule.c60
-rw-r--r--Python/ceval.c94
-rw-r--r--Python/codecs.c10
-rw-r--r--Python/compile.c94
-rw-r--r--Python/errors.c18
-rw-r--r--Python/future.c4
-rw-r--r--Python/getargs.c62
-rw-r--r--Python/import.c68
-rw-r--r--Python/mactoolboxglue.c18
-rw-r--r--Python/marshal.c36
-rw-r--r--Python/modsupport.c10
-rw-r--r--Python/peephole.c16
-rw-r--r--Python/pystrtod.c2
-rw-r--r--Python/pythonrun.c28
-rw-r--r--Python/structmember.c12
-rw-r--r--Python/symtable.c28
-rw-r--r--Python/sysmodule.c38
-rw-r--r--Python/traceback.c10
21 files changed, 360 insertions, 360 deletions
diff --git a/Python/Python-ast.c b/Python/Python-ast.c
index 35a3d27..f958145 100644
--- a/Python/Python-ast.c
+++ b/Python/Python-ast.c
@@ -495,7 +495,7 @@ static PyTypeObject* make_type(char *type, PyTypeObject* base, char**fields, int
fnames = PyTuple_New(num_fields);
if (!fnames) return NULL;
for (i = 0; i < num_fields; i++) {
- PyObject *field = PyBytes_FromString(fields[i]);
+ PyObject *field = PyString_FromString(fields[i]);
if (!field) {
Py_DECREF(fnames);
return NULL;
@@ -514,7 +514,7 @@ static int add_attributes(PyTypeObject* type, char**attrs, int num_fields)
PyObject *s, *l = PyTuple_New(num_fields);
if (!l) return 0;
for(i = 0; i < num_fields; i++) {
- s = PyBytes_FromString(attrs[i]);
+ s = PyString_FromString(attrs[i]);
if (!s) {
Py_DECREF(l);
return 0;
@@ -588,7 +588,7 @@ static int obj2ast_int(PyObject* obj, int* out, PyArena* arena)
PyObject *s = PyObject_Repr(obj);
if (s == NULL) return 1;
PyErr_Format(PyExc_ValueError, "invalid integer value: %.400s",
- PyBytes_AS_STRING(s));
+ PyString_AS_STRING(s));
Py_DECREF(s);
return 1;
}
@@ -606,7 +606,7 @@ static int obj2ast_bool(PyObject* obj, bool* out, PyArena* arena)
PyObject *s = PyObject_Repr(obj);
if (s == NULL) return 1;
PyErr_Format(PyExc_ValueError, "invalid boolean value: %.400s",
- PyBytes_AS_STRING(s));
+ PyString_AS_STRING(s));
Py_DECREF(s);
return 1;
}
@@ -3286,7 +3286,7 @@ obj2ast_mod(PyObject* obj, mod_ty* out, PyArena* arena)
tmp = PyObject_Repr(obj);
if (tmp == NULL) goto failed;
- PyErr_Format(PyExc_TypeError, "expected some sort of mod, but got %.400s", PyBytes_AS_STRING(tmp));
+ PyErr_Format(PyExc_TypeError, "expected some sort of mod, but got %.400s", PyString_AS_STRING(tmp));
failed:
Py_XDECREF(tmp);
return 1;
@@ -4414,7 +4414,7 @@ obj2ast_stmt(PyObject* obj, stmt_ty* out, PyArena* arena)
tmp = PyObject_Repr(obj);
if (tmp == NULL) goto failed;
- PyErr_Format(PyExc_TypeError, "expected some sort of stmt, but got %.400s", PyBytes_AS_STRING(tmp));
+ PyErr_Format(PyExc_TypeError, "expected some sort of stmt, but got %.400s", PyString_AS_STRING(tmp));
failed:
Py_XDECREF(tmp);
return 1;
@@ -5261,7 +5261,7 @@ obj2ast_expr(PyObject* obj, expr_ty* out, PyArena* arena)
tmp = PyObject_Repr(obj);
if (tmp == NULL) goto failed;
- PyErr_Format(PyExc_TypeError, "expected some sort of expr, but got %.400s", PyBytes_AS_STRING(tmp));
+ PyErr_Format(PyExc_TypeError, "expected some sort of expr, but got %.400s", PyString_AS_STRING(tmp));
failed:
Py_XDECREF(tmp);
return 1;
@@ -5299,7 +5299,7 @@ obj2ast_expr_context(PyObject* obj, expr_context_ty* out, PyArena* arena)
tmp = PyObject_Repr(obj);
if (tmp == NULL) goto failed;
- PyErr_Format(PyExc_TypeError, "expected some sort of expr_context, but got %.400s", PyBytes_AS_STRING(tmp));
+ PyErr_Format(PyExc_TypeError, "expected some sort of expr_context, but got %.400s", PyString_AS_STRING(tmp));
failed:
Py_XDECREF(tmp);
return 1;
@@ -5417,7 +5417,7 @@ obj2ast_slice(PyObject* obj, slice_ty* out, PyArena* arena)
tmp = PyObject_Repr(obj);
if (tmp == NULL) goto failed;
- PyErr_Format(PyExc_TypeError, "expected some sort of slice, but got %.400s", PyBytes_AS_STRING(tmp));
+ PyErr_Format(PyExc_TypeError, "expected some sort of slice, but got %.400s", PyString_AS_STRING(tmp));
failed:
Py_XDECREF(tmp);
return 1;
@@ -5439,7 +5439,7 @@ obj2ast_boolop(PyObject* obj, boolop_ty* out, PyArena* arena)
tmp = PyObject_Repr(obj);
if (tmp == NULL) goto failed;
- PyErr_Format(PyExc_TypeError, "expected some sort of boolop, but got %.400s", PyBytes_AS_STRING(tmp));
+ PyErr_Format(PyExc_TypeError, "expected some sort of boolop, but got %.400s", PyString_AS_STRING(tmp));
failed:
Py_XDECREF(tmp);
return 1;
@@ -5501,7 +5501,7 @@ obj2ast_operator(PyObject* obj, operator_ty* out, PyArena* arena)
tmp = PyObject_Repr(obj);
if (tmp == NULL) goto failed;
- PyErr_Format(PyExc_TypeError, "expected some sort of operator, but got %.400s", PyBytes_AS_STRING(tmp));
+ PyErr_Format(PyExc_TypeError, "expected some sort of operator, but got %.400s", PyString_AS_STRING(tmp));
failed:
Py_XDECREF(tmp);
return 1;
@@ -5531,7 +5531,7 @@ obj2ast_unaryop(PyObject* obj, unaryop_ty* out, PyArena* arena)
tmp = PyObject_Repr(obj);
if (tmp == NULL) goto failed;
- PyErr_Format(PyExc_TypeError, "expected some sort of unaryop, but got %.400s", PyBytes_AS_STRING(tmp));
+ PyErr_Format(PyExc_TypeError, "expected some sort of unaryop, but got %.400s", PyString_AS_STRING(tmp));
failed:
Py_XDECREF(tmp);
return 1;
@@ -5585,7 +5585,7 @@ obj2ast_cmpop(PyObject* obj, cmpop_ty* out, PyArena* arena)
tmp = PyObject_Repr(obj);
if (tmp == NULL) goto failed;
- PyErr_Format(PyExc_TypeError, "expected some sort of cmpop, but got %.400s", PyBytes_AS_STRING(tmp));
+ PyErr_Format(PyExc_TypeError, "expected some sort of cmpop, but got %.400s", PyString_AS_STRING(tmp));
failed:
Py_XDECREF(tmp);
return 1;
@@ -5751,7 +5751,7 @@ obj2ast_excepthandler(PyObject* obj, excepthandler_ty* out, PyArena* arena)
tmp = PyObject_Repr(obj);
if (tmp == NULL) goto failed;
- PyErr_Format(PyExc_TypeError, "expected some sort of excepthandler, but got %.400s", PyBytes_AS_STRING(tmp));
+ PyErr_Format(PyExc_TypeError, "expected some sort of excepthandler, but got %.400s", PyString_AS_STRING(tmp));
failed:
Py_XDECREF(tmp);
return 1;
diff --git a/Python/_warnings.c b/Python/_warnings.c
index 0adb0c8..e3daf77 100644
--- a/Python/_warnings.c
+++ b/Python/_warnings.c
@@ -44,7 +44,7 @@ get_warnings_attr(const char *attr)
int result;
if (warnings_str == NULL) {
- warnings_str = PyBytes_InternFromString("warnings");
+ warnings_str = PyString_InternFromString("warnings");
if (warnings_str == NULL)
return NULL;
}
@@ -132,7 +132,7 @@ get_filter(PyObject *category, PyObject *text, Py_ssize_t lineno,
return NULL;
if (good_msg && is_subclass && good_mod && (ln == 0 || lineno == ln))
- return PyBytes_AsString(action);
+ return PyString_AsString(action);
}
m = PyImport_ImportModule(MODULE_NAME);
@@ -144,7 +144,7 @@ get_filter(PyObject *category, PyObject *text, Py_ssize_t lineno,
return NULL;
action = PyDict_GetItemString(d, DEFAULT_ACTION_NAME);
if (action != NULL)
- return PyBytes_AsString(action);
+ return PyString_AsString(action);
PyErr_SetString(PyExc_ValueError,
MODULE_NAME "." DEFAULT_ACTION_NAME " not found");
@@ -184,17 +184,17 @@ normalize_module(PyObject *filename)
if (rc == -1)
return NULL;
else if (rc == 0)
- return PyBytes_FromString("<unknown>");
+ return PyString_FromString("<unknown>");
- mod_str = PyBytes_AsString(filename);
+ mod_str = PyString_AsString(filename);
if (mod_str == NULL)
return NULL;
- len = PyBytes_Size(filename);
+ len = PyString_Size(filename);
if (len < 0)
return NULL;
if (len >= 3 &&
strncmp(mod_str + (len - 3), ".py", 3) == 0) {
- module = PyBytes_FromStringAndSize(mod_str, len-3);
+ module = PyString_FromStringAndSize(mod_str, len-3);
}
else {
module = filename;
@@ -258,7 +258,7 @@ show_warning(PyObject *filename, int lineno, PyObject *text, PyObject
/* Print " source_line\n" */
PyFile_WriteString(" ", f_stderr);
if (sourceline) {
- char *source_line_str = PyBytes_AS_STRING(sourceline);
+ char *source_line_str = PyString_AS_STRING(sourceline);
while (*source_line_str == ' ' || *source_line_str == '\t' ||
*source_line_str == '\014')
source_line_str++;
@@ -267,7 +267,7 @@ show_warning(PyObject *filename, int lineno, PyObject *text, PyObject
PyFile_WriteString("\n", f_stderr);
}
else
- Py_DisplaySourceLine(f_stderr, PyBytes_AS_STRING(filename), lineno);
+ Py_DisplaySourceLine(f_stderr, PyString_AS_STRING(filename), lineno);
PyErr_Clear();
}
@@ -359,7 +359,7 @@ warn_explicit(PyObject *category, PyObject *message,
const char *err_str = "???";
if (to_str != NULL)
- err_str = PyBytes_AS_STRING(to_str);
+ err_str = PyString_AS_STRING(to_str);
PyErr_Format(PyExc_RuntimeError,
"Unrecognized action (%s) in warnings.filters:\n %s",
action, err_str);
@@ -380,7 +380,7 @@ warn_explicit(PyObject *category, PyObject *message,
else {
const char *msg = "functions overriding warnings.showwarning() "
"must support the 'line' argument";
- const char *text_char = PyBytes_AS_STRING(text);
+ const char *text_char = PyString_AS_STRING(text);
if (strcmp(msg, text_char) == 0) {
/* Prevent infinite recursion by using built-in implementation
@@ -484,7 +484,7 @@ setup_context(Py_ssize_t stack_level, PyObject **filename, int *lineno,
/* Setup module. */
*module = PyDict_GetItemString(globals, "__name__");
if (*module == NULL) {
- *module = PyBytes_FromString("<string>");
+ *module = PyString_FromString("<string>");
if (*module == NULL)
goto handle_error;
}
@@ -494,8 +494,8 @@ setup_context(Py_ssize_t stack_level, PyObject **filename, int *lineno,
/* Setup filename. */
*filename = PyDict_GetItemString(globals, "__file__");
if (*filename != NULL) {
- Py_ssize_t len = PyBytes_Size(*filename);
- const char *file_str = PyBytes_AsString(*filename);
+ Py_ssize_t len = PyString_Size(*filename);
+ const char *file_str = PyString_AsString(*filename);
if (file_str == NULL || (len < 0 && PyErr_Occurred()))
goto handle_error;
@@ -507,7 +507,7 @@ setup_context(Py_ssize_t stack_level, PyObject **filename, int *lineno,
(tolower(file_str[len-1]) == 'c' ||
tolower(file_str[len-1]) == 'o'))
{
- *filename = PyBytes_FromStringAndSize(file_str, len-1);
+ *filename = PyString_FromStringAndSize(file_str, len-1);
if (*filename == NULL)
goto handle_error;
}
@@ -515,7 +515,7 @@ setup_context(Py_ssize_t stack_level, PyObject **filename, int *lineno,
Py_INCREF(*filename);
}
else {
- const char *module_str = PyBytes_AsString(*module);
+ const char *module_str = PyString_AsString(*module);
if (module_str && strcmp(module_str, "__main__") == 0) {
PyObject *argv = PySys_GetObject("argv");
if (argv != NULL && PyList_Size(argv) > 0) {
@@ -530,14 +530,14 @@ setup_context(Py_ssize_t stack_level, PyObject **filename, int *lineno,
}
else if (!is_true) {
Py_DECREF(*filename);
- *filename = PyBytes_FromString("__main__");
+ *filename = PyString_FromString("__main__");
if (*filename == NULL)
goto handle_error;
}
}
else {
/* embedded interpreters don't have sys.argv, see bug #839151 */
- *filename = PyBytes_FromString("__main__");
+ *filename = PyString_FromString("__main__");
if (*filename == NULL)
goto handle_error;
}
@@ -649,12 +649,12 @@ warnings_warn_explicit(PyObject *self, PyObject *args, PyObject *kwds)
PyObject *returned;
if (get_source_name == NULL) {
- get_source_name = PyBytes_InternFromString("get_source");
+ get_source_name = PyString_InternFromString("get_source");
if (!get_source_name)
return NULL;
}
if (splitlines_name == NULL) {
- splitlines_name = PyBytes_InternFromString("splitlines");
+ splitlines_name = PyString_InternFromString("splitlines");
if (!splitlines_name)
return NULL;
}
@@ -711,7 +711,7 @@ int
PyErr_WarnEx(PyObject *category, const char *text, Py_ssize_t stack_level)
{
PyObject *res;
- PyObject *message = PyBytes_FromString(text);
+ PyObject *message = PyString_FromString(text);
if (message == NULL)
return -1;
@@ -745,15 +745,15 @@ PyErr_WarnExplicit(PyObject *category, const char *text,
const char *module_str, PyObject *registry)
{
PyObject *res;
- PyObject *message = PyBytes_FromString(text);
- PyObject *filename = PyBytes_FromString(filename_str);
+ PyObject *message = PyString_FromString(text);
+ PyObject *filename = PyString_FromString(filename_str);
PyObject *module = NULL;
int ret = -1;
if (message == NULL || filename == NULL)
goto exit;
if (module_str != NULL) {
- module = PyBytes_FromString(module_str);
+ module = PyString_FromString(module_str);
if (module == NULL)
goto exit;
}
@@ -803,7 +803,7 @@ create_filter(PyObject *category, const char *action)
if (!strcmp(action, "ignore")) {
if (ignore_str == NULL) {
- ignore_str = PyBytes_InternFromString("ignore");
+ ignore_str = PyString_InternFromString("ignore");
if (ignore_str == NULL)
return NULL;
}
@@ -811,7 +811,7 @@ create_filter(PyObject *category, const char *action)
}
else if (!strcmp(action, "error")) {
if (error_str == NULL) {
- error_str = PyBytes_InternFromString("error");
+ error_str = PyString_InternFromString("error");
if (error_str == NULL)
return NULL;
}
@@ -819,7 +819,7 @@ create_filter(PyObject *category, const char *action)
}
else if (!strcmp(action, "default")) {
if (default_str == NULL) {
- default_str = PyBytes_InternFromString("default");
+ default_str = PyString_InternFromString("default");
if (default_str == NULL)
return NULL;
}
@@ -892,7 +892,7 @@ _PyWarnings_Init(void)
if (PyModule_AddObject(m, "once_registry", _once_registry) < 0)
return;
- default_action = PyBytes_InternFromString("default");
+ default_action = PyString_InternFromString("default");
if (default_action == NULL)
return;
if (PyModule_AddObject(m, DEFAULT_ACTION_NAME, default_action) < 0)
diff --git a/Python/ast.c b/Python/ast.c
index ef0d8be..a6bb1b7 100644
--- a/Python/ast.c
+++ b/Python/ast.c
@@ -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;
}
diff --git a/Python/bltinmodule.c b/Python/bltinmodule.c
index 715a108..a2ebb4a 100644
--- a/Python/bltinmodule.c
+++ b/Python/bltinmodule.c
@@ -247,7 +247,7 @@ builtin_filter(PyObject *self, PyObject *args)
return NULL;
/* Strings and tuples return a result of the same type. */
- if (PyBytes_Check(seq))
+ if (PyString_Check(seq))
return filterstring(func, seq);
#ifdef Py_USING_UNICODE
if (PyUnicode_Check(seq))
@@ -381,7 +381,7 @@ builtin_chr(PyObject *self, PyObject *args)
return NULL;
}
s[0] = (char)x;
- return PyBytes_FromStringAndSize(s, 1);
+ return PyString_FromStringAndSize(s, 1);
}
PyDoc_STRVAR(chr_doc,
@@ -652,7 +652,7 @@ builtin_eval(PyObject *self, PyObject *args)
return PyEval_EvalCode((PyCodeObject *) cmd, globals, locals);
}
- if (!PyBytes_Check(cmd) &&
+ if (!PyString_Check(cmd) &&
!PyUnicode_Check(cmd)) {
PyErr_SetString(PyExc_TypeError,
"eval() arg 1 must be a string or code object");
@@ -669,7 +669,7 @@ builtin_eval(PyObject *self, PyObject *args)
cf.cf_flags |= PyCF_SOURCE_IS_UTF8;
}
#endif
- if (PyBytes_AsStringAndSize(cmd, &str, NULL)) {
+ if (PyString_AsStringAndSize(cmd, &str, NULL)) {
Py_XDECREF(tmp);
return NULL;
}
@@ -814,7 +814,7 @@ builtin_getattr(PyObject *self, PyObject *args)
}
#endif
- if (!PyBytes_Check(name)) {
+ if (!PyString_Check(name)) {
PyErr_SetString(PyExc_TypeError,
"getattr(): attribute name must be string");
return NULL;
@@ -870,7 +870,7 @@ builtin_hasattr(PyObject *self, PyObject *args)
}
#endif
- if (!PyBytes_Check(name)) {
+ if (!PyString_Check(name)) {
PyErr_SetString(PyExc_TypeError,
"hasattr(): attribute name must be string");
return NULL;
@@ -1189,7 +1189,7 @@ builtin_hex(PyObject *self, PyObject *v)
return NULL;
}
res = (*nb->nb_hex)(v);
- if (res && !PyBytes_Check(res)) {
+ if (res && !PyString_Check(res)) {
PyErr_Format(PyExc_TypeError,
"__hex__ returned non-string (type %.200s)",
res->ob_type->tp_name);
@@ -1249,13 +1249,13 @@ builtin_intern(PyObject *self, PyObject *args)
PyObject *s;
if (!PyArg_ParseTuple(args, "S:intern", &s))
return NULL;
- if (!PyBytes_CheckExact(s)) {
+ if (!PyString_CheckExact(s)) {
PyErr_SetString(PyExc_TypeError,
"can't intern subclass of string");
return NULL;
}
Py_INCREF(s);
- PyBytes_InternInPlace(&s);
+ PyString_InternInPlace(&s);
return s;
}
@@ -1457,7 +1457,7 @@ builtin_oct(PyObject *self, PyObject *v)
return NULL;
}
res = (*nb->nb_oct)(v);
- if (res && !PyBytes_Check(res)) {
+ if (res && !PyString_Check(res)) {
PyErr_Format(PyExc_TypeError,
"__oct__ returned non-string (type %.200s)",
res->ob_type->tp_name);
@@ -1492,10 +1492,10 @@ builtin_ord(PyObject *self, PyObject* obj)
long ord;
Py_ssize_t size;
- if (PyBytes_Check(obj)) {
- size = PyBytes_GET_SIZE(obj);
+ if (PyString_Check(obj)) {
+ size = PyString_GET_SIZE(obj);
if (size == 1) {
- ord = (long)((unsigned char)*PyBytes_AS_STRING(obj));
+ ord = (long)((unsigned char)*PyString_AS_STRING(obj));
return PyInt_FromLong(ord);
}
} else if (PyByteArray_Check(obj)) {
@@ -1572,14 +1572,14 @@ builtin_print(PyObject *self, PyObject *args, PyObject *kwds)
Py_RETURN_NONE;
}
- if (sep && sep != Py_None && !PyBytes_Check(sep) &&
+ if (sep && sep != Py_None && !PyString_Check(sep) &&
!PyUnicode_Check(sep)) {
PyErr_Format(PyExc_TypeError,
"sep must be None, str or unicode, not %.200s",
sep->ob_type->tp_name);
return NULL;
}
- if (end && end != Py_None && !PyBytes_Check(end) &&
+ if (end && end != Py_None && !PyString_Check(end) &&
!PyUnicode_Check(end)) {
PyErr_Format(PyExc_TypeError,
"end must be None, str or unicode, not %.200s",
@@ -1948,7 +1948,7 @@ builtin_raw_input(PyObject *self, PyObject *args)
po = PyObject_Str(v);
if (po == NULL)
return NULL;
- prompt = PyBytes_AsString(po);
+ prompt = PyString_AsString(po);
if (prompt == NULL)
return NULL;
}
@@ -1976,7 +1976,7 @@ builtin_raw_input(PyObject *self, PyObject *args)
result = NULL;
}
else {
- result = PyBytes_FromStringAndSize(s, len-1);
+ result = PyString_FromStringAndSize(s, len-1);
}
}
PyMem_FREE(s);
@@ -2619,7 +2619,7 @@ _PyBuiltin_Init(void)
SETBUILTIN("bool", &PyBool_Type);
/* SETBUILTIN("memoryview", &PyMemoryView_Type); */
SETBUILTIN("bytearray", &PyByteArray_Type);
- SETBUILTIN("bytes", &PyBytes_Type);
+ SETBUILTIN("bytes", &PyString_Type);
SETBUILTIN("buffer", &PyBuffer_Type);
SETBUILTIN("classmethod", &PyClassMethod_Type);
#ifndef WITHOUT_COMPLEX
@@ -2639,7 +2639,7 @@ _PyBuiltin_Init(void)
SETBUILTIN("set", &PySet_Type);
SETBUILTIN("slice", &PySlice_Type);
SETBUILTIN("staticmethod", &PyStaticMethod_Type);
- SETBUILTIN("str", &PyBytes_Type);
+ SETBUILTIN("str", &PyString_Type);
SETBUILTIN("super", &PySuper_Type);
SETBUILTIN("tuple", &PyTuple_Type);
SETBUILTIN("type", &PyType_Type);
@@ -2737,7 +2737,7 @@ filterstring(PyObject *func, PyObject *strobj)
{
PyObject *result;
Py_ssize_t i, j;
- Py_ssize_t len = PyBytes_Size(strobj);
+ Py_ssize_t len = PyString_Size(strobj);
Py_ssize_t outlen = len;
if (func == Py_None) {
@@ -2745,12 +2745,12 @@ filterstring(PyObject *func, PyObject *strobj)
* as no character is ever false and __getitem__
* does return this character. If it's a subclass
* we must go through the __getitem__ loop */
- if (PyBytes_CheckExact(strobj)) {
+ if (PyString_CheckExact(strobj)) {
Py_INCREF(strobj);
return strobj;
}
}
- if ((result = PyBytes_FromStringAndSize(NULL, len)) == NULL)
+ if ((result = PyString_FromStringAndSize(NULL, len)) == NULL)
return NULL;
for (i = j = 0; i < len; ++i) {
@@ -2780,16 +2780,16 @@ filterstring(PyObject *func, PyObject *strobj)
}
if (ok) {
Py_ssize_t reslen;
- if (!PyBytes_Check(item)) {
+ if (!PyString_Check(item)) {
PyErr_SetString(PyExc_TypeError, "can't filter str to str:"
" __getitem__ returned different type");
Py_DECREF(item);
goto Fail_1;
}
- reslen = PyBytes_GET_SIZE(item);
+ reslen = PyString_GET_SIZE(item);
if (reslen == 1) {
- PyBytes_AS_STRING(result)[j++] =
- PyBytes_AS_STRING(item)[0];
+ PyString_AS_STRING(result)[j++] =
+ PyString_AS_STRING(item)[0];
} else {
/* do we need more space? */
Py_ssize_t need = j + reslen + len-i-1;
@@ -2797,15 +2797,15 @@ filterstring(PyObject *func, PyObject *strobj)
/* overallocate, to avoid reallocations */
if (need<2*outlen)
need = 2*outlen;
- if (_PyBytes_Resize(&result, need)) {
+ if (_PyString_Resize(&result, need)) {
Py_DECREF(item);
return NULL;
}
outlen = need;
}
memcpy(
- PyBytes_AS_STRING(result) + j,
- PyBytes_AS_STRING(item),
+ PyString_AS_STRING(result) + j,
+ PyString_AS_STRING(item),
reslen
);
j += reslen;
@@ -2815,7 +2815,7 @@ filterstring(PyObject *func, PyObject *strobj)
}
if (j < outlen)
- _PyBytes_Resize(&result, j);
+ _PyString_Resize(&result, j);
return result;
diff --git a/Python/ceval.c b/Python/ceval.c
index bf48255..0cff157 100644
--- a/Python/ceval.c
+++ b/Python/ceval.c
@@ -739,7 +739,7 @@ PyEval_EvalFrameEx(PyFrameObject *f, int throwflag)
consts = co->co_consts;
fastlocals = f->f_localsplus;
freevars = f->f_localsplus + co->co_nlocals;
- first_instr = (unsigned char*) PyBytes_AS_STRING(co->co_code);
+ first_instr = (unsigned char*) PyString_AS_STRING(co->co_code);
/* An explanation is in order for the next line.
f->f_lasti now refers to the index of the last instruction
@@ -766,7 +766,7 @@ PyEval_EvalFrameEx(PyFrameObject *f, int throwflag)
lltrace = PyDict_GetItemString(f->f_globals, "__lltrace__") != NULL;
#endif
#if defined(Py_DEBUG) || defined(LLTRACE)
- filename = PyBytes_AsString(co->co_filename);
+ filename = PyString_AsString(co->co_filename);
#endif
why = WHY_NOT;
@@ -1147,8 +1147,8 @@ PyEval_EvalFrameEx(PyFrameObject *f, int throwflag)
goto slow_add;
x = PyInt_FromLong(i);
}
- else if (PyBytes_CheckExact(v) &&
- PyBytes_CheckExact(w)) {
+ else if (PyString_CheckExact(v) &&
+ PyString_CheckExact(w)) {
x = string_concatenate(v, w, f, next_instr);
/* string_concatenate consumed the ref to v */
goto skip_decref_vx;
@@ -1349,8 +1349,8 @@ PyEval_EvalFrameEx(PyFrameObject *f, int throwflag)
goto slow_iadd;
x = PyInt_FromLong(i);
}
- else if (PyBytes_CheckExact(v) &&
- PyBytes_CheckExact(w)) {
+ else if (PyString_CheckExact(v) &&
+ PyString_CheckExact(w)) {
x = string_concatenate(v, w, f, next_instr);
/* string_concatenate consumed the ref to v */
goto skip_decref_v;
@@ -1576,9 +1576,9 @@ PyEval_EvalFrameEx(PyFrameObject *f, int throwflag)
err = PyFile_WriteObject(v, w, Py_PRINT_RAW);
if (err == 0) {
/* XXX move into writeobject() ? */
- if (PyBytes_Check(v)) {
- char *s = PyBytes_AS_STRING(v);
- Py_ssize_t len = PyBytes_GET_SIZE(v);
+ if (PyString_Check(v)) {
+ char *s = PyString_AS_STRING(v);
+ Py_ssize_t len = PyString_GET_SIZE(v);
if (len == 0 ||
!isspace(Py_CHARMASK(s[len-1])) ||
s[len-1] == ' ')
@@ -1705,7 +1705,7 @@ PyEval_EvalFrameEx(PyFrameObject *f, int throwflag)
retval = POP();
}
else if (PyExceptionClass_Check(v) ||
- PyBytes_Check(v)) {
+ PyString_Check(v)) {
w = POP();
u = POP();
PyErr_Restore(v, w, u);
@@ -1869,11 +1869,11 @@ PyEval_EvalFrameEx(PyFrameObject *f, int throwflag)
case LOAD_GLOBAL:
w = GETITEM(names, oparg);
- if (PyBytes_CheckExact(w)) {
+ if (PyString_CheckExact(w)) {
/* Inline the PyDict_GetItem() calls.
WARNING: this is an extreme speed hack.
Do not try this at home. */
- long hash = ((PyBytesObject *)w)->ob_shash;
+ long hash = ((PyStringObject *)w)->ob_shash;
if (hash != -1) {
PyDictObject *d;
PyDictEntry *e;
@@ -2726,7 +2726,7 @@ PyEval_EvalCodeEx(PyCodeObject *co, PyObject *globals, PyObject *locals,
PyErr_Format(PyExc_TypeError,
"%.200s() takes %s %d "
"%sargument%s (%d given)",
- PyBytes_AsString(co->co_name),
+ PyString_AsString(co->co_name),
defcount ? "at most" : "exactly",
co->co_argcount,
kwcount ? "non-keyword " : "",
@@ -2756,10 +2756,10 @@ PyEval_EvalCodeEx(PyCodeObject *co, PyObject *globals, PyObject *locals,
PyObject *keyword = kws[2*i];
PyObject *value = kws[2*i + 1];
int j;
- if (keyword == NULL || !PyBytes_Check(keyword)) {
+ if (keyword == NULL || !PyString_Check(keyword)) {
PyErr_Format(PyExc_TypeError,
"%.200s() keywords must be strings",
- PyBytes_AsString(co->co_name));
+ PyString_AsString(co->co_name));
goto fail;
}
/* XXX slow -- speed up using dictionary? */
@@ -2781,8 +2781,8 @@ PyEval_EvalCodeEx(PyCodeObject *co, PyObject *globals, PyObject *locals,
PyErr_Format(PyExc_TypeError,
"%.200s() got an unexpected "
"keyword argument '%.400s'",
- PyBytes_AsString(co->co_name),
- PyBytes_AsString(keyword));
+ PyString_AsString(co->co_name),
+ PyString_AsString(keyword));
goto fail;
}
PyDict_SetItem(kwdict, keyword, value);
@@ -2793,8 +2793,8 @@ PyEval_EvalCodeEx(PyCodeObject *co, PyObject *globals, PyObject *locals,
"%.200s() got multiple "
"values for keyword "
"argument '%.400s'",
- PyBytes_AsString(co->co_name),
- PyBytes_AsString(keyword));
+ PyString_AsString(co->co_name),
+ PyString_AsString(keyword));
goto fail;
}
Py_INCREF(value);
@@ -2808,7 +2808,7 @@ PyEval_EvalCodeEx(PyCodeObject *co, PyObject *globals, PyObject *locals,
PyErr_Format(PyExc_TypeError,
"%.200s() takes %s %d "
"%sargument%s (%d given)",
- PyBytes_AsString(co->co_name),
+ PyString_AsString(co->co_name),
((co->co_flags & CO_VARARGS) ||
defcount) ? "at least"
: "exactly",
@@ -2834,7 +2834,7 @@ PyEval_EvalCodeEx(PyCodeObject *co, PyObject *globals, PyObject *locals,
if (argcount > 0 || kwcount > 0) {
PyErr_Format(PyExc_TypeError,
"%.200s() takes no arguments (%d given)",
- PyBytes_AsString(co->co_name),
+ PyString_AsString(co->co_name),
argcount + kwcount);
goto fail;
}
@@ -2860,11 +2860,11 @@ PyEval_EvalCodeEx(PyCodeObject *co, PyObject *globals, PyObject *locals,
list so that we can march over it more efficiently?
*/
for (i = 0; i < PyTuple_GET_SIZE(co->co_cellvars); ++i) {
- cellname = PyBytes_AS_STRING(
+ cellname = PyString_AS_STRING(
PyTuple_GET_ITEM(co->co_cellvars, i));
found = 0;
for (j = 0; j < nargs; j++) {
- argname = PyBytes_AS_STRING(
+ argname = PyString_AS_STRING(
PyTuple_GET_ITEM(co->co_varnames, j));
if (strcmp(cellname, argname) == 0) {
c = PyCell_New(GETLOCAL(j));
@@ -3522,13 +3522,13 @@ PyEval_GetFuncName(PyObject *func)
if (PyMethod_Check(func))
return PyEval_GetFuncName(PyMethod_GET_FUNCTION(func));
else if (PyFunction_Check(func))
- return PyBytes_AsString(((PyFunctionObject*)func)->func_name);
+ return PyString_AsString(((PyFunctionObject*)func)->func_name);
else if (PyCFunction_Check(func))
return ((PyCFunctionObject*)func)->m_ml->ml_name;
else if (PyClass_Check(func))
- return PyBytes_AsString(((PyClassObject*)func)->cl_name);
+ return PyString_AsString(((PyClassObject*)func)->cl_name);
else if (PyInstance_Check(func)) {
- return PyBytes_AsString(
+ return PyString_AsString(
((PyInstanceObject*)func)->in_class->cl_name);
} else {
return func->ob_type->tp_name;
@@ -3767,7 +3767,7 @@ update_keyword_args(PyObject *orig_kwdict, int nk, PyObject ***pp_stack,
"for keyword argument '%.200s'",
PyEval_GetFuncName(func),
PyEval_GetFuncDesc(func),
- PyBytes_AsString(key));
+ PyString_AsString(key));
Py_DECREF(key);
Py_DECREF(value);
Py_DECREF(kwdict);
@@ -4086,7 +4086,7 @@ cmp_outcome(int op, register PyObject *v, register PyObject *w)
length = PyTuple_Size(w);
for (i = 0; i < length; i += 1) {
PyObject *exc = PyTuple_GET_ITEM(w, i);
- if (PyBytes_Check(exc)) {
+ if (PyString_Check(exc)) {
int ret_val;
ret_val = PyErr_WarnEx(
PyExc_DeprecationWarning,
@@ -4109,7 +4109,7 @@ cmp_outcome(int op, register PyObject *v, register PyObject *w)
}
}
else {
- if (PyBytes_Check(w)) {
+ if (PyString_Check(w)) {
int ret_val;
ret_val = PyErr_WarnEx(
PyExc_DeprecationWarning,
@@ -4149,7 +4149,7 @@ import_from(PyObject *v, PyObject *name)
if (x == NULL && PyErr_ExceptionMatches(PyExc_AttributeError)) {
PyErr_Format(PyExc_ImportError,
"cannot import name %.230s",
- PyBytes_AsString(name));
+ PyString_AsString(name));
}
return x;
}
@@ -4191,8 +4191,8 @@ import_all_from(PyObject *locals, PyObject *v)
break;
}
if (skip_leading_underscores &&
- PyBytes_Check(name) &&
- PyBytes_AS_STRING(name)[0] == '_')
+ PyString_Check(name) &&
+ PyString_AS_STRING(name)[0] == '_')
{
Py_DECREF(name);
continue;
@@ -4251,12 +4251,12 @@ build_class(PyObject *methods, PyObject *bases, PyObject *name)
PyObject *ptype, *pvalue, *ptraceback;
PyErr_Fetch(&ptype, &pvalue, &ptraceback);
- if (PyBytes_Check(pvalue)) {
+ if (PyString_Check(pvalue)) {
PyObject *newmsg;
- newmsg = PyBytes_FromFormat(
+ newmsg = PyString_FromFormat(
"Error when calling the metaclass bases\n"
" %s",
- PyBytes_AS_STRING(pvalue));
+ PyString_AS_STRING(pvalue));
if (newmsg != NULL) {
Py_DECREF(pvalue);
pvalue = newmsg;
@@ -4297,7 +4297,7 @@ exec_statement(PyFrameObject *f, PyObject *prog, PyObject *globals,
}
else if (locals == Py_None)
locals = globals;
- if (!PyBytes_Check(prog) &&
+ if (!PyString_Check(prog) &&
!PyUnicode_Check(prog) &&
!PyCode_Check(prog) &&
!PyFile_Check(prog)) {
@@ -4327,7 +4327,7 @@ exec_statement(PyFrameObject *f, PyObject *prog, PyObject *globals,
}
else if (PyFile_Check(prog)) {
FILE *fp = PyFile_AsFile(prog);
- char *name = PyBytes_AsString(PyFile_Name(prog));
+ char *name = PyString_AsString(PyFile_Name(prog));
PyCompilerFlags cf;
if (name == NULL)
return -1;
@@ -4353,7 +4353,7 @@ exec_statement(PyFrameObject *f, PyObject *prog, PyObject *globals,
cf.cf_flags |= PyCF_SOURCE_IS_UTF8;
}
#endif
- if (PyBytes_AsStringAndSize(prog, &str, NULL))
+ if (PyString_AsStringAndSize(prog, &str, NULL))
return -1;
if (PyEval_MergeCompilerFlags(&cf))
v = PyRun_StringFlags(str, Py_file_input, globals,
@@ -4378,7 +4378,7 @@ format_exc_check_arg(PyObject *exc, char *format_str, PyObject *obj)
if (!obj)
return;
- obj_str = PyBytes_AsString(obj);
+ obj_str = PyString_AsString(obj);
if (!obj_str)
return;
@@ -4391,8 +4391,8 @@ string_concatenate(PyObject *v, PyObject *w,
{
/* This function implements 'variable += expr' when both arguments
are strings. */
- Py_ssize_t v_len = PyBytes_GET_SIZE(v);
- Py_ssize_t w_len = PyBytes_GET_SIZE(w);
+ Py_ssize_t v_len = PyString_GET_SIZE(v);
+ Py_ssize_t w_len = PyString_GET_SIZE(w);
Py_ssize_t new_len = v_len + w_len;
if (new_len < 0) {
PyErr_SetString(PyExc_OverflowError,
@@ -4441,12 +4441,12 @@ string_concatenate(PyObject *v, PyObject *w,
}
}
- if (v->ob_refcnt == 1 && !PyBytes_CHECK_INTERNED(v)) {
+ if (v->ob_refcnt == 1 && !PyString_CHECK_INTERNED(v)) {
/* Now we own the last reference to 'v', so we can resize it
* in-place.
*/
- if (_PyBytes_Resize(&v, new_len) != 0) {
- /* XXX if _PyBytes_Resize() fails, 'v' has been
+ if (_PyString_Resize(&v, new_len) != 0) {
+ /* XXX if _PyString_Resize() fails, 'v' has been
* deallocated so it cannot be put back into
* 'variable'. The MemoryError is raised when there
* is no value in 'variable', which might (very
@@ -4455,13 +4455,13 @@ string_concatenate(PyObject *v, PyObject *w,
return NULL;
}
/* copy 'w' into the newly allocated area of 'v' */
- memcpy(PyBytes_AS_STRING(v) + v_len,
- PyBytes_AS_STRING(w), w_len);
+ memcpy(PyString_AS_STRING(v) + v_len,
+ PyString_AS_STRING(w), w_len);
return v;
}
else {
/* When in-place resizing is not an option. */
- PyBytes_Concat(&v, w);
+ PyString_Concat(&v, w);
return v;
}
}
diff --git a/Python/codecs.c b/Python/codecs.c
index 0e8cdc7..4b0f4cb 100644
--- a/Python/codecs.c
+++ b/Python/codecs.c
@@ -61,10 +61,10 @@ PyObject *normalizestring(const char *string)
return NULL;
}
- v = PyBytes_FromStringAndSize(NULL, len);
+ v = PyString_FromStringAndSize(NULL, len);
if (v == NULL)
return NULL;
- p = PyBytes_AS_STRING(v);
+ p = PyString_AS_STRING(v);
for (i = 0; i < len; i++) {
register char ch = string[i];
if (ch == ' ')
@@ -112,7 +112,7 @@ PyObject *_PyCodec_Lookup(const char *encoding)
v = normalizestring(encoding);
if (v == NULL)
goto onError;
- PyBytes_InternInPlace(&v);
+ PyString_InternInPlace(&v);
/* First, try to lookup the name in the registry dictionary */
result = PyDict_GetItem(interp->codec_search_cache, v);
@@ -190,7 +190,7 @@ PyObject *args_tuple(PyObject *object,
if (errors) {
PyObject *v;
- v = PyBytes_FromString(errors);
+ v = PyString_FromString(errors);
if (v == NULL) {
Py_DECREF(args);
return NULL;
@@ -451,7 +451,7 @@ static void wrong_exception_type(PyObject *exc)
if (string != NULL) {
PyErr_Format(PyExc_TypeError,
"don't know how to handle %.400s in error callback",
- PyBytes_AS_STRING(string));
+ PyString_AS_STRING(string));
Py_DECREF(string);
}
}
diff --git a/Python/compile.c b/Python/compile.c
index 5092acc..c81218d 100644
--- a/Python/compile.c
+++ b/Python/compile.c
@@ -184,15 +184,15 @@ _Py_Mangle(PyObject *privateobj, PyObject *ident)
{
/* Name mangling: __private becomes _classname__private.
This is independent from how the name is used. */
- const char *p, *name = PyBytes_AsString(ident);
+ const char *p, *name = PyString_AsString(ident);
char *buffer;
size_t nlen, plen;
- if (privateobj == NULL || !PyBytes_Check(privateobj) ||
+ if (privateobj == NULL || !PyString_Check(privateobj) ||
name == NULL || name[0] != '_' || name[1] != '_') {
Py_INCREF(ident);
return ident;
}
- p = PyBytes_AsString(privateobj);
+ p = PyString_AsString(privateobj);
nlen = strlen(name);
/* Don't mangle __id__ or names with dots.
@@ -216,11 +216,11 @@ _Py_Mangle(PyObject *privateobj, PyObject *ident)
return ident; /* Don't mangle if class is just underscores */
}
plen = strlen(p);
- ident = PyBytes_FromStringAndSize(NULL, 1 + nlen + plen);
+ ident = PyString_FromStringAndSize(NULL, 1 + nlen + plen);
if (!ident)
return 0;
/* ident = "_" + p[:plen] + name # i.e. 1+plen+nlen bytes */
- buffer = PyBytes_AS_STRING(ident);
+ buffer = PyString_AS_STRING(ident);
buffer[0] = '_';
strncpy(buffer+1, p, plen);
strcpy(buffer+1+plen, name);
@@ -249,7 +249,7 @@ PyAST_Compile(mod_ty mod, const char *filename, PyCompilerFlags *flags,
int merged;
if (!__doc__) {
- __doc__ = PyBytes_InternFromString("__doc__");
+ __doc__ = PyString_InternFromString("__doc__");
if (!__doc__)
return NULL;
}
@@ -540,7 +540,7 @@ compiler_new_tmpname(struct compiler *c)
{
char tmpname[256];
PyOS_snprintf(tmpname, sizeof(tmpname), "_[%d]", ++c->u->u_tmpname);
- return PyBytes_FromString(tmpname);
+ return PyString_FromString(tmpname);
}
/* Allocate a new block and return a pointer to it.
@@ -1193,7 +1193,7 @@ compiler_mod(struct compiler *c, mod_ty mod)
int addNone = 1;
static PyObject *module;
if (!module) {
- module = PyBytes_InternFromString("<module>");
+ module = PyString_InternFromString("<module>");
if (!module)
return NULL;
}
@@ -1245,8 +1245,8 @@ get_ref_type(struct compiler *c, PyObject *name)
PyOS_snprintf(buf, sizeof(buf),
"unknown scope for %.100s in %.100s(%s) in %s\n"
"symbols: %s\nlocals: %s\nglobals: %s\n",
- PyBytes_AS_STRING(name),
- PyBytes_AS_STRING(c->u->u_name),
+ PyString_AS_STRING(name),
+ PyString_AS_STRING(c->u->u_name),
PyObject_REPR(c->u->u_ste->ste_id),
c->c_filename,
PyObject_REPR(c->u->u_ste->ste_symbols),
@@ -1304,9 +1304,9 @@ compiler_make_closure(struct compiler *c, PyCodeObject *co, int args)
printf("lookup %s in %s %d %d\n"
"freevars of %s: %s\n",
PyObject_REPR(name),
- PyBytes_AS_STRING(c->u->u_name),
+ PyString_AS_STRING(c->u->u_name),
reftype, arg,
- PyBytes_AS_STRING(co->co_name),
+ PyString_AS_STRING(co->co_name),
PyObject_REPR(co->co_freevars));
Py_FatalError("compiler_make_closure()");
}
@@ -1341,7 +1341,7 @@ compiler_arguments(struct compiler *c, arguments_ty args)
for (i = 0; i < n; i++) {
expr_ty arg = (expr_ty)asdl_seq_GET(args->args, i);
if (arg->kind == Tuple_kind) {
- PyObject *id = PyBytes_FromFormat(".%d", i);
+ PyObject *id = PyString_FromFormat(".%d", i);
if (id == NULL) {
return 0;
}
@@ -1434,7 +1434,7 @@ compiler_class(struct compiler *c, stmt_ty s)
Py_XDECREF(c->u->u_private);
c->u->u_private = s->v.ClassDef.name;
Py_INCREF(c->u->u_private);
- str = PyBytes_InternFromString("__name__");
+ str = PyString_InternFromString("__name__");
if (!str || !compiler_nameop(c, str, Load)) {
Py_XDECREF(str);
compiler_exit_scope(c);
@@ -1442,7 +1442,7 @@ compiler_class(struct compiler *c, stmt_ty s)
}
Py_DECREF(str);
- str = PyBytes_InternFromString("__module__");
+ str = PyString_InternFromString("__module__");
if (!str || !compiler_nameop(c, str, Store)) {
Py_XDECREF(str);
compiler_exit_scope(c);
@@ -1509,7 +1509,7 @@ compiler_lambda(struct compiler *c, expr_ty e)
assert(e->kind == Lambda_kind);
if (!name) {
- name = PyBytes_InternFromString("<lambda>");
+ name = PyString_InternFromString("<lambda>");
if (!name)
return 0;
}
@@ -1899,7 +1899,7 @@ compiler_import_as(struct compiler *c, identifier name, identifier asname)
If there is a dot in name, we need to split it and emit a
LOAD_ATTR for each name.
*/
- const char *src = PyBytes_AS_STRING(name);
+ const char *src = PyString_AS_STRING(name);
const char *dot = strchr(src, '.');
if (dot) {
/* Consume the base module name to get the first attribute */
@@ -1908,7 +1908,7 @@ compiler_import_as(struct compiler *c, identifier name, identifier asname)
/* NB src is only defined when dot != NULL */
PyObject *attr;
dot = strchr(src, '.');
- attr = PyBytes_FromStringAndSize(src,
+ attr = PyString_FromStringAndSize(src,
dot ? dot - src : strlen(src));
if (!attr)
return -1;
@@ -1957,10 +1957,10 @@ compiler_import(struct compiler *c, stmt_ty s)
}
else {
identifier tmp = alias->name;
- const char *base = PyBytes_AS_STRING(alias->name);
+ const char *base = PyString_AS_STRING(alias->name);
char *dot = strchr(base, '.');
if (dot)
- tmp = PyBytes_FromStringAndSize(base,
+ tmp = PyString_FromStringAndSize(base,
dot - base);
r = compiler_nameop(c, tmp, Store);
if (dot) {
@@ -2003,7 +2003,7 @@ compiler_from_import(struct compiler *c, stmt_ty s)
}
if (s->lineno > c->c_future->ff_lineno) {
- if (!strcmp(PyBytes_AS_STRING(s->v.ImportFrom.module),
+ if (!strcmp(PyString_AS_STRING(s->v.ImportFrom.module),
"__future__")) {
Py_DECREF(level);
Py_DECREF(names);
@@ -2023,7 +2023,7 @@ compiler_from_import(struct compiler *c, stmt_ty s)
alias_ty alias = (alias_ty)asdl_seq_GET(s->v.ImportFrom.names, i);
identifier store_name;
- if (i == 0 && *PyBytes_AS_STRING(alias->name) == '*') {
+ if (i == 0 && *PyString_AS_STRING(alias->name) == '*') {
assert(n == 1);
ADDOP(c, IMPORT_STAR);
return 1;
@@ -2053,7 +2053,7 @@ compiler_assert(struct compiler *c, stmt_ty s)
if (Py_OptimizeFlag)
return 1;
if (assertion_error == NULL) {
- assertion_error = PyBytes_InternFromString("AssertionError");
+ assertion_error = PyString_InternFromString("AssertionError");
if (assertion_error == NULL)
return 0;
}
@@ -2336,7 +2336,7 @@ compiler_nameop(struct compiler *c, identifier name, expr_context_ty ctx)
/* First check for assignment to __debug__. Param? */
if ((ctx == Store || ctx == AugStore || ctx == Del)
- && !strcmp(PyBytes_AS_STRING(name), "__debug__")) {
+ && !strcmp(PyString_AS_STRING(name), "__debug__")) {
return compiler_error(c, "can not assign to __debug__");
}
@@ -2374,7 +2374,7 @@ compiler_nameop(struct compiler *c, identifier name, expr_context_ty ctx)
}
/* XXX Leave assert here, but handle __doc__ and the like better */
- assert(scope || PyBytes_AS_STRING(name)[0] == '_');
+ assert(scope || PyString_AS_STRING(name)[0] == '_');
switch (optype) {
case OP_DEREF:
@@ -2388,7 +2388,7 @@ compiler_nameop(struct compiler *c, identifier name, expr_context_ty ctx)
PyErr_Format(PyExc_SyntaxError,
"can not delete variable '%s' referenced "
"in nested scope",
- PyBytes_AS_STRING(name));
+ PyString_AS_STRING(name));
Py_DECREF(mangled);
return 0;
case Param:
@@ -2773,7 +2773,7 @@ compiler_genexp(struct compiler *c, expr_ty e)
0)))->iter;
if (!name) {
- name = PyBytes_FromString("<genexpr>");
+ name = PyString_FromString("<genexpr>");
if (!name)
return 0;
}
@@ -2822,7 +2822,7 @@ expr_constant(expr_ty e)
case Name_kind:
/* __debug__ is not assignable, so we can optimize
* it away in if and while statements */
- if (strcmp(PyBytes_AS_STRING(e->v.Name.id),
+ if (strcmp(PyString_AS_STRING(e->v.Name.id),
"__debug__") == 0)
return ! Py_OptimizeFlag;
/* fall through */
@@ -2864,12 +2864,12 @@ compiler_with(struct compiler *c, stmt_ty s)
assert(s->kind == With_kind);
if (!enter_attr) {
- enter_attr = PyBytes_InternFromString("__enter__");
+ enter_attr = PyString_InternFromString("__enter__");
if (!enter_attr)
return 0;
}
if (!exit_attr) {
- exit_attr = PyBytes_InternFromString("__exit__");
+ exit_attr = PyString_InternFromString("__exit__");
if (!exit_attr)
return 0;
}
@@ -3472,10 +3472,10 @@ assemble_init(struct assembler *a, int nblocks, int firstlineno)
{
memset(a, 0, sizeof(struct assembler));
a->a_lineno = firstlineno;
- a->a_bytecode = PyBytes_FromStringAndSize(NULL, DEFAULT_CODE_SIZE);
+ a->a_bytecode = PyString_FromStringAndSize(NULL, DEFAULT_CODE_SIZE);
if (!a->a_bytecode)
return 0;
- a->a_lnotab = PyBytes_FromStringAndSize(NULL, DEFAULT_LNOTAB_SIZE);
+ a->a_lnotab = PyString_FromStringAndSize(NULL, DEFAULT_LNOTAB_SIZE);
if (!a->a_lnotab)
return 0;
a->a_postorder = (basicblock **)PyObject_Malloc(
@@ -3584,17 +3584,17 @@ assemble_lnotab(struct assembler *a, struct instr *i)
if (d_bytecode > 255) {
int j, nbytes, ncodes = d_bytecode / 255;
nbytes = a->a_lnotab_off + 2 * ncodes;
- len = PyBytes_GET_SIZE(a->a_lnotab);
+ len = PyString_GET_SIZE(a->a_lnotab);
if (nbytes >= len) {
if (len * 2 < nbytes)
len = nbytes;
else
len *= 2;
- if (_PyBytes_Resize(&a->a_lnotab, len) < 0)
+ if (_PyString_Resize(&a->a_lnotab, len) < 0)
return 0;
}
lnotab = (unsigned char *)
- PyBytes_AS_STRING(a->a_lnotab) + a->a_lnotab_off;
+ PyString_AS_STRING(a->a_lnotab) + a->a_lnotab_off;
for (j = 0; j < ncodes; j++) {
*lnotab++ = 255;
*lnotab++ = 0;
@@ -3606,17 +3606,17 @@ assemble_lnotab(struct assembler *a, struct instr *i)
if (d_lineno > 255) {
int j, nbytes, ncodes = d_lineno / 255;
nbytes = a->a_lnotab_off + 2 * ncodes;
- len = PyBytes_GET_SIZE(a->a_lnotab);
+ len = PyString_GET_SIZE(a->a_lnotab);
if (nbytes >= len) {
if (len * 2 < nbytes)
len = nbytes;
else
len *= 2;
- if (_PyBytes_Resize(&a->a_lnotab, len) < 0)
+ if (_PyString_Resize(&a->a_lnotab, len) < 0)
return 0;
}
lnotab = (unsigned char *)
- PyBytes_AS_STRING(a->a_lnotab) + a->a_lnotab_off;
+ PyString_AS_STRING(a->a_lnotab) + a->a_lnotab_off;
*lnotab++ = d_bytecode;
*lnotab++ = 255;
d_bytecode = 0;
@@ -3628,13 +3628,13 @@ assemble_lnotab(struct assembler *a, struct instr *i)
a->a_lnotab_off += ncodes * 2;
}
- len = PyBytes_GET_SIZE(a->a_lnotab);
+ len = PyString_GET_SIZE(a->a_lnotab);
if (a->a_lnotab_off + 2 >= len) {
- if (_PyBytes_Resize(&a->a_lnotab, len * 2) < 0)
+ if (_PyString_Resize(&a->a_lnotab, len * 2) < 0)
return 0;
}
lnotab = (unsigned char *)
- PyBytes_AS_STRING(a->a_lnotab) + a->a_lnotab_off;
+ PyString_AS_STRING(a->a_lnotab) + a->a_lnotab_off;
a->a_lnotab_off += 2;
if (d_bytecode) {
@@ -3659,7 +3659,7 @@ static int
assemble_emit(struct assembler *a, struct instr *i)
{
int size, arg = 0, ext = 0;
- Py_ssize_t len = PyBytes_GET_SIZE(a->a_bytecode);
+ Py_ssize_t len = PyString_GET_SIZE(a->a_bytecode);
char *code;
size = instrsize(i);
@@ -3670,10 +3670,10 @@ assemble_emit(struct assembler *a, struct instr *i)
if (i->i_lineno && !assemble_lnotab(a, i))
return 0;
if (a->a_offset + size >= len) {
- if (_PyBytes_Resize(&a->a_bytecode, len * 2) < 0)
+ if (_PyString_Resize(&a->a_bytecode, len * 2) < 0)
return 0;
}
- code = PyBytes_AS_STRING(a->a_bytecode) + a->a_offset;
+ code = PyString_AS_STRING(a->a_bytecode) + a->a_offset;
a->a_offset += size;
if (size == 6) {
assert(i->i_hasarg);
@@ -3846,7 +3846,7 @@ makecode(struct compiler *c, struct assembler *a)
freevars = dict_keys_inorder(c->u->u_freevars, PyTuple_Size(cellvars));
if (!freevars)
goto error;
- filename = PyBytes_FromString(c->c_filename);
+ filename = PyString_FromString(c->c_filename);
if (!filename)
goto error;
@@ -3966,9 +3966,9 @@ assemble(struct compiler *c, int addNone)
goto error;
}
- if (_PyBytes_Resize(&a.a_lnotab, a.a_lnotab_off) < 0)
+ if (_PyString_Resize(&a.a_lnotab, a.a_lnotab_off) < 0)
goto error;
- if (_PyBytes_Resize(&a.a_bytecode, a.a_offset) < 0)
+ if (_PyString_Resize(&a.a_bytecode, a.a_offset) < 0)
goto error;
co = makecode(c, &a);
diff --git a/Python/errors.c b/Python/errors.c
index 8b04c34..8951d57 100644
--- a/Python/errors.c
+++ b/Python/errors.c
@@ -66,7 +66,7 @@ PyErr_SetNone(PyObject *exception)
void
PyErr_SetString(PyObject *exception, const char *string)
{
- PyObject *value = PyBytes_FromString(string);
+ PyObject *value = PyString_FromString(string);
PyErr_SetObject(exception, value);
Py_XDECREF(value);
}
@@ -351,7 +351,7 @@ PyErr_SetFromErrnoWithFilenameObject(PyObject *exc, PyObject *filenameObject)
PyObject *
PyErr_SetFromErrnoWithFilename(PyObject *exc, char *filename)
{
- PyObject *name = filename ? PyBytes_FromString(filename) : NULL;
+ PyObject *name = filename ? PyString_FromString(filename) : NULL;
PyObject *result = PyErr_SetFromErrnoWithFilenameObject(exc, name);
Py_XDECREF(name);
return result;
@@ -430,7 +430,7 @@ PyObject *PyErr_SetExcFromWindowsErrWithFilename(
int ierr,
const char *filename)
{
- PyObject *name = filename ? PyBytes_FromString(filename) : NULL;
+ PyObject *name = filename ? PyString_FromString(filename) : NULL;
PyObject *ret = PyErr_SetExcFromWindowsErrWithFilenameObject(exc,
ierr,
name);
@@ -469,7 +469,7 @@ PyObject *PyErr_SetFromWindowsErrWithFilename(
int ierr,
const char *filename)
{
- PyObject *name = filename ? PyBytes_FromString(filename) : NULL;
+ PyObject *name = filename ? PyString_FromString(filename) : NULL;
PyObject *result = PyErr_SetExcFromWindowsErrWithFilenameObject(
PyExc_WindowsError,
ierr, name);
@@ -527,7 +527,7 @@ PyErr_Format(PyObject *exception, const char *format, ...)
va_start(vargs);
#endif
- string = PyBytes_FromFormatV(format, vargs);
+ string = PyString_FromFormatV(format, vargs);
PyErr_SetObject(exception, string);
Py_XDECREF(string);
va_end(vargs);
@@ -559,7 +559,7 @@ PyErr_NewException(char *name, PyObject *base, PyObject *dict)
goto failure;
}
if (PyDict_GetItemString(dict, "__module__") == NULL) {
- modulename = PyBytes_FromStringAndSize(name,
+ modulename = PyString_FromStringAndSize(name,
(Py_ssize_t)(dot-name));
if (modulename == NULL)
goto failure;
@@ -611,7 +611,7 @@ PyErr_WriteUnraisable(PyObject *obj)
if (moduleName == NULL)
PyFile_WriteString("<unknown>", f);
else {
- char* modstr = PyBytes_AsString(moduleName);
+ char* modstr = PyString_AsString(moduleName);
if (modstr &&
strcmp(modstr, "exceptions") != 0)
{
@@ -665,7 +665,7 @@ PyErr_SyntaxLocation(const char *filename, int lineno)
Py_DECREF(tmp);
}
if (filename != NULL) {
- tmp = PyBytes_FromString(filename);
+ tmp = PyString_FromString(filename);
if (tmp == NULL)
PyErr_Clear();
else {
@@ -742,7 +742,7 @@ PyErr_ProgramText(const char *filename, int lineno)
char *p = linebuf;
while (*p == ' ' || *p == '\t' || *p == '\014')
p++;
- return PyBytes_FromString(p);
+ return PyString_FromString(p);
}
return NULL;
}
diff --git a/Python/future.c b/Python/future.c
index ba058b8..2c6aaa2 100644
--- a/Python/future.c
+++ b/Python/future.c
@@ -20,7 +20,7 @@ future_check_features(PyFutureFeatures *ff, stmt_ty s, const char *filename)
names = s->v.ImportFrom.names;
for (i = 0; i < asdl_seq_LEN(names); i++) {
alias_ty name = (alias_ty)asdl_seq_GET(names, i);
- const char *feature = PyBytes_AsString(name->name);
+ const char *feature = PyString_AsString(name->name);
if (!feature)
return 0;
if (strcmp(feature, FUTURE_NESTED_SCOPES) == 0) {
@@ -59,7 +59,7 @@ future_parse(PyFutureFeatures *ff, mod_ty mod, const char *filename)
static PyObject *future;
if (!future) {
- future = PyBytes_InternFromString("__future__");
+ future = PyString_InternFromString("__future__");
if (!future)
return 0;
}
diff --git a/Python/getargs.c b/Python/getargs.c
index 3b8950c..162cf6f 100644
--- a/Python/getargs.c
+++ b/Python/getargs.c
@@ -418,7 +418,7 @@ converttuple(PyObject *arg, const char **p_format, va_list *p_va, int flags,
n++;
}
- if (!PySequence_Check(arg) || PyBytes_Check(arg)) {
+ if (!PySequence_Check(arg) || PyString_Check(arg)) {
levels[0] = 0;
PyOS_snprintf(msgbuf, bufsize,
toplevel ? "expected %d arguments, not %.50s" :
@@ -765,8 +765,8 @@ convertsimple(PyObject *arg, const char **p_format, va_list *p_va, int flags,
case 'c': {/* char */
char *p = va_arg(*p_va, char *);
- if (PyBytes_Check(arg) && PyBytes_Size(arg) == 1)
- *p = PyBytes_AS_STRING(arg)[0];
+ if (PyString_Check(arg) && PyString_Size(arg) == 1)
+ *p = PyString_AS_STRING(arg)[0];
else
return converterr("char", arg, msgbuf, bufsize);
break;
@@ -777,9 +777,9 @@ convertsimple(PyObject *arg, const char **p_format, va_list *p_va, int flags,
void **p = (void **)va_arg(*p_va, char **);
FETCH_SIZE;
- if (PyBytes_Check(arg)) {
- *p = PyBytes_AS_STRING(arg);
- STORE_SIZE(PyBytes_GET_SIZE(arg));
+ if (PyString_Check(arg)) {
+ *p = PyString_AS_STRING(arg);
+ STORE_SIZE(PyString_GET_SIZE(arg));
}
#ifdef Py_USING_UNICODE
else if (PyUnicode_Check(arg)) {
@@ -787,8 +787,8 @@ convertsimple(PyObject *arg, const char **p_format, va_list *p_va, int flags,
if (uarg == NULL)
return converterr(CONV_UNICODE,
arg, msgbuf, bufsize);
- *p = PyBytes_AS_STRING(uarg);
- STORE_SIZE(PyBytes_GET_SIZE(uarg));
+ *p = PyString_AS_STRING(uarg);
+ STORE_SIZE(PyString_GET_SIZE(uarg));
}
#endif
else { /* any buffer-like object */
@@ -802,20 +802,20 @@ convertsimple(PyObject *arg, const char **p_format, va_list *p_va, int flags,
} else {
char **p = va_arg(*p_va, char **);
- if (PyBytes_Check(arg))
- *p = PyBytes_AS_STRING(arg);
+ if (PyString_Check(arg))
+ *p = PyString_AS_STRING(arg);
#ifdef Py_USING_UNICODE
else if (PyUnicode_Check(arg)) {
uarg = UNICODE_DEFAULT_ENCODING(arg);
if (uarg == NULL)
return converterr(CONV_UNICODE,
arg, msgbuf, bufsize);
- *p = PyBytes_AS_STRING(uarg);
+ *p = PyString_AS_STRING(uarg);
}
#endif
else
return converterr("string", arg, msgbuf, bufsize);
- if ((Py_ssize_t)strlen(*p) != PyBytes_Size(arg))
+ if ((Py_ssize_t)strlen(*p) != PyString_Size(arg))
return converterr("string without null bytes",
arg, msgbuf, bufsize);
}
@@ -831,9 +831,9 @@ convertsimple(PyObject *arg, const char **p_format, va_list *p_va, int flags,
*p = 0;
STORE_SIZE(0);
}
- else if (PyBytes_Check(arg)) {
- *p = PyBytes_AS_STRING(arg);
- STORE_SIZE(PyBytes_GET_SIZE(arg));
+ else if (PyString_Check(arg)) {
+ *p = PyString_AS_STRING(arg);
+ STORE_SIZE(PyString_GET_SIZE(arg));
}
#ifdef Py_USING_UNICODE
else if (PyUnicode_Check(arg)) {
@@ -841,8 +841,8 @@ convertsimple(PyObject *arg, const char **p_format, va_list *p_va, int flags,
if (uarg == NULL)
return converterr(CONV_UNICODE,
arg, msgbuf, bufsize);
- *p = PyBytes_AS_STRING(uarg);
- STORE_SIZE(PyBytes_GET_SIZE(uarg));
+ *p = PyString_AS_STRING(uarg);
+ STORE_SIZE(PyString_GET_SIZE(uarg));
}
#endif
else { /* any buffer-like object */
@@ -858,15 +858,15 @@ convertsimple(PyObject *arg, const char **p_format, va_list *p_va, int flags,
if (arg == Py_None)
*p = 0;
- else if (PyBytes_Check(arg))
- *p = PyBytes_AS_STRING(arg);
+ else if (PyString_Check(arg))
+ *p = PyString_AS_STRING(arg);
#ifdef Py_USING_UNICODE
else if (PyUnicode_Check(arg)) {
uarg = UNICODE_DEFAULT_ENCODING(arg);
if (uarg == NULL)
return converterr(CONV_UNICODE,
arg, msgbuf, bufsize);
- *p = PyBytes_AS_STRING(uarg);
+ *p = PyString_AS_STRING(uarg);
}
#endif
else
@@ -878,11 +878,11 @@ convertsimple(PyObject *arg, const char **p_format, va_list *p_va, int flags,
if (arg == Py_None)
*q = 0;
else
- *q = PyBytes_Size(arg);
+ *q = PyString_Size(arg);
format++;
}
else if (*p != NULL &&
- (Py_ssize_t)strlen(*p) != PyBytes_Size(arg))
+ (Py_ssize_t)strlen(*p) != PyString_Size(arg))
return converterr(
"string without null bytes or None",
arg, msgbuf, bufsize);
@@ -923,7 +923,7 @@ convertsimple(PyObject *arg, const char **p_format, va_list *p_va, int flags,
arg, msgbuf, bufsize);
/* Encode object */
- if (!recode_strings && PyBytes_Check(arg)) {
+ if (!recode_strings && PyString_Check(arg)) {
s = arg;
Py_INCREF(s);
}
@@ -946,7 +946,7 @@ convertsimple(PyObject *arg, const char **p_format, va_list *p_va, int flags,
if (s == NULL)
return converterr("(encoding failed)",
arg, msgbuf, bufsize);
- if (!PyBytes_Check(s)) {
+ if (!PyString_Check(s)) {
Py_DECREF(s);
return converterr(
"(encoder failed to return a string)",
@@ -956,7 +956,7 @@ convertsimple(PyObject *arg, const char **p_format, va_list *p_va, int flags,
return converterr("string<e>", arg, msgbuf, bufsize);
#endif
}
- size = PyBytes_GET_SIZE(s);
+ size = PyString_GET_SIZE(s);
/* Write output; output is guaranteed to be 0-terminated */
if (*format == '#') {
@@ -1013,7 +1013,7 @@ convertsimple(PyObject *arg, const char **p_format, va_list *p_va, int flags,
}
}
memcpy(*buffer,
- PyBytes_AS_STRING(s),
+ PyString_AS_STRING(s),
size + 1);
STORE_SIZE(size);
} else {
@@ -1030,7 +1030,7 @@ convertsimple(PyObject *arg, const char **p_format, va_list *p_va, int flags,
PyMem_Free()ing it after usage
*/
- if ((Py_ssize_t)strlen(PyBytes_AS_STRING(s))
+ if ((Py_ssize_t)strlen(PyString_AS_STRING(s))
!= size) {
Py_DECREF(s);
return converterr(
@@ -1049,7 +1049,7 @@ convertsimple(PyObject *arg, const char **p_format, va_list *p_va, int flags,
arg, msgbuf, bufsize);
}
memcpy(*buffer,
- PyBytes_AS_STRING(s),
+ PyString_AS_STRING(s),
size + 1);
}
Py_DECREF(s);
@@ -1083,7 +1083,7 @@ convertsimple(PyObject *arg, const char **p_format, va_list *p_va, int flags,
case 'S': { /* string object */
PyObject **p = va_arg(*p_va, PyObject **);
- if (PyBytes_Check(arg))
+ if (PyString_Check(arg))
*p = arg;
else
return converterr("string", arg, msgbuf, bufsize);
@@ -1473,12 +1473,12 @@ vgetargskeywords(PyObject *args, PyObject *keywords, const char *format,
while (PyDict_Next(keywords, &pos, &key, &value)) {
int match = 0;
char *ks;
- if (!PyBytes_Check(key)) {
+ if (!PyString_Check(key)) {
PyErr_SetString(PyExc_TypeError,
"keywords must be strings");
return cleanreturn(0, freelist);
}
- ks = PyBytes_AsString(key);
+ ks = PyString_AsString(key);
for (i = 0; i < len; i++) {
if (!strcmp(ks, kwlist[i])) {
match = 1;
diff --git a/Python/import.c b/Python/import.c
index ffaaca5..b65ed0e 100644
--- a/Python/import.c
+++ b/Python/import.c
@@ -467,8 +467,8 @@ PyImport_Cleanup(void)
while (PyDict_Next(modules, &pos, &key, &value)) {
if (value->ob_refcnt != 1)
continue;
- if (PyBytes_Check(key) && PyModule_Check(value)) {
- name = PyBytes_AS_STRING(key);
+ if (PyString_Check(key) && PyModule_Check(value)) {
+ name = PyString_AS_STRING(key);
if (strcmp(name, "__builtin__") == 0)
continue;
if (strcmp(name, "sys") == 0)
@@ -486,8 +486,8 @@ PyImport_Cleanup(void)
/* Next, delete all modules (still skipping __builtin__ and sys) */
pos = 0;
while (PyDict_Next(modules, &pos, &key, &value)) {
- if (PyBytes_Check(key) && PyModule_Check(value)) {
- name = PyBytes_AS_STRING(key);
+ if (PyString_Check(key) && PyModule_Check(value)) {
+ name = PyString_AS_STRING(key);
if (strcmp(name, "__builtin__") == 0)
continue;
if (strcmp(name, "sys") == 0)
@@ -665,7 +665,7 @@ PyImport_ExecCodeModuleEx(char *name, PyObject *co, char *pathname)
/* Remember the filename as the __file__ attribute */
v = NULL;
if (pathname != NULL) {
- v = PyBytes_FromString(pathname);
+ v = PyString_FromString(pathname);
if (v == NULL)
PyErr_Clear();
}
@@ -1002,7 +1002,7 @@ load_package(char *name, char *pathname)
PySys_WriteStderr("import %s # directory %s\n",
name, pathname);
d = PyModule_GetDict(m);
- file = PyBytes_FromString(pathname);
+ file = PyString_FromString(pathname);
if (file == NULL)
goto error;
path = Py_BuildValue("[O]", file);
@@ -1214,15 +1214,15 @@ find_module(char *fullname, char *subname, PyObject *path, char *buf,
Py_DECREF(meta_path);
}
- if (path != NULL && PyBytes_Check(path)) {
+ if (path != NULL && PyString_Check(path)) {
/* The only type of submodule allowed inside a "frozen"
package are other frozen modules or packages. */
- if (PyBytes_Size(path) + 1 + strlen(name) >= (size_t)buflen) {
+ if (PyString_Size(path) + 1 + strlen(name) >= (size_t)buflen) {
PyErr_SetString(PyExc_ImportError,
"full frozen module name too long");
return NULL;
}
- strcpy(buf, PyBytes_AsString(path));
+ strcpy(buf, PyString_AsString(path));
strcat(buf, ".");
strcat(buf, name);
strcpy(name, buf);
@@ -1291,14 +1291,14 @@ find_module(char *fullname, char *subname, PyObject *path, char *buf,
}
else
#endif
- if (!PyBytes_Check(v))
+ if (!PyString_Check(v))
continue;
- len = PyBytes_GET_SIZE(v);
+ len = PyString_GET_SIZE(v);
if (len + 2 + namelen + MAXSUFFIXSIZE >= buflen) {
Py_XDECREF(copy);
continue; /* Too long */
}
- strcpy(buf, PyBytes_AS_STRING(v));
+ strcpy(buf, PyString_AS_STRING(v));
if (strlen(buf) != len) {
Py_XDECREF(copy);
continue; /* v contains '\0' */
@@ -1963,7 +1963,7 @@ PyImport_ImportFrozenModule(char *name)
if (m == NULL)
goto err_return;
d = PyModule_GetDict(m);
- s = PyBytes_InternFromString(name);
+ s = PyString_InternFromString(name);
if (s == NULL)
goto err_return;
err = PyDict_SetItemString(d, "__path__", s);
@@ -1992,7 +1992,7 @@ PyImport_ImportModule(const char *name)
PyObject *pname;
PyObject *result;
- pname = PyBytes_FromString(name);
+ pname = PyString_FromString(name);
if (pname == NULL)
return NULL;
result = PyImport_Import(pname);
@@ -2165,17 +2165,17 @@ get_parent(PyObject *globals, char *buf, Py_ssize_t *p_buflen, int level)
return Py_None;
if (namestr == NULL) {
- namestr = PyBytes_InternFromString("__name__");
+ namestr = PyString_InternFromString("__name__");
if (namestr == NULL)
return NULL;
}
if (pathstr == NULL) {
- pathstr = PyBytes_InternFromString("__path__");
+ pathstr = PyString_InternFromString("__path__");
if (pathstr == NULL)
return NULL;
}
if (pkgstr == NULL) {
- pkgstr = PyBytes_InternFromString("__package__");
+ pkgstr = PyString_InternFromString("__package__");
if (pkgstr == NULL)
return NULL;
}
@@ -2187,12 +2187,12 @@ get_parent(PyObject *globals, char *buf, Py_ssize_t *p_buflen, int level)
if ((pkgname != NULL) && (pkgname != Py_None)) {
/* __package__ is set, so use it */
Py_ssize_t len;
- if (!PyBytes_Check(pkgname)) {
+ if (!PyString_Check(pkgname)) {
PyErr_SetString(PyExc_ValueError,
"__package__ set to non-string");
return NULL;
}
- len = PyBytes_GET_SIZE(pkgname);
+ len = PyString_GET_SIZE(pkgname);
if (len == 0) {
if (level > 0) {
PyErr_SetString(PyExc_ValueError,
@@ -2206,24 +2206,24 @@ get_parent(PyObject *globals, char *buf, Py_ssize_t *p_buflen, int level)
"Package name too long");
return NULL;
}
- strcpy(buf, PyBytes_AS_STRING(pkgname));
+ strcpy(buf, PyString_AS_STRING(pkgname));
} else {
/* __package__ not set, so figure it out and set it */
modname = PyDict_GetItem(globals, namestr);
- if (modname == NULL || !PyBytes_Check(modname))
+ if (modname == NULL || !PyString_Check(modname))
return Py_None;
modpath = PyDict_GetItem(globals, pathstr);
if (modpath != NULL) {
/* __path__ is set, so modname is already the package name */
- Py_ssize_t len = PyBytes_GET_SIZE(modname);
+ Py_ssize_t len = PyString_GET_SIZE(modname);
int error;
if (len > MAXPATHLEN) {
PyErr_SetString(PyExc_ValueError,
"Module name too long");
return NULL;
}
- strcpy(buf, PyBytes_AS_STRING(modname));
+ strcpy(buf, PyString_AS_STRING(modname));
error = PyDict_SetItem(globals, pkgstr, modname);
if (error) {
PyErr_SetString(PyExc_ValueError,
@@ -2232,7 +2232,7 @@ get_parent(PyObject *globals, char *buf, Py_ssize_t *p_buflen, int level)
}
} else {
/* Normal module, so work out the package name if any */
- char *start = PyBytes_AS_STRING(modname);
+ char *start = PyString_AS_STRING(modname);
char *lastdot = strrchr(start, '.');
size_t len;
int error;
@@ -2258,7 +2258,7 @@ get_parent(PyObject *globals, char *buf, Py_ssize_t *p_buflen, int level)
}
strncpy(buf, start, len);
buf[len] = '\0';
- pkgname = PyBytes_FromString(buf);
+ pkgname = PyString_FromString(buf);
if (pkgname == NULL) {
return NULL;
}
@@ -2394,13 +2394,13 @@ ensure_fromlist(PyObject *mod, PyObject *fromlist, char *buf, Py_ssize_t buflen,
}
return 0;
}
- if (!PyBytes_Check(item)) {
+ if (!PyString_Check(item)) {
PyErr_SetString(PyExc_TypeError,
"Item in ``from list'' not a string");
Py_DECREF(item);
return 0;
}
- if (PyBytes_AS_STRING(item)[0] == '*') {
+ if (PyString_AS_STRING(item)[0] == '*') {
PyObject *all;
Py_DECREF(item);
/* See if the package defines __all__ */
@@ -2419,7 +2419,7 @@ ensure_fromlist(PyObject *mod, PyObject *fromlist, char *buf, Py_ssize_t buflen,
}
hasit = PyObject_HasAttr(mod, item);
if (!hasit) {
- char *subname = PyBytes_AS_STRING(item);
+ char *subname = PyString_AS_STRING(item);
PyObject *submod;
char *p;
if (buflen + strlen(subname) >= MAXPATHLEN) {
@@ -2585,7 +2585,7 @@ PyImport_ReloadModule(PyObject *m)
subname = name;
else {
PyObject *parentname, *parent;
- parentname = PyBytes_FromStringAndSize(name, (subname-name));
+ parentname = PyString_FromStringAndSize(name, (subname-name));
if (parentname == NULL) {
imp_modules_reloading_clear();
return NULL;
@@ -2594,7 +2594,7 @@ PyImport_ReloadModule(PyObject *m)
if (parent == NULL) {
PyErr_Format(PyExc_ImportError,
"reload(): parent %.200s not in sys.modules",
- PyBytes_AS_STRING(parentname));
+ PyString_AS_STRING(parentname));
Py_DECREF(parentname);
imp_modules_reloading_clear();
return NULL;
@@ -2639,7 +2639,7 @@ PyImport_ReloadModule(PyObject *m)
done using whatever import hooks are installed in the current
environment, e.g. by "rexec".
A dummy list ["__doc__"] is passed as the 4th argument so that
- e.g. PyImport_Import(PyBytes_FromString("win32com.client.gencache"))
+ e.g. PyImport_Import(PyString_FromString("win32com.client.gencache"))
will return <module "gencache"> instead of <module "win32com">. */
PyObject *
@@ -2655,10 +2655,10 @@ PyImport_Import(PyObject *module_name)
/* Initialize constant string objects */
if (silly_list == NULL) {
- import_str = PyBytes_InternFromString("__import__");
+ import_str = PyString_InternFromString("__import__");
if (import_str == NULL)
return NULL;
- builtins_str = PyBytes_InternFromString("__builtins__");
+ builtins_str = PyString_InternFromString("__builtins__");
if (builtins_str == NULL)
return NULL;
silly_list = Py_BuildValue("[s]", "__doc__");
@@ -2726,7 +2726,7 @@ imp_get_magic(PyObject *self, PyObject *noargs)
buf[2] = (char) ((pyc_magic >> 16) & 0xff);
buf[3] = (char) ((pyc_magic >> 24) & 0xff);
- return PyBytes_FromStringAndSize(buf, 4);
+ return PyString_FromStringAndSize(buf, 4);
}
static PyObject *
diff --git a/Python/mactoolboxglue.c b/Python/mactoolboxglue.c
index 19ec4cf..4037d47 100644
--- a/Python/mactoolboxglue.c
+++ b/Python/mactoolboxglue.c
@@ -52,7 +52,7 @@ PyMac_StrError(int err)
buf[0] = '\0';
}
else {
- char *input = PyBytes_AsString(rv);
+ char *input = PyString_AsString(rv);
if (!input) {
PyErr_Clear();
buf[0] = '\0';
@@ -125,7 +125,7 @@ PyMac_GetFullPathname(FSSpec *fss, char *path, int len)
if (!rv)
goto error;
- input = PyBytes_AsString(rv);
+ input = PyString_AsString(rv);
if (!input)
goto error;
@@ -161,12 +161,12 @@ int
PyMac_GetOSType(PyObject *v, OSType *pr)
{
uint32_t tmp;
- if (!PyBytes_Check(v) || PyBytes_Size(v) != 4) {
+ if (!PyString_Check(v) || PyString_Size(v) != 4) {
PyErr_SetString(PyExc_TypeError,
"OSType arg must be string of 4 chars");
return 0;
}
- memcpy((char *)&tmp, PyBytes_AsString(v), 4);
+ memcpy((char *)&tmp, PyString_AsString(v), 4);
*pr = (OSType)ntohl(tmp);
return 1;
}
@@ -176,7 +176,7 @@ PyObject *
PyMac_BuildOSType(OSType t)
{
uint32_t tmp = htonl((uint32_t)t);
- return PyBytes_FromStringAndSize((char *)&tmp, 4);
+ return PyString_FromStringAndSize((char *)&tmp, 4);
}
/* Convert an NumVersion value to a 4-element tuple */
@@ -192,13 +192,13 @@ int
PyMac_GetStr255(PyObject *v, Str255 pbuf)
{
int len;
- if (!PyBytes_Check(v) || (len = PyBytes_Size(v)) > 255) {
+ if (!PyString_Check(v) || (len = PyString_Size(v)) > 255) {
PyErr_SetString(PyExc_TypeError,
"Str255 arg must be string of at most 255 chars");
return 0;
}
pbuf[0] = len;
- memcpy((char *)(pbuf+1), PyBytes_AsString(v), len);
+ memcpy((char *)(pbuf+1), PyString_AsString(v), len);
return 1;
}
@@ -210,7 +210,7 @@ PyMac_BuildStr255(Str255 s)
PyErr_SetString(PyExc_SystemError, "Str255 pointer is NULL");
return NULL;
}
- return PyBytes_FromStringAndSize((char *)&s[1], (int)s[0]);
+ return PyString_FromStringAndSize((char *)&s[1], (int)s[0]);
}
PyObject *
@@ -220,7 +220,7 @@ PyMac_BuildOptStr255(Str255 s)
Py_INCREF(Py_None);
return Py_None;
}
- return PyBytes_FromStringAndSize((char *)&s[1], (int)s[0]);
+ return PyString_FromStringAndSize((char *)&s[1], (int)s[0]);
}
diff --git a/Python/marshal.c b/Python/marshal.c
index 1cc222c..6db46e4 100644
--- a/Python/marshal.c
+++ b/Python/marshal.c
@@ -64,18 +64,18 @@ w_more(int c, WFILE *p)
Py_ssize_t size, newsize;
if (p->str == NULL)
return; /* An error already occurred */
- size = PyBytes_Size(p->str);
+ size = PyString_Size(p->str);
newsize = size + size + 1024;
if (newsize > 32*1024*1024) {
newsize = size + 1024*1024;
}
- if (_PyBytes_Resize(&p->str, newsize) != 0) {
+ if (_PyString_Resize(&p->str, newsize) != 0) {
p->ptr = p->end = NULL;
}
else {
- p->ptr = PyBytes_AS_STRING((PyBytesObject *)p->str) + size;
+ p->ptr = PyString_AS_STRING((PyStringObject *)p->str) + size;
p->end =
- PyBytes_AS_STRING((PyBytesObject *)p->str) + newsize;
+ PyString_AS_STRING((PyStringObject *)p->str) + newsize;
*p->ptr++ = Py_SAFE_DOWNCAST(c, int, char);
}
}
@@ -239,8 +239,8 @@ w_object(PyObject *v, WFILE *p)
}
}
#endif
- else if (PyBytes_CheckExact(v)) {
- if (p->strings && PyBytes_CHECK_INTERNED(v)) {
+ else if (PyString_CheckExact(v)) {
+ if (p->strings && PyString_CHECK_INTERNED(v)) {
PyObject *o = PyDict_GetItem(p->strings, v);
if (o) {
long w = PyInt_AsLong(o);
@@ -265,7 +265,7 @@ w_object(PyObject *v, WFILE *p)
else {
w_byte(TYPE_STRING, p);
}
- n = PyBytes_GET_SIZE(v);
+ n = PyString_GET_SIZE(v);
if (n > INT_MAX) {
/* huge strings are not supported */
p->depth--;
@@ -273,7 +273,7 @@ w_object(PyObject *v, WFILE *p)
return;
}
w_long((long)n, p);
- w_string(PyBytes_AS_STRING(v), (int)n, p);
+ w_string(PyString_AS_STRING(v), (int)n, p);
}
#ifdef Py_USING_UNICODE
else if (PyUnicode_CheckExact(v)) {
@@ -285,14 +285,14 @@ w_object(PyObject *v, WFILE *p)
return;
}
w_byte(TYPE_UNICODE, p);
- n = PyBytes_GET_SIZE(utf8);
+ n = PyString_GET_SIZE(utf8);
if (n > INT_MAX) {
p->depth--;
p->error = 1;
return;
}
w_long((long)n, p);
- w_string(PyBytes_AS_STRING(utf8), (int)n, p);
+ w_string(PyString_AS_STRING(utf8), (int)n, p);
Py_DECREF(utf8);
}
#endif
@@ -713,12 +713,12 @@ r_object(RFILE *p)
retval = NULL;
break;
}
- v = PyBytes_FromStringAndSize((char *)NULL, n);
+ v = PyString_FromStringAndSize((char *)NULL, n);
if (v == NULL) {
retval = NULL;
break;
}
- if (r_string(PyBytes_AS_STRING(v), (int)n, p) != n) {
+ if (r_string(PyString_AS_STRING(v), (int)n, p) != n) {
Py_DECREF(v);
PyErr_SetString(PyExc_EOFError,
"EOF read where object expected");
@@ -726,7 +726,7 @@ r_object(RFILE *p)
break;
}
if (type == TYPE_INTERNED) {
- PyBytes_InternInPlace(&v);
+ PyString_InternInPlace(&v);
if (PyList_Append(p->strings, v) < 0) {
retval = NULL;
break;
@@ -1113,11 +1113,11 @@ PyMarshal_WriteObjectToString(PyObject *x, int version)
{
WFILE wf;
wf.fp = NULL;
- wf.str = PyBytes_FromStringAndSize((char *)NULL, 50);
+ wf.str = PyString_FromStringAndSize((char *)NULL, 50);
if (wf.str == NULL)
return NULL;
- wf.ptr = PyBytes_AS_STRING((PyBytesObject *)wf.str);
- wf.end = wf.ptr + PyBytes_Size(wf.str);
+ wf.ptr = PyString_AS_STRING((PyStringObject *)wf.str);
+ wf.end = wf.ptr + PyString_Size(wf.str);
wf.error = 0;
wf.depth = 0;
wf.version = version;
@@ -1125,14 +1125,14 @@ PyMarshal_WriteObjectToString(PyObject *x, int version)
w_object(x, &wf);
Py_XDECREF(wf.strings);
if (wf.str != NULL) {
- char *base = PyBytes_AS_STRING((PyBytesObject *)wf.str);
+ char *base = PyString_AS_STRING((PyStringObject *)wf.str);
if (wf.ptr - base > PY_SSIZE_T_MAX) {
Py_DECREF(wf.str);
PyErr_SetString(PyExc_OverflowError,
"too much marshall data for a string");
return NULL;
}
- _PyBytes_Resize(&wf.str, (Py_ssize_t)(wf.ptr - base));
+ _PyString_Resize(&wf.str, (Py_ssize_t)(wf.ptr - base));
}
if (wf.error) {
Py_XDECREF(wf.str);
diff --git a/Python/modsupport.c b/Python/modsupport.c
index b23749f..d54158f 100644
--- a/Python/modsupport.c
+++ b/Python/modsupport.c
@@ -65,7 +65,7 @@ Py_InitModule4(const char *name, PyMethodDef *methods, const char *doc,
return NULL;
d = PyModule_GetDict(m);
if (methods != NULL) {
- n = PyBytes_FromString(name);
+ n = PyString_FromString(name);
if (n == NULL)
return NULL;
for (ml = methods; ml->ml_name != NULL; ml++) {
@@ -92,7 +92,7 @@ Py_InitModule4(const char *name, PyMethodDef *methods, const char *doc,
Py_DECREF(n);
}
if (doc != NULL) {
- v = PyBytes_FromString(doc);
+ v = PyString_FromString(doc);
if (v == NULL || PyDict_SetItemString(d, "__doc__", v) != 0) {
Py_XDECREF(v);
return NULL;
@@ -391,7 +391,7 @@ do_mkvalue(const char **p_format, va_list *p_va, int flags)
{
char p[1];
p[0] = (char)va_arg(*p_va, int);
- return PyBytes_FromStringAndSize(p, 1);
+ return PyString_FromStringAndSize(p, 1);
}
case 's':
@@ -423,7 +423,7 @@ do_mkvalue(const char **p_format, va_list *p_va, int flags)
}
n = (Py_ssize_t)m;
}
- v = PyBytes_FromStringAndSize(str, n);
+ v = PyString_FromStringAndSize(str, n);
}
return v;
}
@@ -633,7 +633,7 @@ PyModule_AddIntConstant(PyObject *m, const char *name, long value)
int
PyModule_AddStringConstant(PyObject *m, const char *name, const char *value)
{
- PyObject *o = PyBytes_FromString(value);
+ PyObject *o = PyString_FromString(value);
if (!o)
return -1;
if (PyModule_AddObject(m, name, o) == 0)
diff --git a/Python/peephole.c b/Python/peephole.c
index df19726..e9da377 100644
--- a/Python/peephole.c
+++ b/Python/peephole.c
@@ -300,15 +300,15 @@ PyCode_Optimize(PyObject *code, PyObject* consts, PyObject *names,
goto exitUnchanged;
/* Bypass optimization when the lineno table is too complex */
- assert(PyBytes_Check(lineno_obj));
- lineno = (unsigned char*)PyBytes_AS_STRING(lineno_obj);
- tabsiz = PyBytes_GET_SIZE(lineno_obj);
+ assert(PyString_Check(lineno_obj));
+ lineno = (unsigned char*)PyString_AS_STRING(lineno_obj);
+ tabsiz = PyString_GET_SIZE(lineno_obj);
if (memchr(lineno, 255, tabsiz) != NULL)
goto exitUnchanged;
/* Avoid situations where jump retargeting could overflow */
- assert(PyBytes_Check(code));
- codelen = PyBytes_GET_SIZE(code);
+ assert(PyString_Check(code));
+ codelen = PyString_GET_SIZE(code);
if (codelen > 32700)
goto exitUnchanged;
@@ -317,7 +317,7 @@ PyCode_Optimize(PyObject *code, PyObject* consts, PyObject *names,
if (codestr == NULL)
goto exitUnchanged;
codestr = (unsigned char *)memcpy(codestr,
- PyBytes_AS_STRING(code), codelen);
+ PyString_AS_STRING(code), codelen);
/* Verify that RETURN_VALUE terminates the codestring. This allows
the various transformation patterns to look ahead several
@@ -382,7 +382,7 @@ PyCode_Optimize(PyObject *code, PyObject* consts, PyObject *names,
case LOAD_NAME:
case LOAD_GLOBAL:
j = GETARG(codestr, i);
- name = PyBytes_AsString(PyTuple_GET_ITEM(names, j));
+ name = PyString_AsString(PyTuple_GET_ITEM(names, j));
if (name == NULL || strcmp(name, "None") != 0)
continue;
for (j=0 ; j < PyList_GET_SIZE(consts) ; j++) {
@@ -612,7 +612,7 @@ PyCode_Optimize(PyObject *code, PyObject* consts, PyObject *names,
}
assert(h + nops == codelen);
- code = PyBytes_FromStringAndSize((char *)codestr, h);
+ code = PyString_FromStringAndSize((char *)codestr, h);
PyMem_Free(addrmap);
PyMem_Free(codestr);
PyMem_Free(blocks);
diff --git a/Python/pystrtod.c b/Python/pystrtod.c
index e7bc22c..3f0328e 100644
--- a/Python/pystrtod.c
+++ b/Python/pystrtod.c
@@ -364,7 +364,7 @@ add_thousands_grouping(char* buffer, size_t buf_size)
/* At this point, p points just past the right-most character we
want to format. We need to add the grouping string for the
characters between buffer and p. */
- return _PyBytes_InsertThousandsGrouping(buffer, len, p,
+ return _PyString_InsertThousandsGrouping(buffer, len, p,
buf_size, NULL, 1);
}
diff --git a/Python/pythonrun.c b/Python/pythonrun.c
index 26557ca..785519b 100644
--- a/Python/pythonrun.c
+++ b/Python/pythonrun.c
@@ -495,7 +495,7 @@ Py_Finalize(void)
PyTuple_Fini();
PyList_Fini();
PySet_Fini();
- PyBytes_Fini();
+ PyString_Fini();
PyByteArray_Fini();
PyInt_Fini();
PyFloat_Fini();
@@ -744,12 +744,12 @@ PyRun_InteractiveLoopFlags(FILE *fp, const char *filename, PyCompilerFlags *flag
}
v = PySys_GetObject("ps1");
if (v == NULL) {
- PySys_SetObject("ps1", v = PyBytes_FromString(">>> "));
+ PySys_SetObject("ps1", v = PyString_FromString(">>> "));
Py_XDECREF(v);
}
v = PySys_GetObject("ps2");
if (v == NULL) {
- PySys_SetObject("ps2", v = PyBytes_FromString("... "));
+ PySys_SetObject("ps2", v = PyString_FromString("... "));
Py_XDECREF(v);
}
for (;;) {
@@ -796,16 +796,16 @@ PyRun_InteractiveOneFlags(FILE *fp, const char *filename, PyCompilerFlags *flags
v = PyObject_Str(v);
if (v == NULL)
PyErr_Clear();
- else if (PyBytes_Check(v))
- ps1 = PyBytes_AsString(v);
+ else if (PyString_Check(v))
+ ps1 = PyString_AsString(v);
}
w = PySys_GetObject("ps2");
if (w != NULL) {
w = PyObject_Str(w);
if (w == NULL)
PyErr_Clear();
- else if (PyBytes_Check(w))
- ps2 = PyBytes_AsString(w);
+ else if (PyString_Check(w))
+ ps2 = PyString_AsString(w);
}
arena = PyArena_New();
if (arena == NULL) {
@@ -898,7 +898,7 @@ PyRun_SimpleFileExFlags(FILE *fp, const char *filename, int closeit,
return -1;
d = PyModule_GetDict(m);
if (PyDict_GetItemString(d, "__file__") == NULL) {
- PyObject *f = PyBytes_FromString(filename);
+ PyObject *f = PyString_FromString(filename);
if (f == NULL)
return -1;
if (PyDict_SetItemString(d, "__file__", f) < 0) {
@@ -982,7 +982,7 @@ parse_syntax_error(PyObject *err, PyObject **message, const char **filename,
goto finally;
if (v == Py_None)
*filename = NULL;
- else if (! (*filename = PyBytes_AsString(v)))
+ else if (! (*filename = PyString_AsString(v)))
goto finally;
Py_DECREF(v);
@@ -1014,7 +1014,7 @@ parse_syntax_error(PyObject *err, PyObject **message, const char **filename,
goto finally;
if (v == Py_None)
*text = NULL;
- else if (! (*text = PyBytes_AsString(v)))
+ else if (! (*text = PyString_AsString(v)))
goto finally;
Py_DECREF(v);
return 1;
@@ -1237,7 +1237,7 @@ PyErr_Display(PyObject *exception, PyObject *value, PyObject *tb)
if (moduleName == NULL)
err = PyFile_WriteString("<unknown>", f);
else {
- char* modstr = PyBytes_AsString(moduleName);
+ char* modstr = PyString_AsString(moduleName);
if (modstr && strcmp(modstr, "exceptions"))
{
err = PyFile_WriteString(modstr, f);
@@ -1261,8 +1261,8 @@ PyErr_Display(PyObject *exception, PyObject *value, PyObject *tb)
*/
if (s == NULL)
err = -1;
- else if (!PyBytes_Check(s) ||
- PyBytes_GET_SIZE(s) != 0)
+ else if (!PyString_Check(s) ||
+ PyString_GET_SIZE(s) != 0)
err = PyFile_WriteString(": ", f);
if (err == 0)
err = PyFile_WriteObject(s, f, Py_PRINT_RAW);
@@ -1581,7 +1581,7 @@ err_input(perrdetail *err)
if (value != NULL) {
u = PyObject_Str(value);
if (u != NULL) {
- msg = PyBytes_AsString(u);
+ msg = PyString_AsString(u);
}
}
if (msg == NULL)
diff --git a/Python/structmember.c b/Python/structmember.c
index 5ebe283..d230590 100644
--- a/Python/structmember.c
+++ b/Python/structmember.c
@@ -16,7 +16,7 @@ listmembers(struct memberlist *mlist)
if (v != NULL) {
for (i = 0; i < n; i++)
PyList_SetItem(v, i,
- PyBytes_FromString(mlist[i].name));
+ PyString_FromString(mlist[i].name));
if (PyErr_Occurred()) {
Py_DECREF(v);
v = NULL;
@@ -103,13 +103,13 @@ PyMember_GetOne(const char *addr, PyMemberDef *l)
v = Py_None;
}
else
- v = PyBytes_FromString(*(char**)addr);
+ v = PyString_FromString(*(char**)addr);
break;
case T_STRING_INPLACE:
- v = PyBytes_FromString((char*)addr);
+ v = PyString_FromString((char*)addr);
break;
case T_CHAR:
- v = PyBytes_FromStringAndSize((char*)addr, 1);
+ v = PyString_FromStringAndSize((char*)addr, 1);
break;
case T_OBJECT:
v = *(PyObject **)addr;
@@ -310,8 +310,8 @@ PyMember_SetOne(char *addr, PyMemberDef *l, PyObject *v)
Py_XDECREF(oldv);
break;
case T_CHAR:
- if (PyBytes_Check(v) && PyBytes_Size(v) == 1) {
- *(char*)addr = PyBytes_AsString(v)[0];
+ if (PyString_Check(v) && PyString_Size(v) == 1) {
+ *(char*)addr = PyString_AsString(v)[0];
}
else {
PyErr_BadArgument();
diff --git a/Python/symtable.c b/Python/symtable.c
index c0201c3..cc3c774 100644
--- a/Python/symtable.c
+++ b/Python/symtable.c
@@ -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;
diff --git a/Python/sysmodule.c b/Python/sysmodule.c
index 9564267..64ea89f 100644
--- a/Python/sysmodule.c
+++ b/Python/sysmodule.c
@@ -229,7 +229,7 @@ exit status will be one (i.e., failure)."
static PyObject *
sys_getdefaultencoding(PyObject *self)
{
- return PyBytes_FromString(PyUnicode_GetDefaultEncoding());
+ return PyString_FromString(PyUnicode_GetDefaultEncoding());
}
PyDoc_STRVAR(getdefaultencoding_doc,
@@ -261,7 +261,7 @@ static PyObject *
sys_getfilesystemencoding(PyObject *self)
{
if (Py_FileSystemDefaultEncoding)
- return PyBytes_FromString(Py_FileSystemDefaultEncoding);
+ return PyString_FromString(Py_FileSystemDefaultEncoding);
Py_INCREF(Py_None);
return Py_None;
}
@@ -290,7 +290,7 @@ trace_init(void)
int i;
for (i = 0; i < 7; ++i) {
if (whatstrings[i] == NULL) {
- name = PyBytes_InternFromString(whatnames[i]);
+ name = PyString_InternFromString(whatnames[i]);
if (name == NULL)
return -1;
whatstrings[i] = name;
@@ -931,7 +931,7 @@ list_builtin_module_names(void)
if (list == NULL)
return NULL;
for (i = 0; PyImport_Inittab[i].name != NULL; i++) {
- PyObject *name = PyBytes_FromString(
+ PyObject *name = PyString_FromString(
PyImport_Inittab[i].name);
if (name == NULL)
break;
@@ -971,7 +971,7 @@ PySys_AddWarnOption(char *s)
if (warnoptions == NULL)
return;
}
- str = PyBytes_FromString(s);
+ str = PyString_FromString(s);
if (str != NULL) {
PyList_Append(warnoptions, str);
Py_DECREF(str);
@@ -1327,7 +1327,7 @@ _PySys_Init(void)
Py_XDECREF(syserr);
SET_SYS_FROM_STRING("version",
- PyBytes_FromString(Py_GetVersion()));
+ PyString_FromString(Py_GetVersion()));
SET_SYS_FROM_STRING("hexversion",
PyInt_FromLong(PY_VERSION_HEX));
svnversion_init();
@@ -1358,15 +1358,15 @@ _PySys_Init(void)
SET_SYS_FROM_STRING("api_version",
PyInt_FromLong(PYTHON_API_VERSION));
SET_SYS_FROM_STRING("copyright",
- PyBytes_FromString(Py_GetCopyright()));
+ PyString_FromString(Py_GetCopyright()));
SET_SYS_FROM_STRING("platform",
- PyBytes_FromString(Py_GetPlatform()));
+ PyString_FromString(Py_GetPlatform()));
SET_SYS_FROM_STRING("executable",
- PyBytes_FromString(Py_GetProgramFullPath()));
+ PyString_FromString(Py_GetProgramFullPath()));
SET_SYS_FROM_STRING("prefix",
- PyBytes_FromString(Py_GetPrefix()));
+ PyString_FromString(Py_GetPrefix()));
SET_SYS_FROM_STRING("exec_prefix",
- PyBytes_FromString(Py_GetExecPrefix()));
+ PyString_FromString(Py_GetExecPrefix()));
SET_SYS_FROM_STRING("maxsize",
PyInt_FromSsize_t(PY_SSIZE_T_MAX));
SET_SYS_FROM_STRING("maxint",
@@ -1393,13 +1393,13 @@ _PySys_Init(void)
else
value = "little";
SET_SYS_FROM_STRING("byteorder",
- PyBytes_FromString(value));
+ PyString_FromString(value));
}
#ifdef MS_COREDLL
SET_SYS_FROM_STRING("dllhandle",
PyLong_FromVoidPtr(PyWin_DLLhModule));
SET_SYS_FROM_STRING("winver",
- PyBytes_FromString(PyWin_DLLVersionString));
+ PyString_FromString(PyWin_DLLVersionString));
#endif
if (warnoptions == NULL) {
warnoptions = PyList_New(0);
@@ -1444,7 +1444,7 @@ makepathobject(char *path, int delim)
p = strchr(path, delim);
if (p == NULL)
p = strchr(path, '\0'); /* End of string */
- w = PyBytes_FromStringAndSize(path, (Py_ssize_t) (p - path));
+ w = PyString_FromStringAndSize(path, (Py_ssize_t) (p - path));
if (w == NULL) {
Py_DECREF(v);
return NULL;
@@ -1489,14 +1489,14 @@ makeargvobject(int argc, char **argv)
if (i == 0) {
char* fn = decc$translate_vms(argv[0]);
if ((fn == (char *)0) || fn == (char *)-1)
- v = PyBytes_FromString(argv[0]);
+ v = PyString_FromString(argv[0]);
else
- v = PyBytes_FromString(
+ v = PyString_FromString(
decc$translate_vms(argv[0]));
} else
- v = PyBytes_FromString(argv[i]);
+ v = PyString_FromString(argv[i]);
#else
- PyObject *v = PyBytes_FromString(argv[i]);
+ PyObject *v = PyString_FromString(argv[i]);
#endif
if (v == NULL) {
Py_DECREF(av);
@@ -1600,7 +1600,7 @@ PySys_SetArgv(int argc, char **argv)
#endif /* Unix */
}
#endif /* All others */
- a = PyBytes_FromStringAndSize(argv0, n);
+ a = PyString_FromStringAndSize(argv0, n);
if (a == NULL)
Py_FatalError("no mem for sys.path insertion");
if (PyList_Insert(path, 0, a) < 0)
diff --git a/Python/traceback.c b/Python/traceback.c
index adf9a53..a481963 100644
--- a/Python/traceback.c
+++ b/Python/traceback.c
@@ -155,12 +155,12 @@ Py_DisplaySourceLine(PyObject *f, const char *filename, int lineno)
PyErr_Clear();
break;
}
- if (PyBytes_Check(v)) {
+ if (PyString_Check(v)) {
size_t len;
- len = PyBytes_GET_SIZE(v);
+ len = PyString_GET_SIZE(v);
if (len + 1 + taillen >= MAXPATHLEN)
continue; /* Too long */
- strcpy(namebuf, PyBytes_AsString(v));
+ strcpy(namebuf, PyString_AsString(v));
if (strlen(namebuf) != len)
continue; /* v contains '\0' */
if (len > 0 && namebuf[len-1] != SEP)
@@ -238,10 +238,10 @@ tb_printinternal(PyTracebackObject *tb, PyObject *f, long limit)
while (tb != NULL && err == 0) {
if (depth <= limit) {
err = tb_displayline(f,
- PyBytes_AsString(
+ PyString_AsString(
tb->tb_frame->f_code->co_filename),
tb->tb_lineno,
- PyBytes_AsString(tb->tb_frame->f_code->co_name));
+ PyString_AsString(tb->tb_frame->f_code->co_name));
}
depth--;
tb = tb->tb_next;