summaryrefslogtreecommitdiffstats
path: root/Python
diff options
context:
space:
mode:
authorChristian Heimes <christian@cheimes.de>2008-05-26 13:28:38 (GMT)
committerChristian Heimes <christian@cheimes.de>2008-05-26 13:28:38 (GMT)
commit72b710a59617ebe6dd1c41613d2c7eb81702efd9 (patch)
treecd134cc11c49ba09f50e44a9f36b69f2b0ffc893 /Python
parent9c4756ea265b5ebd71c9ae59f3673c7cecb6f060 (diff)
downloadcpython-72b710a59617ebe6dd1c41613d2c7eb81702efd9.zip
cpython-72b710a59617ebe6dd1c41613d2c7eb81702efd9.tar.gz
cpython-72b710a59617ebe6dd1c41613d2c7eb81702efd9.tar.bz2
Renamed PyString to PyBytes
Diffstat (limited to 'Python')
-rw-r--r--Python/Python-ast.c22
-rw-r--r--Python/ast.c22
-rw-r--r--Python/bltinmodule.c8
-rw-r--r--Python/ceval.c2
-rw-r--r--Python/codecs.c4
-rw-r--r--Python/compile.c40
-rw-r--r--Python/getargs.c44
-rw-r--r--Python/import.c10
-rw-r--r--Python/marshal.c38
-rw-r--r--Python/modsupport.c2
-rw-r--r--Python/peephole.c14
-rw-r--r--Python/pystrtod.c2
-rw-r--r--Python/pythonrun.c2
-rw-r--r--Python/traceback.c6
14 files changed, 108 insertions, 108 deletions
diff --git a/Python/Python-ast.c b/Python/Python-ast.c
index 9e9ba06..12bff58 100644
--- a/Python/Python-ast.c
+++ b/Python/Python-ast.c
@@ -609,7 +609,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;
}
@@ -3485,7 +3485,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;
@@ -4595,7 +4595,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;
@@ -5616,7 +5616,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;
@@ -5654,7 +5654,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;
@@ -5766,7 +5766,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;
@@ -5788,7 +5788,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;
@@ -5850,7 +5850,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;
@@ -5880,7 +5880,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;
@@ -5934,7 +5934,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;
@@ -6100,7 +6100,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/ast.c b/Python/ast.c
index 1124a8b..da42a0e 100644
--- a/Python/ast.c
+++ b/Python/ast.c
@@ -2293,10 +2293,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) {
@@ -2307,8 +2307,8 @@ alias_for_import_name(struct compiling *c, const node *n)
}
--s;
*s = '\0';
- uni = PyUnicode_DecodeUTF8(PyString_AS_STRING(str),
- PyString_GET_SIZE(str),
+ uni = PyUnicode_DecodeUTF8(PyBytes_AS_STRING(str),
+ PyBytes_GET_SIZE(str),
NULL);
Py_DECREF(str);
if (!uni)
@@ -3146,10 +3146,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 == '\\') {
@@ -3168,7 +3168,7 @@ decode_unicode(struct compiling *c, const char *s, size_t len, int rawmode, cons
Py_DECREF(u);
return NULL;
}
- r = PyString_AS_STRING(w);
+ r = PyBytes_AS_STRING(w);
rn = Py_SIZE(w);
assert(rn % 2 == 0);
for (i = 0; i < rn; i += 2) {
@@ -3264,14 +3264,14 @@ parsestr(struct compiling *c, const node *n, int *bytesmode)
Py_DECREF(u);
return v;
} else if (*bytesmode) {
- return PyString_FromStringAndSize(s, len);
+ return PyBytes_FromStringAndSize(s, len);
} else if (strcmp(c->c_encoding, "utf-8") == 0) {
return PyUnicode_FromStringAndSize(s, len);
} else {
return PyUnicode_DecodeLatin1(s, len, NULL);
}
}
- return PyString_DecodeEscape(s, len, NULL, 1,
+ return PyBytes_DecodeEscape(s, len, NULL, 1,
need_encoding ? c->c_encoding : NULL);
}
@@ -3298,8 +3298,8 @@ parsestrplus(struct compiling *c, const node *n, int *bytesmode)
ast_error(n, "cannot mix bytes and nonbytes literals");
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 4ff0823..3dc6a00 100644
--- a/Python/bltinmodule.c
+++ b/Python/bltinmodule.c
@@ -1350,10 +1350,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 PyLong_FromLong(ord);
}
}
@@ -2267,7 +2267,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("classmethod", &PyClassMethod_Type);
#ifndef WITHOUT_COMPLEX
SETBUILTIN("complex", &PyComplex_Type);
diff --git a/Python/ceval.c b/Python/ceval.c
index defd002..3ea9059 100644
--- a/Python/ceval.c
+++ b/Python/ceval.c
@@ -742,7 +742,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
diff --git a/Python/codecs.c b/Python/codecs.c
index 554c1d2..33f0733 100644
--- a/Python/codecs.c
+++ b/Python/codecs.c
@@ -354,9 +354,9 @@ PyObject *PyCodec_Encode(PyObject *object,
v = NULL;
goto onError;
}
- v = PyString_FromStringAndSize(PyByteArray_AS_STRING(v), Py_SIZE(v));
+ v = PyBytes_FromStringAndSize(PyByteArray_AS_STRING(v), Py_SIZE(v));
}
- else if (PyString_Check(v))
+ else if (PyBytes_Check(v))
Py_INCREF(v);
else {
PyErr_SetString(PyExc_TypeError,
diff --git a/Python/compile.c b/Python/compile.c
index 6cc5c4a..c8a4f85 100644
--- a/Python/compile.c
+++ b/Python/compile.c
@@ -1225,8 +1225,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),
@@ -1285,7 +1285,7 @@ compiler_make_closure(struct compiler *c, PyCodeObject *co, int args)
"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,
PyUnicode_AsString(co->co_name),
PyObject_REPR(co->co_freevars));
@@ -3068,7 +3068,7 @@ expr_constant(expr_ty e)
return PyObject_IsTrue(e->v.Str.s);
case Name_kind:
/* optimize away names that can't be reassigned */
- id = PyString_AS_STRING(
+ id = PyBytes_AS_STRING(
_PyUnicode_AsDefaultEncodedString(e->v.Name.id, NULL));
if (strcmp(id, "True") == 0) return 1;
if (strcmp(id, "False") == 0) return 0;
@@ -3682,10 +3682,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(
@@ -3794,17 +3794,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;
@@ -3816,17 +3816,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;
@@ -3838,13 +3838,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) {
@@ -3869,7 +3869,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);
@@ -3880,10 +3880,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);
@@ -4177,9 +4177,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/getargs.c b/Python/getargs.c
index 2289bb6..ccd1817 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" :
@@ -762,8 +762,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 if (PyUnicode_Check(arg) &&
PyUnicode_GET_SIZE(arg) == 1 &&
PyUnicode_AS_UNICODE(arg)[0] < 256)
@@ -775,8 +775,8 @@ convertsimple(PyObject *arg, const char **p_format, va_list *p_va, int flags,
case 'C': {/* unicode char */
int *p = va_arg(*p_va, int *);
- 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 if (PyUnicode_Check(arg) &&
PyUnicode_GET_SIZE(arg) == 1)
*p = PyUnicode_AS_UNICODE(arg)[0];
@@ -798,8 +798,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));
}
else { /* any buffer-like object */
/* XXX Really? */
@@ -818,11 +818,11 @@ 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);
+ *p = PyBytes_AS_STRING(uarg);
}
else
return converterr("string", arg, msgbuf, bufsize);
- if ((Py_ssize_t) strlen(*p) != PyString_GET_SIZE(uarg))
+ if ((Py_ssize_t) strlen(*p) != PyBytes_GET_SIZE(uarg))
return converterr("string without null bytes",
arg, msgbuf, bufsize);
}
@@ -857,8 +857,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));
}
else { /* any buffer-like object */
/* XXX Really? */
@@ -875,17 +875,17 @@ convertsimple(PyObject *arg, const char **p_format, va_list *p_va, int flags,
if (arg == Py_None)
*p = 0;
- else if (PyString_Check(arg)) {
+ else if (PyBytes_Check(arg)) {
/* Enable null byte check below */
uarg = arg;
- *p = PyString_AS_STRING(arg);
+ *p = PyBytes_AS_STRING(arg);
}
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);
}
else
return converterr("string or None",
@@ -897,12 +897,12 @@ convertsimple(PyObject *arg, const char **p_format, va_list *p_va, int flags,
STORE_SIZE(0);
}
else {
- STORE_SIZE(PyString_Size(arg));
+ STORE_SIZE(PyBytes_Size(arg));
}
format++;
}
else if (*p != NULL && uarg != NULL &&
- (Py_ssize_t) strlen(*p) != PyString_GET_SIZE(uarg))
+ (Py_ssize_t) strlen(*p) != PyBytes_GET_SIZE(uarg))
return converterr(
"string without null bytes or None",
arg, msgbuf, bufsize);
@@ -971,7 +971,7 @@ convertsimple(PyObject *arg, const char **p_format, va_list *p_va, int flags,
/* Encode object */
if (!recode_strings &&
- (PyString_Check(arg) || PyByteArray_Check(arg))) {
+ (PyBytes_Check(arg) || PyByteArray_Check(arg))) {
s = arg;
Py_INCREF(s);
if (PyObject_AsCharBuffer(s, &ptr, &size) < 0)
@@ -996,14 +996,14 @@ 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 bytes)",
arg, msgbuf, bufsize);
}
- size = PyString_GET_SIZE(s);
- ptr = PyString_AS_STRING(s);
+ size = PyBytes_GET_SIZE(s);
+ ptr = PyBytes_AS_STRING(s);
if (ptr == NULL)
ptr = "";
}
@@ -1114,9 +1114,9 @@ convertsimple(PyObject *arg, const char **p_format, va_list *p_va, int flags,
break;
}
- case 'S': { /* PyString object */
+ case 'S': { /* PyBytes object */
PyObject **p = va_arg(*p_va, PyObject **);
- if (PyString_Check(arg))
+ if (PyBytes_Check(arg))
*p = arg;
else
return converterr("bytes", arg, msgbuf, bufsize);
diff --git a/Python/import.c b/Python/import.c
index 5dabd9f..31e2401 100644
--- a/Python/import.c
+++ b/Python/import.c
@@ -1322,10 +1322,10 @@ find_module(char *fullname, char *subname, PyObject *path, char *buf,
if (v == NULL)
return NULL;
}
- if (!PyString_Check(v))
+ if (!PyBytes_Check(v))
continue;
- base = PyString_AS_STRING(v);
- size = PyString_GET_SIZE(v);
+ base = PyBytes_AS_STRING(v);
+ size = PyBytes_GET_SIZE(v);
len = size;
if (len + 2 + namelen + MAXSUFFIXSIZE >= buflen) {
continue; /* Too long */
@@ -2385,7 +2385,7 @@ ensure_fromlist(PyObject *mod, PyObject *fromlist, char *buf, Py_ssize_t buflen,
PyErr_SetString(PyExc_ValueError, "Cannot encode path item");
return 0;
}
- subname = PyString_AS_STRING(item8);
+ subname = PyBytes_AS_STRING(item8);
if (buflen + strlen(subname) >= MAXPATHLEN) {
PyErr_SetString(PyExc_ValueError,
"Module name too long");
@@ -2691,7 +2691,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/marshal.c b/Python/marshal.c
index 5672a06..f7eb445 100644
--- a/Python/marshal.c
+++ b/Python/marshal.c
@@ -67,18 +67,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);
}
}
@@ -231,9 +231,9 @@ w_object(PyObject *v, WFILE *p)
}
}
#endif
- else if (PyString_CheckExact(v)) {
+ else if (PyBytes_CheckExact(v)) {
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--;
@@ -241,7 +241,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);
}
else if (PyUnicode_CheckExact(v)) {
PyObject *utf8;
@@ -252,14 +252,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);
}
else if (PyTuple_CheckExact(v)) {
@@ -686,12 +686,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");
@@ -1064,11 +1064,11 @@ PyMarshal_WriteObjectToString(PyObject *x, int version)
PyObject *res = NULL;
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;
@@ -1076,14 +1076,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 marshal data for a string");
return NULL;
}
- if (_PyString_Resize(&wf.str, (Py_ssize_t)(wf.ptr - base)) < 0)
+ if (_PyBytes_Resize(&wf.str, (Py_ssize_t)(wf.ptr - base)) < 0)
return NULL;
}
if (wf.error) {
@@ -1132,9 +1132,9 @@ marshal_load(PyObject *self, PyObject *f)
if (data == NULL)
return NULL;
rf.fp = NULL;
- if (PyString_Check(data)) {
- rf.ptr = PyString_AS_STRING(data);
- rf.end = rf.ptr + PyString_GET_SIZE(data);
+ if (PyBytes_Check(data)) {
+ rf.ptr = PyBytes_AS_STRING(data);
+ rf.end = rf.ptr + PyBytes_GET_SIZE(data);
}
else if (PyByteArray_Check(data)) {
rf.ptr = PyByteArray_AS_STRING(data);
diff --git a/Python/modsupport.c b/Python/modsupport.c
index 3d90ede..5e43aca 100644
--- a/Python/modsupport.c
+++ b/Python/modsupport.c
@@ -498,7 +498,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;
}
diff --git a/Python/peephole.c b/Python/peephole.c
index db5ca33..30789e4 100644
--- a/Python/peephole.c
+++ b/Python/peephole.c
@@ -325,15 +325,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;
@@ -342,7 +342,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
@@ -632,7 +632,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 7f6966a..2e93a3a 100644
--- a/Python/pythonrun.c
+++ b/Python/pythonrun.c
@@ -459,7 +459,7 @@ Py_Finalize(void)
PyTuple_Fini();
PyList_Fini();
PySet_Fini();
- PyString_Fini();
+ PyBytes_Fini();
PyByteArray_Fini();
PyLong_Fini();
PyFloat_Fini();
diff --git a/Python/traceback.c b/Python/traceback.c
index bbc8e16..76e22a1 100644
--- a/Python/traceback.c
+++ b/Python/traceback.c
@@ -161,12 +161,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)