summaryrefslogtreecommitdiffstats
path: root/Python
diff options
context:
space:
mode:
authorChristian Heimes <christian@cheimes.de>2008-05-26 12:51:38 (GMT)
committerChristian Heimes <christian@cheimes.de>2008-05-26 12:51:38 (GMT)
commit593daf545bd9b7e7bcb27b498ecc6f36db9ae395 (patch)
treec0a57029b9ab0eb18a2bb4f8fd65f0817f1a1707 /Python
parentc3cb683d638e9d660c18a05293a576f98965166e (diff)
downloadcpython-593daf545bd9b7e7bcb27b498ecc6f36db9ae395.zip
cpython-593daf545bd9b7e7bcb27b498ecc6f36db9ae395.tar.gz
cpython-593daf545bd9b7e7bcb27b498ecc6f36db9ae395.tar.bz2
Renamed PyString to PyBytes
Diffstat (limited to 'Python')
-rw-r--r--Python/Python-ast.c28
-rw-r--r--Python/_warnings.c56
-rw-r--r--Python/ast.c36
-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, 364 insertions, 364 deletions
diff --git a/Python/Python-ast.c b/Python/Python-ast.c
index f958145..35a3d27 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 = PyString_FromString(fields[i]);
+ PyObject *field = PyBytes_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 = PyString_FromString(attrs[i]);
+ s = PyBytes_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",
- PyString_AS_STRING(s));
+ PyBytes_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",
- PyString_AS_STRING(s));
+ PyBytes_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", PyString_AS_STRING(tmp));
+ PyErr_Format(PyExc_TypeError, "expected some sort of mod, but got %.400s", PyBytes_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", PyString_AS_STRING(tmp));
+ PyErr_Format(PyExc_TypeError, "expected some sort of stmt, but got %.400s", PyBytes_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", PyString_AS_STRING(tmp));
+ PyErr_Format(PyExc_TypeError, "expected some sort of expr, but got %.400s", PyBytes_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", PyString_AS_STRING(tmp));
+ PyErr_Format(PyExc_TypeError, "expected some sort of expr_context, but got %.400s", PyBytes_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", PyString_AS_STRING(tmp));
+ PyErr_Format(PyExc_TypeError, "expected some sort of slice, but got %.400s", PyBytes_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", PyString_AS_STRING(tmp));
+ PyErr_Format(PyExc_TypeError, "expected some sort of boolop, but got %.400s", PyBytes_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", PyString_AS_STRING(tmp));
+ PyErr_Format(PyExc_TypeError, "expected some sort of operator, but got %.400s", PyBytes_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", PyString_AS_STRING(tmp));
+ PyErr_Format(PyExc_TypeError, "expected some sort of unaryop, but got %.400s", PyBytes_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", PyString_AS_STRING(tmp));
+ PyErr_Format(PyExc_TypeError, "expected some sort of cmpop, but got %.400s", PyBytes_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", PyString_AS_STRING(tmp));
+ PyErr_Format(PyExc_TypeError, "expected some sort of excepthandler, but got %.400s", PyBytes_AS_STRING(tmp));
failed:
Py_XDECREF(tmp);
return 1;
diff --git a/Python/_warnings.c b/Python/_warnings.c
index 6603bf0..9783745 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 = PyString_InternFromString("warnings");
+ warnings_str = PyBytes_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 PyString_AsString(action);
+ return PyBytes_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 PyString_AsString(action);
+ return PyBytes_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 PyString_FromString("<unknown>");
+ return PyBytes_FromString("<unknown>");
- mod_str = PyString_AsString(filename);
+ mod_str = PyBytes_AsString(filename);
if (mod_str == NULL)
return NULL;
- len = PyString_Size(filename);
+ len = PyBytes_Size(filename);
if (len < 0)
return NULL;
if (len >= 3 &&
strncmp(mod_str + (len - 3), ".py", 3) == 0) {
- module = PyString_FromStringAndSize(mod_str, len-3);
+ module = PyBytes_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 = PyString_AS_STRING(sourceline);
+ char *source_line_str = PyBytes_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, PyString_AS_STRING(filename), lineno);
+ Py_DisplaySourceLine(f_stderr, PyBytes_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 = PyString_AS_STRING(to_str);
+ err_str = PyBytes_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 = PyString_AS_STRING(text);
+ const char *text_char = PyBytes_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 = PyString_FromString("<string>");
+ *module = PyBytes_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 = PyString_Size(*filename);
- const char *file_str = PyString_AsString(*filename);
+ Py_ssize_t len = PyBytes_Size(*filename);
+ const char *file_str = PyBytes_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 = PyString_FromStringAndSize(file_str, len-1);
+ *filename = PyBytes_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 = PyString_AsString(*module);
+ const char *module_str = PyBytes_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 = PyString_FromString("__main__");
+ *filename = PyBytes_FromString("__main__");
if (*filename == NULL)
goto handle_error;
}
}
else {
/* embedded interpreters don't have sys.argv, see bug #839151 */
- *filename = PyString_FromString("__main__");
+ *filename = PyBytes_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 = PyString_InternFromString("get_source");
+ get_source_name = PyBytes_InternFromString("get_source");
if (!get_source_name)
return NULL;
}
if (splitlines_name == NULL) {
- splitlines_name = PyString_InternFromString("splitlines");
+ splitlines_name = PyBytes_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 = PyString_FromString(text);
+ PyObject *message = PyBytes_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 = PyString_FromString(text);
- PyObject *filename = PyString_FromString(filename_str);
+ PyObject *message = PyBytes_FromString(text);
+ PyObject *filename = PyBytes_FromString(filename_str);
PyObject *module = NULL;
int ret = -1;
if (message == NULL || filename == NULL)
goto exit;
if (module_str != NULL) {
- module = PyString_FromString(module_str);
+ module = PyBytes_FromString(module_str);
if (module == NULL)
goto exit;
}
@@ -812,7 +812,7 @@ create_filter(PyObject *category, const char *action)
if (!strcmp(action, "ignore")) {
if (ignore_str == NULL) {
- ignore_str = PyString_InternFromString("ignore");
+ ignore_str = PyBytes_InternFromString("ignore");
if (ignore_str == NULL)
return NULL;
}
@@ -820,7 +820,7 @@ create_filter(PyObject *category, const char *action)
}
else if (!strcmp(action, "error")) {
if (error_str == NULL) {
- error_str = PyString_InternFromString("error");
+ error_str = PyBytes_InternFromString("error");
if (error_str == NULL)
return NULL;
}
@@ -828,7 +828,7 @@ create_filter(PyObject *category, const char *action)
}
else if (!strcmp(action, "default")) {
if (default_str == NULL) {
- default_str = PyString_InternFromString("default");
+ default_str = PyBytes_InternFromString("default");
if (default_str == NULL)
return NULL;
}
@@ -901,7 +901,7 @@ _PyWarnings_Init(void)
if (PyModule_AddObject(m, "once_registry", _once_registry) < 0)
return;
- default_action = PyString_InternFromString("default");
+ default_action = PyBytes_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 06f5fdf..0bc7595 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 = PyString_InternFromString(n);
+ PyObject* id = PyBytes_InternFromString(n);
PyArena_AddPyObject(arena, id);
return id;
}
@@ -352,7 +352,7 @@ set_context(struct compiling *c, expr_ty e, expr_context_ty ctx, const node *n)
switch (e->kind) {
case Attribute_kind:
if (ctx == Store &&
- !strcmp(PyString_AS_STRING(e->v.Attribute.attr), "None")) {
+ !strcmp(PyBytes_AS_STRING(e->v.Attribute.attr), "None")) {
return ast_error(n, "assignment to None");
}
e->v.Attribute.ctx = ctx;
@@ -362,7 +362,7 @@ set_context(struct compiling *c, expr_ty e, expr_context_ty ctx, const node *n)
break;
case Name_kind:
if (ctx == Store &&
- !strcmp(PyString_AS_STRING(e->v.Name.id), "None")) {
+ !strcmp(PyBytes_AS_STRING(e->v.Name.id), "None")) {
return ast_error(n, "assignment to None");
}
e->v.Name.ctx = ctx;
@@ -1276,7 +1276,7 @@ ast_for_atom(struct compiling *c, const node *n)
if (errstr) {
char *s = "";
char buf[128];
- s = PyString_AsString(errstr);
+ s = PyBytes_AsString(errstr);
PyOS_snprintf(buf, sizeof(buf), "(unicode error) %s", s);
ast_error(n, buf);
} else {
@@ -1921,7 +1921,7 @@ ast_for_call(struct compiling *c, const node *n, expr_ty func)
return NULL;
}
key = e->v.Name.id;
- if (!strcmp(PyString_AS_STRING(key), "None")) {
+ if (!strcmp(PyBytes_AS_STRING(key), "None")) {
ast_error(CHILD(ch, 0), "assignment to None");
return NULL;
}
@@ -2050,7 +2050,7 @@ ast_for_expr_stmt(struct compiling *c, const node *n)
"expression not possible");
return NULL;
case Name_kind: {
- const char *var_name = PyString_AS_STRING(expr1->v.Name.id);
+ const char *var_name = PyBytes_AS_STRING(expr1->v.Name.id);
if (var_name[0] == 'N' && !strcmp(var_name, "None")) {
ast_error(ch, "assignment to None");
return NULL;
@@ -2326,10 +2326,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 = PyString_FromStringAndSize(NULL, len);
+ str = PyBytes_FromStringAndSize(NULL, len);
if (!str)
return NULL;
- s = PyString_AS_STRING(str);
+ s = PyBytes_AS_STRING(str);
if (!s)
return NULL;
for (i = 0; i < NCH(n); i += 2) {
@@ -2340,13 +2340,13 @@ alias_for_import_name(struct compiling *c, const node *n)
}
--s;
*s = '\0';
- PyString_InternInPlace(&str);
+ PyBytes_InternInPlace(&str);
PyArena_AddPyObject(c->c_arena, str);
return alias(str, NULL, c->c_arena);
}
break;
case STAR:
- str = PyString_InternFromString("*");
+ str = PyBytes_InternFromString("*");
PyArena_AddPyObject(c->c_arena, str);
return alias(str, NULL, c->c_arena);
default:
@@ -3196,10 +3196,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 = PyString_FromStringAndSize((char *)NULL, len * 4);
+ u = PyBytes_FromStringAndSize((char *)NULL, len * 4);
if (u == NULL)
return NULL;
- p = buf = PyString_AsString(u);
+ p = buf = PyBytes_AsString(u);
end = s + len;
while (s < end) {
if (*s == '\\') {
@@ -3218,8 +3218,8 @@ decode_unicode(struct compiling *c, const char *s, size_t len, int rawmode, cons
Py_DECREF(u);
return NULL;
}
- r = PyString_AsString(w);
- rn = PyString_Size(w);
+ r = PyBytes_AsString(w);
+ rn = PyBytes_Size(w);
assert(rn % 2 == 0);
for (i = 0; i < rn; i += 2) {
sprintf(p, "\\u%02x%02x",
@@ -3318,11 +3318,11 @@ parsestr(struct compiling *c, const char *s)
return v;
#endif
} else {
- return PyString_FromStringAndSize(s, len);
+ return PyBytes_FromStringAndSize(s, len);
}
}
- return PyString_DecodeEscape(s, len, NULL, unicode,
+ return PyBytes_DecodeEscape(s, len, NULL, unicode,
need_encoding ? c->c_encoding : NULL);
}
@@ -3343,8 +3343,8 @@ parsestrplus(struct compiling *c, const node *n)
s = parsestr(c, STR(CHILD(n, i)));
if (s == NULL)
goto onError;
- if (PyString_Check(v) && PyString_Check(s)) {
- PyString_ConcatAndDel(&v, s);
+ if (PyBytes_Check(v) && PyBytes_Check(s)) {
+ PyBytes_ConcatAndDel(&v, s);
if (v == NULL)
goto onError;
}
diff --git a/Python/bltinmodule.c b/Python/bltinmodule.c
index 8734822..dbae0c9 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 (PyString_Check(seq))
+ if (PyBytes_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 PyString_FromStringAndSize(s, 1);
+ return PyBytes_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 (!PyString_Check(cmd) &&
+ if (!PyBytes_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 (PyString_AsStringAndSize(cmd, &str, NULL)) {
+ if (PyBytes_AsStringAndSize(cmd, &str, NULL)) {
Py_XDECREF(tmp);
return NULL;
}
@@ -814,7 +814,7 @@ builtin_getattr(PyObject *self, PyObject *args)
}
#endif
- if (!PyString_Check(name)) {
+ if (!PyBytes_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 (!PyString_Check(name)) {
+ if (!PyBytes_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 && !PyString_Check(res)) {
+ if (res && !PyBytes_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 (!PyString_CheckExact(s)) {
+ if (!PyBytes_CheckExact(s)) {
PyErr_SetString(PyExc_TypeError,
"can't intern subclass of string");
return NULL;
}
Py_INCREF(s);
- PyString_InternInPlace(&s);
+ PyBytes_InternInPlace(&s);
return s;
}
@@ -1457,7 +1457,7 @@ builtin_oct(PyObject *self, PyObject *v)
return NULL;
}
res = (*nb->nb_oct)(v);
- if (res && !PyString_Check(res)) {
+ if (res && !PyBytes_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 (PyString_Check(obj)) {
- size = PyString_GET_SIZE(obj);
+ if (PyBytes_Check(obj)) {
+ size = PyBytes_GET_SIZE(obj);
if (size == 1) {
- ord = (long)((unsigned char)*PyString_AS_STRING(obj));
+ ord = (long)((unsigned char)*PyBytes_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 && !PyString_Check(sep) &&
+ if (sep && sep != Py_None && !PyBytes_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 && !PyString_Check(end) &&
+ if (end && end != Py_None && !PyBytes_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 = PyString_AsString(po);
+ prompt = PyBytes_AsString(po);
if (prompt == NULL)
return NULL;
}
@@ -1976,7 +1976,7 @@ builtin_raw_input(PyObject *self, PyObject *args)
result = NULL;
}
else {
- result = PyString_FromStringAndSize(s, len-1);
+ result = PyBytes_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", &PyString_Type);
+ SETBUILTIN("bytes", &PyBytes_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", &PyString_Type);
+ SETBUILTIN("str", &PyBytes_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 = PyString_Size(strobj);
+ Py_ssize_t len = PyBytes_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 (PyString_CheckExact(strobj)) {
+ if (PyBytes_CheckExact(strobj)) {
Py_INCREF(strobj);
return strobj;
}
}
- if ((result = PyString_FromStringAndSize(NULL, len)) == NULL)
+ if ((result = PyBytes_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 (!PyString_Check(item)) {
+ if (!PyBytes_Check(item)) {
PyErr_SetString(PyExc_TypeError, "can't filter str to str:"
" __getitem__ returned different type");
Py_DECREF(item);
goto Fail_1;
}
- reslen = PyString_GET_SIZE(item);
+ reslen = PyBytes_GET_SIZE(item);
if (reslen == 1) {
- PyString_AS_STRING(result)[j++] =
- PyString_AS_STRING(item)[0];
+ PyBytes_AS_STRING(result)[j++] =
+ PyBytes_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 (_PyString_Resize(&result, need)) {
+ if (_PyBytes_Resize(&result, need)) {
Py_DECREF(item);
return NULL;
}
outlen = need;
}
memcpy(
- PyString_AS_STRING(result) + j,
- PyString_AS_STRING(item),
+ PyBytes_AS_STRING(result) + j,
+ PyBytes_AS_STRING(item),
reslen
);
j += reslen;
@@ -2815,7 +2815,7 @@ filterstring(PyObject *func, PyObject *strobj)
}
if (j < outlen)
- _PyString_Resize(&result, j);
+ _PyBytes_Resize(&result, j);
return result;
diff --git a/Python/ceval.c b/Python/ceval.c
index 0cff157..bf48255 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*) PyString_AS_STRING(co->co_code);
+ first_instr = (unsigned char*) PyBytes_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 = PyString_AsString(co->co_filename);
+ filename = PyBytes_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 (PyString_CheckExact(v) &&
- PyString_CheckExact(w)) {
+ else if (PyBytes_CheckExact(v) &&
+ PyBytes_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 (PyString_CheckExact(v) &&
- PyString_CheckExact(w)) {
+ else if (PyBytes_CheckExact(v) &&
+ PyBytes_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 (PyString_Check(v)) {
- char *s = PyString_AS_STRING(v);
- Py_ssize_t len = PyString_GET_SIZE(v);
+ if (PyBytes_Check(v)) {
+ char *s = PyBytes_AS_STRING(v);
+ Py_ssize_t len = PyBytes_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) ||
- PyString_Check(v)) {
+ PyBytes_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 (PyString_CheckExact(w)) {
+ if (PyBytes_CheckExact(w)) {
/* Inline the PyDict_GetItem() calls.
WARNING: this is an extreme speed hack.
Do not try this at home. */
- long hash = ((PyStringObject *)w)->ob_shash;
+ long hash = ((PyBytesObject *)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)",
- PyString_AsString(co->co_name),
+ PyBytes_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 || !PyString_Check(keyword)) {
+ if (keyword == NULL || !PyBytes_Check(keyword)) {
PyErr_Format(PyExc_TypeError,
"%.200s() keywords must be strings",
- PyString_AsString(co->co_name));
+ PyBytes_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'",
- PyString_AsString(co->co_name),
- PyString_AsString(keyword));
+ PyBytes_AsString(co->co_name),
+ PyBytes_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'",
- PyString_AsString(co->co_name),
- PyString_AsString(keyword));
+ PyBytes_AsString(co->co_name),
+ PyBytes_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)",
- PyString_AsString(co->co_name),
+ PyBytes_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)",
- PyString_AsString(co->co_name),
+ PyBytes_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 = PyString_AS_STRING(
+ cellname = PyBytes_AS_STRING(
PyTuple_GET_ITEM(co->co_cellvars, i));
found = 0;
for (j = 0; j < nargs; j++) {
- argname = PyString_AS_STRING(
+ argname = PyBytes_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 PyString_AsString(((PyFunctionObject*)func)->func_name);
+ return PyBytes_AsString(((PyFunctionObject*)func)->func_name);
else if (PyCFunction_Check(func))
return ((PyCFunctionObject*)func)->m_ml->ml_name;
else if (PyClass_Check(func))
- return PyString_AsString(((PyClassObject*)func)->cl_name);
+ return PyBytes_AsString(((PyClassObject*)func)->cl_name);
else if (PyInstance_Check(func)) {
- return PyString_AsString(
+ return PyBytes_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),
- PyString_AsString(key));
+ PyBytes_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 (PyString_Check(exc)) {
+ if (PyBytes_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 (PyString_Check(w)) {
+ if (PyBytes_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",
- PyString_AsString(name));
+ PyBytes_AsString(name));
}
return x;
}
@@ -4191,8 +4191,8 @@ import_all_from(PyObject *locals, PyObject *v)
break;
}
if (skip_leading_underscores &&
- PyString_Check(name) &&
- PyString_AS_STRING(name)[0] == '_')
+ PyBytes_Check(name) &&
+ PyBytes_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 (PyString_Check(pvalue)) {
+ if (PyBytes_Check(pvalue)) {
PyObject *newmsg;
- newmsg = PyString_FromFormat(
+ newmsg = PyBytes_FromFormat(
"Error when calling the metaclass bases\n"
" %s",
- PyString_AS_STRING(pvalue));
+ PyBytes_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 (!PyString_Check(prog) &&
+ if (!PyBytes_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 = PyString_AsString(PyFile_Name(prog));
+ char *name = PyBytes_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 (PyString_AsStringAndSize(prog, &str, NULL))
+ if (PyBytes_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 = PyString_AsString(obj);
+ obj_str = PyBytes_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 = PyString_GET_SIZE(v);
- Py_ssize_t w_len = PyString_GET_SIZE(w);
+ Py_ssize_t v_len = PyBytes_GET_SIZE(v);
+ Py_ssize_t w_len = PyBytes_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 && !PyString_CHECK_INTERNED(v)) {
+ if (v->ob_refcnt == 1 && !PyBytes_CHECK_INTERNED(v)) {
/* Now we own the last reference to 'v', so we can resize it
* in-place.
*/
- if (_PyString_Resize(&v, new_len) != 0) {
- /* XXX if _PyString_Resize() fails, 'v' has been
+ if (_PyBytes_Resize(&v, new_len) != 0) {
+ /* XXX if _PyBytes_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(PyString_AS_STRING(v) + v_len,
- PyString_AS_STRING(w), w_len);
+ memcpy(PyBytes_AS_STRING(v) + v_len,
+ PyBytes_AS_STRING(w), w_len);
return v;
}
else {
/* When in-place resizing is not an option. */
- PyString_Concat(&v, w);
+ PyBytes_Concat(&v, w);
return v;
}
}
diff --git a/Python/codecs.c b/Python/codecs.c
index 4b0f4cb..0e8cdc7 100644
--- a/Python/codecs.c
+++ b/Python/codecs.c
@@ -61,10 +61,10 @@ PyObject *normalizestring(const char *string)
return NULL;
}
- v = PyString_FromStringAndSize(NULL, len);
+ v = PyBytes_FromStringAndSize(NULL, len);
if (v == NULL)
return NULL;
- p = PyString_AS_STRING(v);
+ p = PyBytes_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;
- PyString_InternInPlace(&v);
+ PyBytes_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 = PyString_FromString(errors);
+ v = PyBytes_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",
- PyString_AS_STRING(string));
+ PyBytes_AS_STRING(string));
Py_DECREF(string);
}
}
diff --git a/Python/compile.c b/Python/compile.c
index c81218d..5092acc 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 = PyString_AsString(ident);
+ const char *p, *name = PyBytes_AsString(ident);
char *buffer;
size_t nlen, plen;
- if (privateobj == NULL || !PyString_Check(privateobj) ||
+ if (privateobj == NULL || !PyBytes_Check(privateobj) ||
name == NULL || name[0] != '_' || name[1] != '_') {
Py_INCREF(ident);
return ident;
}
- p = PyString_AsString(privateobj);
+ p = PyBytes_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 = PyString_FromStringAndSize(NULL, 1 + nlen + plen);
+ ident = PyBytes_FromStringAndSize(NULL, 1 + nlen + plen);
if (!ident)
return 0;
/* ident = "_" + p[:plen] + name # i.e. 1+plen+nlen bytes */
- buffer = PyString_AS_STRING(ident);
+ buffer = PyBytes_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__ = PyString_InternFromString("__doc__");
+ __doc__ = PyBytes_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 PyString_FromString(tmpname);
+ return PyBytes_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 = PyString_InternFromString("<module>");
+ module = PyBytes_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",
- PyString_AS_STRING(name),
- PyString_AS_STRING(c->u->u_name),
+ PyBytes_AS_STRING(name),
+ PyBytes_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),
- PyString_AS_STRING(c->u->u_name),
+ PyBytes_AS_STRING(c->u->u_name),
reftype, arg,
- PyString_AS_STRING(co->co_name),
+ PyBytes_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 = PyString_FromFormat(".%d", i);
+ PyObject *id = PyBytes_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 = PyString_InternFromString("__name__");
+ str = PyBytes_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 = PyString_InternFromString("__module__");
+ str = PyBytes_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 = PyString_InternFromString("<lambda>");
+ name = PyBytes_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 = PyString_AS_STRING(name);
+ const char *src = PyBytes_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 = PyString_FromStringAndSize(src,
+ attr = PyBytes_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 = PyString_AS_STRING(alias->name);
+ const char *base = PyBytes_AS_STRING(alias->name);
char *dot = strchr(base, '.');
if (dot)
- tmp = PyString_FromStringAndSize(base,
+ tmp = PyBytes_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(PyString_AS_STRING(s->v.ImportFrom.module),
+ if (!strcmp(PyBytes_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 && *PyString_AS_STRING(alias->name) == '*') {
+ if (i == 0 && *PyBytes_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 = PyString_InternFromString("AssertionError");
+ assertion_error = PyBytes_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(PyString_AS_STRING(name), "__debug__")) {
+ && !strcmp(PyBytes_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 || PyString_AS_STRING(name)[0] == '_');
+ assert(scope || PyBytes_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",
- PyString_AS_STRING(name));
+ PyBytes_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 = PyString_FromString("<genexpr>");
+ name = PyBytes_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(PyString_AS_STRING(e->v.Name.id),
+ if (strcmp(PyBytes_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 = PyString_InternFromString("__enter__");
+ enter_attr = PyBytes_InternFromString("__enter__");
if (!enter_attr)
return 0;
}
if (!exit_attr) {
- exit_attr = PyString_InternFromString("__exit__");
+ exit_attr = PyBytes_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 = PyString_FromStringAndSize(NULL, DEFAULT_CODE_SIZE);
+ a->a_bytecode = PyBytes_FromStringAndSize(NULL, DEFAULT_CODE_SIZE);
if (!a->a_bytecode)
return 0;
- a->a_lnotab = PyString_FromStringAndSize(NULL, DEFAULT_LNOTAB_SIZE);
+ a->a_lnotab = PyBytes_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 = PyString_GET_SIZE(a->a_lnotab);
+ len = PyBytes_GET_SIZE(a->a_lnotab);
if (nbytes >= len) {
if (len * 2 < nbytes)
len = nbytes;
else
len *= 2;
- if (_PyString_Resize(&a->a_lnotab, len) < 0)
+ if (_PyBytes_Resize(&a->a_lnotab, len) < 0)
return 0;
}
lnotab = (unsigned char *)
- PyString_AS_STRING(a->a_lnotab) + a->a_lnotab_off;
+ PyBytes_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 = PyString_GET_SIZE(a->a_lnotab);
+ len = PyBytes_GET_SIZE(a->a_lnotab);
if (nbytes >= len) {
if (len * 2 < nbytes)
len = nbytes;
else
len *= 2;
- if (_PyString_Resize(&a->a_lnotab, len) < 0)
+ if (_PyBytes_Resize(&a->a_lnotab, len) < 0)
return 0;
}
lnotab = (unsigned char *)
- PyString_AS_STRING(a->a_lnotab) + a->a_lnotab_off;
+ PyBytes_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 = PyString_GET_SIZE(a->a_lnotab);
+ len = PyBytes_GET_SIZE(a->a_lnotab);
if (a->a_lnotab_off + 2 >= len) {
- if (_PyString_Resize(&a->a_lnotab, len * 2) < 0)
+ if (_PyBytes_Resize(&a->a_lnotab, len * 2) < 0)
return 0;
}
lnotab = (unsigned char *)
- PyString_AS_STRING(a->a_lnotab) + a->a_lnotab_off;
+ PyBytes_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 = PyString_GET_SIZE(a->a_bytecode);
+ Py_ssize_t len = PyBytes_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 (_PyString_Resize(&a->a_bytecode, len * 2) < 0)
+ if (_PyBytes_Resize(&a->a_bytecode, len * 2) < 0)
return 0;
}
- code = PyString_AS_STRING(a->a_bytecode) + a->a_offset;
+ code = PyBytes_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 = PyString_FromString(c->c_filename);
+ filename = PyBytes_FromString(c->c_filename);
if (!filename)
goto error;
@@ -3966,9 +3966,9 @@ assemble(struct compiler *c, int addNone)
goto error;
}
- if (_PyString_Resize(&a.a_lnotab, a.a_lnotab_off) < 0)
+ if (_PyBytes_Resize(&a.a_lnotab, a.a_lnotab_off) < 0)
goto error;
- if (_PyString_Resize(&a.a_bytecode, a.a_offset) < 0)
+ if (_PyBytes_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 8951d57..8b04c34 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 = PyString_FromString(string);
+ PyObject *value = PyBytes_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 ? PyString_FromString(filename) : NULL;
+ PyObject *name = filename ? PyBytes_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 ? PyString_FromString(filename) : NULL;
+ PyObject *name = filename ? PyBytes_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 ? PyString_FromString(filename) : NULL;
+ PyObject *name = filename ? PyBytes_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 = PyString_FromFormatV(format, vargs);
+ string = PyBytes_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 = PyString_FromStringAndSize(name,
+ modulename = PyBytes_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 = PyString_AsString(moduleName);
+ char* modstr = PyBytes_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 = PyString_FromString(filename);
+ tmp = PyBytes_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 PyString_FromString(p);
+ return PyBytes_FromString(p);
}
return NULL;
}
diff --git a/Python/future.c b/Python/future.c
index 2c6aaa2..ba058b8 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 = PyString_AsString(name->name);
+ const char *feature = PyBytes_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 = PyString_InternFromString("__future__");
+ future = PyBytes_InternFromString("__future__");
if (!future)
return 0;
}
diff --git a/Python/getargs.c b/Python/getargs.c
index 162cf6f..3b8950c 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) || PyString_Check(arg)) {
+ if (!PySequence_Check(arg) || PyBytes_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 (PyString_Check(arg) && PyString_Size(arg) == 1)
- *p = PyString_AS_STRING(arg)[0];
+ if (PyBytes_Check(arg) && PyBytes_Size(arg) == 1)
+ *p = PyBytes_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 (PyString_Check(arg)) {
- *p = PyString_AS_STRING(arg);
- STORE_SIZE(PyString_GET_SIZE(arg));
+ if (PyBytes_Check(arg)) {
+ *p = PyBytes_AS_STRING(arg);
+ STORE_SIZE(PyBytes_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 = PyString_AS_STRING(uarg);
- STORE_SIZE(PyString_GET_SIZE(uarg));
+ *p = PyBytes_AS_STRING(uarg);
+ STORE_SIZE(PyBytes_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 (PyString_Check(arg))
- *p = PyString_AS_STRING(arg);
+ if (PyBytes_Check(arg))
+ *p = PyBytes_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 = PyString_AS_STRING(uarg);
+ *p = PyBytes_AS_STRING(uarg);
}
#endif
else
return converterr("string", arg, msgbuf, bufsize);
- if ((Py_ssize_t)strlen(*p) != PyString_Size(arg))
+ if ((Py_ssize_t)strlen(*p) != PyBytes_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 (PyString_Check(arg)) {
- *p = PyString_AS_STRING(arg);
- STORE_SIZE(PyString_GET_SIZE(arg));
+ else if (PyBytes_Check(arg)) {
+ *p = PyBytes_AS_STRING(arg);
+ STORE_SIZE(PyBytes_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 = PyString_AS_STRING(uarg);
- STORE_SIZE(PyString_GET_SIZE(uarg));
+ *p = PyBytes_AS_STRING(uarg);
+ STORE_SIZE(PyBytes_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 (PyString_Check(arg))
- *p = PyString_AS_STRING(arg);
+ else if (PyBytes_Check(arg))
+ *p = PyBytes_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 = PyString_AS_STRING(uarg);
+ *p = PyBytes_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 = PyString_Size(arg);
+ *q = PyBytes_Size(arg);
format++;
}
else if (*p != NULL &&
- (Py_ssize_t)strlen(*p) != PyString_Size(arg))
+ (Py_ssize_t)strlen(*p) != PyBytes_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 && PyString_Check(arg)) {
+ if (!recode_strings && PyBytes_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 (!PyString_Check(s)) {
+ if (!PyBytes_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 = PyString_GET_SIZE(s);
+ size = PyBytes_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,
- PyString_AS_STRING(s),
+ PyBytes_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(PyString_AS_STRING(s))
+ if ((Py_ssize_t)strlen(PyBytes_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,
- PyString_AS_STRING(s),
+ PyBytes_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 (PyString_Check(arg))
+ if (PyBytes_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 (!PyString_Check(key)) {
+ if (!PyBytes_Check(key)) {
PyErr_SetString(PyExc_TypeError,
"keywords must be strings");
return cleanreturn(0, freelist);
}
- ks = PyString_AsString(key);
+ ks = PyBytes_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 b65ed0e..ffaaca5 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 (PyString_Check(key) && PyModule_Check(value)) {
- name = PyString_AS_STRING(key);
+ if (PyBytes_Check(key) && PyModule_Check(value)) {
+ name = PyBytes_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 (PyString_Check(key) && PyModule_Check(value)) {
- name = PyString_AS_STRING(key);
+ if (PyBytes_Check(key) && PyModule_Check(value)) {
+ name = PyBytes_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 = PyString_FromString(pathname);
+ v = PyBytes_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 = PyString_FromString(pathname);
+ file = PyBytes_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 && PyString_Check(path)) {
+ if (path != NULL && PyBytes_Check(path)) {
/* The only type of submodule allowed inside a "frozen"
package are other frozen modules or packages. */
- if (PyString_Size(path) + 1 + strlen(name) >= (size_t)buflen) {
+ if (PyBytes_Size(path) + 1 + strlen(name) >= (size_t)buflen) {
PyErr_SetString(PyExc_ImportError,
"full frozen module name too long");
return NULL;
}
- strcpy(buf, PyString_AsString(path));
+ strcpy(buf, PyBytes_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 (!PyString_Check(v))
+ if (!PyBytes_Check(v))
continue;
- len = PyString_GET_SIZE(v);
+ len = PyBytes_GET_SIZE(v);
if (len + 2 + namelen + MAXSUFFIXSIZE >= buflen) {
Py_XDECREF(copy);
continue; /* Too long */
}
- strcpy(buf, PyString_AS_STRING(v));
+ strcpy(buf, PyBytes_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 = PyString_InternFromString(name);
+ s = PyBytes_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 = PyString_FromString(name);
+ pname = PyBytes_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 = PyString_InternFromString("__name__");
+ namestr = PyBytes_InternFromString("__name__");
if (namestr == NULL)
return NULL;
}
if (pathstr == NULL) {
- pathstr = PyString_InternFromString("__path__");
+ pathstr = PyBytes_InternFromString("__path__");
if (pathstr == NULL)
return NULL;
}
if (pkgstr == NULL) {
- pkgstr = PyString_InternFromString("__package__");
+ pkgstr = PyBytes_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 (!PyString_Check(pkgname)) {
+ if (!PyBytes_Check(pkgname)) {
PyErr_SetString(PyExc_ValueError,
"__package__ set to non-string");
return NULL;
}
- len = PyString_GET_SIZE(pkgname);
+ len = PyBytes_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, PyString_AS_STRING(pkgname));
+ strcpy(buf, PyBytes_AS_STRING(pkgname));
} else {
/* __package__ not set, so figure it out and set it */
modname = PyDict_GetItem(globals, namestr);
- if (modname == NULL || !PyString_Check(modname))
+ if (modname == NULL || !PyBytes_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 = PyString_GET_SIZE(modname);
+ Py_ssize_t len = PyBytes_GET_SIZE(modname);
int error;
if (len > MAXPATHLEN) {
PyErr_SetString(PyExc_ValueError,
"Module name too long");
return NULL;
}
- strcpy(buf, PyString_AS_STRING(modname));
+ strcpy(buf, PyBytes_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 = PyString_AS_STRING(modname);
+ char *start = PyBytes_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 = PyString_FromString(buf);
+ pkgname = PyBytes_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 (!PyString_Check(item)) {
+ if (!PyBytes_Check(item)) {
PyErr_SetString(PyExc_TypeError,
"Item in ``from list'' not a string");
Py_DECREF(item);
return 0;
}
- if (PyString_AS_STRING(item)[0] == '*') {
+ if (PyBytes_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 = PyString_AS_STRING(item);
+ char *subname = PyBytes_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 = PyString_FromStringAndSize(name, (subname-name));
+ parentname = PyBytes_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",
- PyString_AS_STRING(parentname));
+ PyBytes_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(PyString_FromString("win32com.client.gencache"))
+ e.g. PyImport_Import(PyBytes_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 = PyString_InternFromString("__import__");
+ import_str = PyBytes_InternFromString("__import__");
if (import_str == NULL)
return NULL;
- builtins_str = PyString_InternFromString("__builtins__");
+ builtins_str = PyBytes_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 PyString_FromStringAndSize(buf, 4);
+ return PyBytes_FromStringAndSize(buf, 4);
}
static PyObject *
diff --git a/Python/mactoolboxglue.c b/Python/mactoolboxglue.c
index 8ad0d6d..e96bb64 100644
--- a/Python/mactoolboxglue.c
+++ b/Python/mactoolboxglue.c
@@ -52,7 +52,7 @@ PyMac_StrError(int err)
buf[0] = '\0';
}
else {
- char *input = PyString_AsString(rv);
+ char *input = PyBytes_AsString(rv);
if (!input) {
PyErr_Clear();
buf[0] = '\0';
@@ -124,7 +124,7 @@ PyMac_GetFullPathname(FSSpec *fss, char *path, int len)
if (!rv)
goto error;
- input = PyString_AsString(rv);
+ input = PyBytes_AsString(rv);
if (!input)
goto error;
@@ -159,12 +159,12 @@ int
PyMac_GetOSType(PyObject *v, OSType *pr)
{
uint32_t tmp;
- if (!PyString_Check(v) || PyString_Size(v) != 4) {
+ if (!PyBytes_Check(v) || PyBytes_Size(v) != 4) {
PyErr_SetString(PyExc_TypeError,
"OSType arg must be string of 4 chars");
return 0;
}
- memcpy((char *)&tmp, PyString_AsString(v), 4);
+ memcpy((char *)&tmp, PyBytes_AsString(v), 4);
*pr = (OSType)ntohl(tmp);
return 1;
}
@@ -174,7 +174,7 @@ PyObject *
PyMac_BuildOSType(OSType t)
{
uint32_t tmp = htonl((uint32_t)t);
- return PyString_FromStringAndSize((char *)&tmp, 4);
+ return PyBytes_FromStringAndSize((char *)&tmp, 4);
}
/* Convert an NumVersion value to a 4-element tuple */
@@ -190,13 +190,13 @@ int
PyMac_GetStr255(PyObject *v, Str255 pbuf)
{
int len;
- if (!PyString_Check(v) || (len = PyString_Size(v)) > 255) {
+ if (!PyBytes_Check(v) || (len = PyBytes_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), PyString_AsString(v), len);
+ memcpy((char *)(pbuf+1), PyBytes_AsString(v), len);
return 1;
}
@@ -208,7 +208,7 @@ PyMac_BuildStr255(Str255 s)
PyErr_SetString(PyExc_SystemError, "Str255 pointer is NULL");
return NULL;
}
- return PyString_FromStringAndSize((char *)&s[1], (int)s[0]);
+ return PyBytes_FromStringAndSize((char *)&s[1], (int)s[0]);
}
PyObject *
@@ -218,7 +218,7 @@ PyMac_BuildOptStr255(Str255 s)
Py_INCREF(Py_None);
return Py_None;
}
- return PyString_FromStringAndSize((char *)&s[1], (int)s[0]);
+ return PyBytes_FromStringAndSize((char *)&s[1], (int)s[0]);
}
diff --git a/Python/marshal.c b/Python/marshal.c
index 6db46e4..1cc222c 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 = PyString_Size(p->str);
+ size = PyBytes_Size(p->str);
newsize = size + size + 1024;
if (newsize > 32*1024*1024) {
newsize = size + 1024*1024;
}
- if (_PyString_Resize(&p->str, newsize) != 0) {
+ if (_PyBytes_Resize(&p->str, newsize) != 0) {
p->ptr = p->end = NULL;
}
else {
- p->ptr = PyString_AS_STRING((PyStringObject *)p->str) + size;
+ p->ptr = PyBytes_AS_STRING((PyBytesObject *)p->str) + size;
p->end =
- PyString_AS_STRING((PyStringObject *)p->str) + newsize;
+ PyBytes_AS_STRING((PyBytesObject *)p->str) + newsize;
*p->ptr++ = Py_SAFE_DOWNCAST(c, int, char);
}
}
@@ -239,8 +239,8 @@ w_object(PyObject *v, WFILE *p)
}
}
#endif
- else if (PyString_CheckExact(v)) {
- if (p->strings && PyString_CHECK_INTERNED(v)) {
+ else if (PyBytes_CheckExact(v)) {
+ if (p->strings && PyBytes_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 = PyString_GET_SIZE(v);
+ n = PyBytes_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(PyString_AS_STRING(v), (int)n, p);
+ w_string(PyBytes_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 = PyString_GET_SIZE(utf8);
+ n = PyBytes_GET_SIZE(utf8);
if (n > INT_MAX) {
p->depth--;
p->error = 1;
return;
}
w_long((long)n, p);
- w_string(PyString_AS_STRING(utf8), (int)n, p);
+ w_string(PyBytes_AS_STRING(utf8), (int)n, p);
Py_DECREF(utf8);
}
#endif
@@ -713,12 +713,12 @@ r_object(RFILE *p)
retval = NULL;
break;
}
- v = PyString_FromStringAndSize((char *)NULL, n);
+ v = PyBytes_FromStringAndSize((char *)NULL, n);
if (v == NULL) {
retval = NULL;
break;
}
- if (r_string(PyString_AS_STRING(v), (int)n, p) != n) {
+ if (r_string(PyBytes_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) {
- PyString_InternInPlace(&v);
+ PyBytes_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 = PyString_FromStringAndSize((char *)NULL, 50);
+ wf.str = PyBytes_FromStringAndSize((char *)NULL, 50);
if (wf.str == NULL)
return NULL;
- wf.ptr = PyString_AS_STRING((PyStringObject *)wf.str);
- wf.end = wf.ptr + PyString_Size(wf.str);
+ wf.ptr = PyBytes_AS_STRING((PyBytesObject *)wf.str);
+ wf.end = wf.ptr + PyBytes_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 = PyString_AS_STRING((PyStringObject *)wf.str);
+ char *base = PyBytes_AS_STRING((PyBytesObject *)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;
}
- _PyString_Resize(&wf.str, (Py_ssize_t)(wf.ptr - base));
+ _PyBytes_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 d54158f..b23749f 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 = PyString_FromString(name);
+ n = PyBytes_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 = PyString_FromString(doc);
+ v = PyBytes_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 PyString_FromStringAndSize(p, 1);
+ return PyBytes_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 = PyString_FromStringAndSize(str, n);
+ v = PyBytes_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 = PyString_FromString(value);
+ PyObject *o = PyBytes_FromString(value);
if (!o)
return -1;
if (PyModule_AddObject(m, name, o) == 0)
diff --git a/Python/peephole.c b/Python/peephole.c
index e9da377..df19726 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(PyString_Check(lineno_obj));
- lineno = (unsigned char*)PyString_AS_STRING(lineno_obj);
- tabsiz = PyString_GET_SIZE(lineno_obj);
+ assert(PyBytes_Check(lineno_obj));
+ lineno = (unsigned char*)PyBytes_AS_STRING(lineno_obj);
+ tabsiz = PyBytes_GET_SIZE(lineno_obj);
if (memchr(lineno, 255, tabsiz) != NULL)
goto exitUnchanged;
/* Avoid situations where jump retargeting could overflow */
- assert(PyString_Check(code));
- codelen = PyString_GET_SIZE(code);
+ assert(PyBytes_Check(code));
+ codelen = PyBytes_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,
- PyString_AS_STRING(code), codelen);
+ PyBytes_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 = PyString_AsString(PyTuple_GET_ITEM(names, j));
+ name = PyBytes_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 = PyString_FromStringAndSize((char *)codestr, h);
+ code = PyBytes_FromStringAndSize((char *)codestr, h);
PyMem_Free(addrmap);
PyMem_Free(codestr);
PyMem_Free(blocks);
diff --git a/Python/pystrtod.c b/Python/pystrtod.c
index 3f0328e..e7bc22c 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 _PyString_InsertThousandsGrouping(buffer, len, p,
+ return _PyBytes_InsertThousandsGrouping(buffer, len, p,
buf_size, NULL, 1);
}
diff --git a/Python/pythonrun.c b/Python/pythonrun.c
index 9880b94..6a9cb25 100644
--- a/Python/pythonrun.c
+++ b/Python/pythonrun.c
@@ -450,7 +450,7 @@ Py_Finalize(void)
PyTuple_Fini();
PyList_Fini();
PySet_Fini();
- PyString_Fini();
+ PyBytes_Fini();
PyByteArray_Fini();
PyInt_Fini();
PyFloat_Fini();
@@ -699,12 +699,12 @@ PyRun_InteractiveLoopFlags(FILE *fp, const char *filename, PyCompilerFlags *flag
}
v = PySys_GetObject("ps1");
if (v == NULL) {
- PySys_SetObject("ps1", v = PyString_FromString(">>> "));
+ PySys_SetObject("ps1", v = PyBytes_FromString(">>> "));
Py_XDECREF(v);
}
v = PySys_GetObject("ps2");
if (v == NULL) {
- PySys_SetObject("ps2", v = PyString_FromString("... "));
+ PySys_SetObject("ps2", v = PyBytes_FromString("... "));
Py_XDECREF(v);
}
for (;;) {
@@ -751,16 +751,16 @@ PyRun_InteractiveOneFlags(FILE *fp, const char *filename, PyCompilerFlags *flags
v = PyObject_Str(v);
if (v == NULL)
PyErr_Clear();
- else if (PyString_Check(v))
- ps1 = PyString_AsString(v);
+ else if (PyBytes_Check(v))
+ ps1 = PyBytes_AsString(v);
}
w = PySys_GetObject("ps2");
if (w != NULL) {
w = PyObject_Str(w);
if (w == NULL)
PyErr_Clear();
- else if (PyString_Check(w))
- ps2 = PyString_AsString(w);
+ else if (PyBytes_Check(w))
+ ps2 = PyBytes_AsString(w);
}
arena = PyArena_New();
if (arena == NULL) {
@@ -853,7 +853,7 @@ PyRun_SimpleFileExFlags(FILE *fp, const char *filename, int closeit,
return -1;
d = PyModule_GetDict(m);
if (PyDict_GetItemString(d, "__file__") == NULL) {
- PyObject *f = PyString_FromString(filename);
+ PyObject *f = PyBytes_FromString(filename);
if (f == NULL)
return -1;
if (PyDict_SetItemString(d, "__file__", f) < 0) {
@@ -937,7 +937,7 @@ parse_syntax_error(PyObject *err, PyObject **message, const char **filename,
goto finally;
if (v == Py_None)
*filename = NULL;
- else if (! (*filename = PyString_AsString(v)))
+ else if (! (*filename = PyBytes_AsString(v)))
goto finally;
Py_DECREF(v);
@@ -969,7 +969,7 @@ parse_syntax_error(PyObject *err, PyObject **message, const char **filename,
goto finally;
if (v == Py_None)
*text = NULL;
- else if (! (*text = PyString_AsString(v)))
+ else if (! (*text = PyBytes_AsString(v)))
goto finally;
Py_DECREF(v);
return 1;
@@ -1192,7 +1192,7 @@ PyErr_Display(PyObject *exception, PyObject *value, PyObject *tb)
if (moduleName == NULL)
err = PyFile_WriteString("<unknown>", f);
else {
- char* modstr = PyString_AsString(moduleName);
+ char* modstr = PyBytes_AsString(moduleName);
if (modstr && strcmp(modstr, "exceptions"))
{
err = PyFile_WriteString(modstr, f);
@@ -1216,8 +1216,8 @@ PyErr_Display(PyObject *exception, PyObject *value, PyObject *tb)
*/
if (s == NULL)
err = -1;
- else if (!PyString_Check(s) ||
- PyString_GET_SIZE(s) != 0)
+ else if (!PyBytes_Check(s) ||
+ PyBytes_GET_SIZE(s) != 0)
err = PyFile_WriteString(": ", f);
if (err == 0)
err = PyFile_WriteObject(s, f, Py_PRINT_RAW);
@@ -1536,7 +1536,7 @@ err_input(perrdetail *err)
if (value != NULL) {
u = PyObject_Str(value);
if (u != NULL) {
- msg = PyString_AsString(u);
+ msg = PyBytes_AsString(u);
}
}
if (msg == NULL)
diff --git a/Python/structmember.c b/Python/structmember.c
index d230590..5ebe283 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,
- PyString_FromString(mlist[i].name));
+ PyBytes_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 = PyString_FromString(*(char**)addr);
+ v = PyBytes_FromString(*(char**)addr);
break;
case T_STRING_INPLACE:
- v = PyString_FromString((char*)addr);
+ v = PyBytes_FromString((char*)addr);
break;
case T_CHAR:
- v = PyString_FromStringAndSize((char*)addr, 1);
+ v = PyBytes_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 (PyString_Check(v) && PyString_Size(v) == 1) {
- *(char*)addr = PyString_AsString(v)[0];
+ if (PyBytes_Check(v) && PyBytes_Size(v) == 1) {
+ *(char*)addr = PyBytes_AsString(v)[0];
}
else {
PyErr_BadArgument();
diff --git a/Python/symtable.c b/Python/symtable.c
index cc3c774..c0201c3 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>",
- PyString_AS_STRING(ste->ste_name),
+ PyBytes_AS_STRING(ste->ste_name),
PyInt_AS_LONG(ste->ste_id), ste->ste_lineno);
- return PyString_FromString(buf);
+ return PyBytes_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) = PyString_InternFromString(# VAR)))
+ ((VAR) ? (VAR) : ((VAR) = PyBytes_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",
- PyString_AS_STRING(name));
+ PyBytes_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",
- PyString_AS_STRING(ste->ste_name), trailer);
+ PyBytes_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",
- PyString_AS_STRING(ste->ste_name), trailer);
+ PyBytes_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",
- PyString_AS_STRING(ste->ste_name), trailer);
+ PyBytes_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,
- PyString_AsString(name));
+ PyBytes_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 = PyString_InternFromString(tmpname);
+ tmp = PyBytes_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 = PyString_AS_STRING(name);
+ char *c_name = PyBytes_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 = PyString_FromFormat(".%d", pos);
+ PyObject *id = PyBytes_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 = PyString_AS_STRING(name);
+ const char *base = PyBytes_AS_STRING(name);
char *dot = strchr(base, '.');
if (dot) {
- store_name = PyString_FromStringAndSize(base, dot - base);
+ store_name = PyBytes_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(PyString_AS_STRING(name), "*")) {
+ if (strcmp(PyBytes_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 f706a7d..b248429 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 PyString_FromString(PyUnicode_GetDefaultEncoding());
+ return PyBytes_FromString(PyUnicode_GetDefaultEncoding());
}
PyDoc_STRVAR(getdefaultencoding_doc,
@@ -261,7 +261,7 @@ static PyObject *
sys_getfilesystemencoding(PyObject *self)
{
if (Py_FileSystemDefaultEncoding)
- return PyString_FromString(Py_FileSystemDefaultEncoding);
+ return PyBytes_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 = PyString_InternFromString(whatnames[i]);
+ name = PyBytes_InternFromString(whatnames[i]);
if (name == NULL)
return -1;
whatstrings[i] = name;
@@ -891,7 +891,7 @@ list_builtin_module_names(void)
if (list == NULL)
return NULL;
for (i = 0; PyImport_Inittab[i].name != NULL; i++) {
- PyObject *name = PyString_FromString(
+ PyObject *name = PyBytes_FromString(
PyImport_Inittab[i].name);
if (name == NULL)
break;
@@ -931,7 +931,7 @@ PySys_AddWarnOption(char *s)
if (warnoptions == NULL)
return;
}
- str = PyString_FromString(s);
+ str = PyBytes_FromString(s);
if (str != NULL) {
PyList_Append(warnoptions, str);
Py_DECREF(str);
@@ -1306,7 +1306,7 @@ _PySys_Init(void)
Py_XDECREF(syserr);
SET_SYS_FROM_STRING("version",
- PyString_FromString(Py_GetVersion()));
+ PyBytes_FromString(Py_GetVersion()));
SET_SYS_FROM_STRING("hexversion",
PyInt_FromLong(PY_VERSION_HEX));
svnversion_init();
@@ -1337,15 +1337,15 @@ _PySys_Init(void)
SET_SYS_FROM_STRING("api_version",
PyInt_FromLong(PYTHON_API_VERSION));
SET_SYS_FROM_STRING("copyright",
- PyString_FromString(Py_GetCopyright()));
+ PyBytes_FromString(Py_GetCopyright()));
SET_SYS_FROM_STRING("platform",
- PyString_FromString(Py_GetPlatform()));
+ PyBytes_FromString(Py_GetPlatform()));
SET_SYS_FROM_STRING("executable",
- PyString_FromString(Py_GetProgramFullPath()));
+ PyBytes_FromString(Py_GetProgramFullPath()));
SET_SYS_FROM_STRING("prefix",
- PyString_FromString(Py_GetPrefix()));
+ PyBytes_FromString(Py_GetPrefix()));
SET_SYS_FROM_STRING("exec_prefix",
- PyString_FromString(Py_GetExecPrefix()));
+ PyBytes_FromString(Py_GetExecPrefix()));
SET_SYS_FROM_STRING("maxsize",
PyInt_FromSsize_t(PY_SSIZE_T_MAX));
SET_SYS_FROM_STRING("maxint",
@@ -1372,13 +1372,13 @@ _PySys_Init(void)
else
value = "little";
SET_SYS_FROM_STRING("byteorder",
- PyString_FromString(value));
+ PyBytes_FromString(value));
}
#ifdef MS_COREDLL
SET_SYS_FROM_STRING("dllhandle",
PyLong_FromVoidPtr(PyWin_DLLhModule));
SET_SYS_FROM_STRING("winver",
- PyString_FromString(PyWin_DLLVersionString));
+ PyBytes_FromString(PyWin_DLLVersionString));
#endif
if (warnoptions == NULL) {
warnoptions = PyList_New(0);
@@ -1423,7 +1423,7 @@ makepathobject(char *path, int delim)
p = strchr(path, delim);
if (p == NULL)
p = strchr(path, '\0'); /* End of string */
- w = PyString_FromStringAndSize(path, (Py_ssize_t) (p - path));
+ w = PyBytes_FromStringAndSize(path, (Py_ssize_t) (p - path));
if (w == NULL) {
Py_DECREF(v);
return NULL;
@@ -1468,14 +1468,14 @@ makeargvobject(int argc, char **argv)
if (i == 0) {
char* fn = decc$translate_vms(argv[0]);
if ((fn == (char *)0) || fn == (char *)-1)
- v = PyString_FromString(argv[0]);
+ v = PyBytes_FromString(argv[0]);
else
- v = PyString_FromString(
+ v = PyBytes_FromString(
decc$translate_vms(argv[0]));
} else
- v = PyString_FromString(argv[i]);
+ v = PyBytes_FromString(argv[i]);
#else
- PyObject *v = PyString_FromString(argv[i]);
+ PyObject *v = PyBytes_FromString(argv[i]);
#endif
if (v == NULL) {
Py_DECREF(av);
@@ -1579,7 +1579,7 @@ PySys_SetArgv(int argc, char **argv)
#endif /* Unix */
}
#endif /* All others */
- a = PyString_FromStringAndSize(argv0, n);
+ a = PyBytes_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 a481963..adf9a53 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 (PyString_Check(v)) {
+ if (PyBytes_Check(v)) {
size_t len;
- len = PyString_GET_SIZE(v);
+ len = PyBytes_GET_SIZE(v);
if (len + 1 + taillen >= MAXPATHLEN)
continue; /* Too long */
- strcpy(namebuf, PyString_AsString(v));
+ strcpy(namebuf, PyBytes_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,
- PyString_AsString(
+ PyBytes_AsString(
tb->tb_frame->f_code->co_filename),
tb->tb_lineno,
- PyString_AsString(tb->tb_frame->f_code->co_name));
+ PyBytes_AsString(tb->tb_frame->f_code->co_name));
}
depth--;
tb = tb->tb_next;