summaryrefslogtreecommitdiffstats
path: root/Objects
diff options
context:
space:
mode:
authorGregory P. Smith <greg@mad-scientist.com>2008-06-09 04:58:54 (GMT)
committerGregory P. Smith <greg@mad-scientist.com>2008-06-09 04:58:54 (GMT)
commitdd96db63f689e2f0d8ae5a1436b3b3395eec7de5 (patch)
treeb2299acac9ce44fc488fc7b2ae2a44548cd5fbb8 /Objects
parente98839a1f48b2915f1cc747884e64f4d6e4c8e7a (diff)
downloadcpython-dd96db63f689e2f0d8ae5a1436b3b3395eec7de5.zip
cpython-dd96db63f689e2f0d8ae5a1436b3b3395eec7de5.tar.gz
cpython-dd96db63f689e2f0d8ae5a1436b3b3395eec7de5.tar.bz2
This reverts r63675 based on the discussion in this thread:
http://mail.python.org/pipermail/python-dev/2008-June/079988.html Python 2.6 should stick with PyString_* in its codebase. The PyBytes_* names in the spirit of 3.0 are available via a #define only. See the email thread.
Diffstat (limited to 'Objects')
-rw-r--r--Objects/abstract.c44
-rw-r--r--Objects/boolobject.c4
-rw-r--r--Objects/bufferobject.c26
-rw-r--r--Objects/bytes_methods.c20
-rw-r--r--Objects/bytesobject.c22
-rw-r--r--Objects/cellobject.c4
-rw-r--r--Objects/classobject.c174
-rw-r--r--Objects/codeobject.c44
-rw-r--r--Objects/complexobject.c18
-rw-r--r--Objects/descrobject.c22
-rw-r--r--Objects/dictobject.c78
-rw-r--r--Objects/exceptions.c96
-rw-r--r--Objects/fileobject.c108
-rw-r--r--Objects/floatobject.c22
-rw-r--r--Objects/frameobject.c10
-rw-r--r--Objects/funcobject.c16
-rw-r--r--Objects/genobject.c4
-rw-r--r--Objects/intobject.c14
-rw-r--r--Objects/listobject.c20
-rw-r--r--Objects/longobject.c32
-rw-r--r--Objects/methodobject.c12
-rw-r--r--Objects/moduleobject.c22
-rw-r--r--Objects/object.c58
-rw-r--r--Objects/rangeobject.c6
-rw-r--r--Objects/setobject.c30
-rw-r--r--Objects/sliceobject.c18
-rw-r--r--Objects/stringlib/string_format.h2
-rw-r--r--Objects/stringlib/stringdefs.h14
-rw-r--r--Objects/structseq.c4
-rw-r--r--Objects/tupleobject.c16
-rw-r--r--Objects/typeobject.c120
-rw-r--r--Objects/unicodeobject.c132
-rw-r--r--Objects/weakrefobject.c8
33 files changed, 610 insertions, 610 deletions
diff --git a/Objects/abstract.c b/Objects/abstract.c
index aa30129e..1d5c4d5 100644
--- a/Objects/abstract.c
+++ b/Objects/abstract.c
@@ -105,7 +105,7 @@ _PyObject_LengthHint(PyObject *o, Py_ssize_t defaultvalue)
/* cache a hashed version of the attribute string */
if (hintstrobj == NULL) {
- hintstrobj = PyBytes_InternFromString("__length_hint__");
+ hintstrobj = PyString_InternFromString("__length_hint__");
if (hintstrobj == NULL)
goto defaultcase;
}
@@ -227,7 +227,7 @@ PyObject_DelItemString(PyObject *o, char *key)
null_error();
return -1;
}
- okey = PyBytes_FromString(key);
+ okey = PyString_FromString(key);
if (okey == NULL)
return -1;
ret = PyObject_DelItem(o, okey);
@@ -723,21 +723,21 @@ PyObject_Format(PyObject* obj, PyObject *format_spec)
/* Initialize cached value */
if (str__format__ == NULL) {
/* Initialize static variable needed by _PyType_Lookup */
- str__format__ = PyBytes_InternFromString("__format__");
+ str__format__ = PyString_InternFromString("__format__");
if (str__format__ == NULL)
goto done;
}
/* If no format_spec is provided, use an empty string */
if (format_spec == NULL) {
- empty = PyBytes_FromStringAndSize(NULL, 0);
+ empty = PyString_FromStringAndSize(NULL, 0);
format_spec = empty;
}
/* Check the format_spec type, and make sure it's str or unicode */
if (PyUnicode_Check(format_spec))
spec_is_unicode = 1;
- else if (PyBytes_Check(format_spec))
+ else if (PyString_Check(format_spec))
spec_is_unicode = 0;
else {
PyErr_Format(PyExc_TypeError,
@@ -817,7 +817,7 @@ PyObject_Format(PyObject* obj, PyObject *format_spec)
/* Check the result type, and make sure it's str or unicode */
if (PyUnicode_Check(result))
result_is_unicode = 1;
- else if (PyBytes_Check(result))
+ else if (PyString_Check(result))
result_is_unicode = 0;
else {
PyErr_Format(PyExc_TypeError,
@@ -1535,7 +1535,7 @@ _PyNumber_ConvertIntegralToInt(PyObject *integral, const char* error_format)
const char *type_name;
static PyObject *int_name = NULL;
if (int_name == NULL) {
- int_name = PyBytes_InternFromString("__int__");
+ int_name = PyString_InternFromString("__int__");
if (int_name == NULL)
return NULL;
}
@@ -1561,7 +1561,7 @@ _PyNumber_ConvertIntegralToInt(PyObject *integral, const char* error_format)
non_integral_error:
if (PyInstance_Check(integral)) {
- type_name = PyBytes_AS_STRING(((PyInstanceObject *)integral)
+ type_name = PyString_AS_STRING(((PyInstanceObject *)integral)
->in_class->cl_name);
}
else {
@@ -1583,7 +1583,7 @@ PyNumber_Int(PyObject *o)
Py_ssize_t buffer_len;
if (trunc_name == NULL) {
- trunc_name = PyBytes_InternFromString("__trunc__");
+ trunc_name = PyString_InternFromString("__trunc__");
if (trunc_name == NULL)
return NULL;
}
@@ -1623,9 +1623,9 @@ PyNumber_Int(PyObject *o)
}
PyErr_Clear(); /* It's not an error if o.__trunc__ doesn't exist. */
- if (PyBytes_Check(o))
- return int_from_string(PyBytes_AS_STRING(o),
- PyBytes_GET_SIZE(o));
+ if (PyString_Check(o))
+ return int_from_string(PyString_AS_STRING(o),
+ PyString_GET_SIZE(o));
#ifdef Py_USING_UNICODE
if (PyUnicode_Check(o))
return PyInt_FromUnicode(PyUnicode_AS_UNICODE(o),
@@ -1668,7 +1668,7 @@ PyNumber_Long(PyObject *o)
Py_ssize_t buffer_len;
if (trunc_name == NULL) {
- trunc_name = PyBytes_InternFromString("__trunc__");
+ trunc_name = PyString_InternFromString("__trunc__");
if (trunc_name == NULL)
return NULL;
}
@@ -1710,13 +1710,13 @@ PyNumber_Long(PyObject *o)
}
PyErr_Clear(); /* It's not an error if o.__trunc__ doesn't exist. */
- if (PyBytes_Check(o))
+ if (PyString_Check(o))
/* need to do extra error checking that PyLong_FromString()
* doesn't do. In particular long('9.5') must raise an
* exception, not truncate the float.
*/
- return long_from_string(PyBytes_AS_STRING(o),
- PyBytes_GET_SIZE(o));
+ return long_from_string(PyString_AS_STRING(o),
+ PyString_GET_SIZE(o));
#ifdef Py_USING_UNICODE
if (PyUnicode_Check(o))
/* The above check is done in PyLong_FromUnicode(). */
@@ -2407,7 +2407,7 @@ PyMapping_GetItemString(PyObject *o, char *key)
if (key == NULL)
return null_error();
- okey = PyBytes_FromString(key);
+ okey = PyString_FromString(key);
if (okey == NULL)
return NULL;
r = PyObject_GetItem(o, okey);
@@ -2426,7 +2426,7 @@ PyMapping_SetItemString(PyObject *o, char *key, PyObject *value)
return -1;
}
- okey = PyBytes_FromString(key);
+ okey = PyString_FromString(key);
if (okey == NULL)
return -1;
r = PyObject_SetItem(o, okey, value);
@@ -2754,7 +2754,7 @@ abstract_get_bases(PyObject *cls)
PyObject *bases;
if (__bases__ == NULL) {
- __bases__ = PyBytes_InternFromString("__bases__");
+ __bases__ = PyString_InternFromString("__bases__");
if (__bases__ == NULL)
return NULL;
}
@@ -2832,7 +2832,7 @@ recursive_isinstance(PyObject *inst, PyObject *cls, int recursion_depth)
int retval = 0;
if (__class__ == NULL) {
- __class__ = PyBytes_InternFromString("__class__");
+ __class__ = PyString_InternFromString("__class__");
if (__class__ == NULL)
return -1;
}
@@ -2908,7 +2908,7 @@ PyObject_IsInstance(PyObject *inst, PyObject *cls)
return 1;
if (name == NULL) {
- name = PyBytes_InternFromString("__instancecheck__");
+ name = PyString_InternFromString("__instancecheck__");
if (name == NULL)
return -1;
}
@@ -2992,7 +2992,7 @@ PyObject_IsSubclass(PyObject *derived, PyObject *cls)
PyErr_Fetch(&t, &v, &tb);
if (name == NULL) {
- name = PyBytes_InternFromString("__subclasscheck__");
+ name = PyString_InternFromString("__subclasscheck__");
if (name == NULL)
return -1;
}
diff --git a/Objects/boolobject.c b/Objects/boolobject.c
index 93affd1..fd73d28 100644
--- a/Objects/boolobject.c
+++ b/Objects/boolobject.c
@@ -25,10 +25,10 @@ bool_repr(PyBoolObject *self)
if (self->ob_ival)
s = true_str ? true_str :
- (true_str = PyBytes_InternFromString("True"));
+ (true_str = PyString_InternFromString("True"));
else
s = false_str ? false_str :
- (false_str = PyBytes_InternFromString("False"));
+ (false_str = PyString_InternFromString("False"));
Py_XINCREF(s);
return s;
}
diff --git a/Objects/bufferobject.c b/Objects/bufferobject.c
index ee8dd3d..37d9bcb 100644
--- a/Objects/bufferobject.c
+++ b/Objects/bufferobject.c
@@ -287,13 +287,13 @@ buffer_repr(PyBufferObject *self)
const char *status = self->b_readonly ? "read-only" : "read-write";
if ( self->b_base == NULL )
- return PyBytes_FromFormat("<%s buffer ptr %p, size %zd at %p>",
+ return PyString_FromFormat("<%s buffer ptr %p, size %zd at %p>",
status,
self->b_ptr,
self->b_size,
self);
else
- return PyBytes_FromFormat(
+ return PyString_FromFormat(
"<%s buffer for %p, size %zd, offset %zd at %p>",
status,
self->b_base,
@@ -318,7 +318,7 @@ buffer_hash(PyBufferObject *self)
* underlying memory is immutable. b_readonly is a necessary but not
* sufficient condition for a buffer to be hashable. Perhaps it would
* be better to only allow hashing if the underlying object is known to
- * be immutable (e.g. PyBytes_Check() is true). Another idea would
+ * be immutable (e.g. PyString_Check() is true). Another idea would
* be to call tp_hash on the underlying object and see if it raises
* an error. */
if ( !self->b_readonly )
@@ -349,7 +349,7 @@ buffer_str(PyBufferObject *self)
Py_ssize_t size;
if (!get_buf(self, &ptr, &size, ANY_BUFFER))
return NULL;
- return PyBytes_FromStringAndSize((const char *)ptr, size);
+ return PyString_FromStringAndSize((const char *)ptr, size);
}
/* Sequence methods */
@@ -401,10 +401,10 @@ buffer_concat(PyBufferObject *self, PyObject *other)
if ( (count = (*pb->bf_getreadbuffer)(other, 0, &ptr2)) < 0 )
return NULL;
- ob = PyBytes_FromStringAndSize(NULL, size + count);
+ ob = PyString_FromStringAndSize(NULL, size + count);
if ( ob == NULL )
return NULL;
- p = PyBytes_AS_STRING(ob);
+ p = PyString_AS_STRING(ob);
memcpy(p, ptr1, size);
memcpy(p + size, ptr2, count);
@@ -426,11 +426,11 @@ buffer_repeat(PyBufferObject *self, Py_ssize_t count)
count = 0;
if (!get_buf(self, &ptr, &size, ANY_BUFFER))
return NULL;
- ob = PyBytes_FromStringAndSize(NULL, size * count);
+ ob = PyString_FromStringAndSize(NULL, size * count);
if ( ob == NULL )
return NULL;
- p = PyBytes_AS_STRING(ob);
+ p = PyString_AS_STRING(ob);
while ( count-- )
{
memcpy(p, ptr, size);
@@ -454,7 +454,7 @@ buffer_item(PyBufferObject *self, Py_ssize_t idx)
PyErr_SetString(PyExc_IndexError, "buffer index out of range");
return NULL;
}
- return PyBytes_FromStringAndSize((char *)ptr + idx, 1);
+ return PyString_FromStringAndSize((char *)ptr + idx, 1);
}
static PyObject *
@@ -472,7 +472,7 @@ buffer_slice(PyBufferObject *self, Py_ssize_t left, Py_ssize_t right)
right = size;
if ( right < left )
right = left;
- return PyBytes_FromStringAndSize((char *)ptr + left,
+ return PyString_FromStringAndSize((char *)ptr + left,
right - left);
}
@@ -501,9 +501,9 @@ buffer_subscript(PyBufferObject *self, PyObject *item)
}
if (slicelength <= 0)
- return PyBytes_FromStringAndSize("", 0);
+ return PyString_FromStringAndSize("", 0);
else if (step == 1)
- return PyBytes_FromStringAndSize((char *)p + start,
+ return PyString_FromStringAndSize((char *)p + start,
stop - start);
else {
PyObject *result;
@@ -518,7 +518,7 @@ buffer_subscript(PyBufferObject *self, PyObject *item)
result_buf[i] = source_buf[cur];
}
- result = PyBytes_FromStringAndSize(result_buf,
+ result = PyString_FromStringAndSize(result_buf,
slicelength);
PyMem_Free(result_buf);
return result;
diff --git a/Objects/bytes_methods.c b/Objects/bytes_methods.c
index 2d55601..de87905 100644
--- a/Objects/bytes_methods.c
+++ b/Objects/bytes_methods.c
@@ -462,11 +462,11 @@ _Py_bytes_lower(char *result, const char *cptr, Py_ssize_t len)
Py_ssize_t i;
/*
- newobj = PyBytes_FromStringAndSize(NULL, len);
+ newobj = PyString_FromStringAndSize(NULL, len);
if (!newobj)
return NULL;
- s = PyBytes_AS_STRING(newobj);
+ s = PyString_AS_STRING(newobj);
*/
Py_MEMCPY(result, cptr, len);
@@ -490,11 +490,11 @@ _Py_bytes_upper(char *result, const char *cptr, Py_ssize_t len)
Py_ssize_t i;
/*
- newobj = PyBytes_FromStringAndSize(NULL, len);
+ newobj = PyString_FromStringAndSize(NULL, len);
if (!newobj)
return NULL;
- s = PyBytes_AS_STRING(newobj);
+ s = PyString_AS_STRING(newobj);
*/
Py_MEMCPY(result, cptr, len);
@@ -520,10 +520,10 @@ _Py_bytes_title(char *result, char *s, Py_ssize_t len)
int previous_is_cased = 0;
/*
- newobj = PyBytes_FromStringAndSize(NULL, len);
+ newobj = PyString_FromStringAndSize(NULL, len);
if (newobj == NULL)
return NULL;
- s_new = PyBytes_AsString(newobj);
+ s_new = PyString_AsString(newobj);
*/
for (i = 0; i < len; i++) {
int c = Py_CHARMASK(*s++);
@@ -553,10 +553,10 @@ _Py_bytes_capitalize(char *result, char *s, Py_ssize_t len)
Py_ssize_t i;
/*
- newobj = PyBytes_FromStringAndSize(NULL, len);
+ newobj = PyString_FromStringAndSize(NULL, len);
if (newobj == NULL)
return NULL;
- s_new = PyBytes_AsString(newobj);
+ s_new = PyString_AsString(newobj);
*/
if (0 < len) {
int c = Py_CHARMASK(*s++);
@@ -589,10 +589,10 @@ _Py_bytes_swapcase(char *result, char *s, Py_ssize_t len)
Py_ssize_t i;
/*
- newobj = PyBytes_FromStringAndSize(NULL, len);
+ newobj = PyString_FromStringAndSize(NULL, len);
if (newobj == NULL)
return NULL;
- s_new = PyBytes_AsString(newobj);
+ s_new = PyString_AsString(newobj);
*/
for (i = 0; i < len; i++) {
int c = Py_CHARMASK(*s++);
diff --git a/Objects/bytesobject.c b/Objects/bytesobject.c
index 61ee42ab..d0e4e26 100644
--- a/Objects/bytesobject.c
+++ b/Objects/bytesobject.c
@@ -87,13 +87,13 @@ PyBytes_FromStringAndSize(const char *str, Py_ssize_t size)
/* share short strings */
if (size == 0) {
PyObject *t = (PyObject *)op;
- PyBytes_InternInPlace(&t);
+ PyString_InternInPlace(&t);
op = (PyBytesObject *)t;
nullstring = op;
Py_INCREF(op);
} else if (size == 1 && str != NULL) {
PyObject *t = (PyObject *)op;
- PyBytes_InternInPlace(&t);
+ PyString_InternInPlace(&t);
op = (PyBytesObject *)t;
characters[*str & UCHAR_MAX] = op;
Py_INCREF(op);
@@ -140,13 +140,13 @@ PyBytes_FromString(const char *str)
/* share short strings */
if (size == 0) {
PyObject *t = (PyObject *)op;
- PyBytes_InternInPlace(&t);
+ PyString_InternInPlace(&t);
op = (PyBytesObject *)t;
nullstring = op;
Py_INCREF(op);
} else if (size == 1) {
PyObject *t = (PyObject *)op;
- PyBytes_InternInPlace(&t);
+ PyString_InternInPlace(&t);
op = (PyBytesObject *)t;
characters[*str & UCHAR_MAX] = op;
Py_INCREF(op);
@@ -5093,12 +5093,12 @@ PyBytes_Format(PyObject *format, PyObject *args)
}
void
-PyBytes_InternInPlace(PyObject **p)
+PyString_InternInPlace(PyObject **p)
{
register PyBytesObject *s = (PyBytesObject *)(*p);
PyObject *t;
if (s == NULL || !PyBytes_Check(s))
- Py_FatalError("PyBytes_InternInPlace: strings only please!");
+ Py_FatalError("PyString_InternInPlace: strings only please!");
/* If it's a string subclass, we don't really know what putting
it in the interned dict might do. */
if (!PyBytes_CheckExact(s))
@@ -5131,9 +5131,9 @@ PyBytes_InternInPlace(PyObject **p)
}
void
-PyBytes_InternImmortal(PyObject **p)
+PyString_InternImmortal(PyObject **p)
{
- PyBytes_InternInPlace(p);
+ PyString_InternInPlace(p);
if (PyBytes_CHECK_INTERNED(*p) != SSTATE_INTERNED_IMMORTAL) {
PyBytes_CHECK_INTERNED(*p) = SSTATE_INTERNED_IMMORTAL;
Py_INCREF(*p);
@@ -5142,17 +5142,17 @@ PyBytes_InternImmortal(PyObject **p)
PyObject *
-PyBytes_InternFromString(const char *cp)
+PyString_InternFromString(const char *cp)
{
PyObject *s = PyBytes_FromString(cp);
if (s == NULL)
return NULL;
- PyBytes_InternInPlace(&s);
+ PyString_InternInPlace(&s);
return s;
}
void
-PyBytes_Fini(void)
+PyString_Fini(void)
{
int i;
for (i = 0; i < UCHAR_MAX + 1; i++) {
diff --git a/Objects/cellobject.c b/Objects/cellobject.c
index 16bb150..4e0bcf8 100644
--- a/Objects/cellobject.c
+++ b/Objects/cellobject.c
@@ -73,9 +73,9 @@ static PyObject *
cell_repr(PyCellObject *op)
{
if (op->ob_ref == NULL)
- return PyBytes_FromFormat("<cell at %p: empty>", op);
+ return PyString_FromFormat("<cell at %p: empty>", op);
- return PyBytes_FromFormat("<cell at %p: %.80s object at %p>",
+ return PyString_FromFormat("<cell at %p: %.80s object at %p>",
op, op->ob_ref->ob_type->tp_name,
op->ob_ref);
}
diff --git a/Objects/classobject.c b/Objects/classobject.c
index 372a40e..caf6b3e 100644
--- a/Objects/classobject.c
+++ b/Objects/classobject.c
@@ -32,21 +32,21 @@ PyClass_New(PyObject *bases, PyObject *dict, PyObject *name)
PyClassObject *op, *dummy;
static PyObject *docstr, *modstr, *namestr;
if (docstr == NULL) {
- docstr= PyBytes_InternFromString("__doc__");
+ docstr= PyString_InternFromString("__doc__");
if (docstr == NULL)
return NULL;
}
if (modstr == NULL) {
- modstr= PyBytes_InternFromString("__module__");
+ modstr= PyString_InternFromString("__module__");
if (modstr == NULL)
return NULL;
}
if (namestr == NULL) {
- namestr= PyBytes_InternFromString("__name__");
+ namestr= PyString_InternFromString("__name__");
if (namestr == NULL)
return NULL;
}
- if (name == NULL || !PyBytes_Check(name)) {
+ if (name == NULL || !PyString_Check(name)) {
PyErr_SetString(PyExc_TypeError,
"PyClass_New: name must be a string");
return NULL;
@@ -101,13 +101,13 @@ PyClass_New(PyObject *bases, PyObject *dict, PyObject *name)
}
if (getattrstr == NULL) {
- getattrstr = PyBytes_InternFromString("__getattr__");
+ getattrstr = PyString_InternFromString("__getattr__");
if (getattrstr == NULL)
goto alloc_error;
- setattrstr = PyBytes_InternFromString("__setattr__");
+ setattrstr = PyString_InternFromString("__setattr__");
if (setattrstr == NULL)
goto alloc_error;
- delattrstr = PyBytes_InternFromString("__delattr__");
+ delattrstr = PyString_InternFromString("__delattr__");
if (delattrstr == NULL)
goto alloc_error;
}
@@ -222,7 +222,7 @@ static PyObject *
class_getattr(register PyClassObject *op, PyObject *name)
{
register PyObject *v;
- register char *sname = PyBytes_AsString(name);
+ register char *sname = PyString_AsString(name);
PyClassObject *klass;
descrgetfunc f;
@@ -253,7 +253,7 @@ class_getattr(register PyClassObject *op, PyObject *name)
if (v == NULL) {
PyErr_Format(PyExc_AttributeError,
"class %.50s has no attribute '%.400s'",
- PyBytes_AS_STRING(op->cl_name), sname);
+ PyString_AS_STRING(op->cl_name), sname);
return NULL;
}
f = TP_DESCR_GET(v->ob_type);
@@ -316,9 +316,9 @@ set_bases(PyClassObject *c, PyObject *v)
static char *
set_name(PyClassObject *c, PyObject *v)
{
- if (v == NULL || !PyBytes_Check(v))
+ if (v == NULL || !PyString_Check(v))
return "__name__ must be a string object";
- if (strlen(PyBytes_AS_STRING(v)) != (size_t)PyBytes_GET_SIZE(v))
+ if (strlen(PyString_AS_STRING(v)) != (size_t)PyString_GET_SIZE(v))
return "__name__ must not contain null bytes";
set_slot(&c->cl_name, v);
return "";
@@ -333,9 +333,9 @@ class_setattr(PyClassObject *op, PyObject *name, PyObject *v)
"classes are read-only in restricted mode");
return -1;
}
- sname = PyBytes_AsString(name);
+ sname = PyString_AsString(name);
if (sname[0] == '_' && sname[1] == '_') {
- Py_ssize_t n = PyBytes_Size(name);
+ Py_ssize_t n = PyString_Size(name);
if (sname[n-1] == '_' && sname[n-2] == '_') {
char *err = NULL;
if (strcmp(sname, "__dict__") == 0)
@@ -365,7 +365,7 @@ class_setattr(PyClassObject *op, PyObject *name, PyObject *v)
if (rv < 0)
PyErr_Format(PyExc_AttributeError,
"class %.50s has no attribute '%.400s'",
- PyBytes_AS_STRING(op->cl_name), sname);
+ PyString_AS_STRING(op->cl_name), sname);
return rv;
}
else
@@ -377,15 +377,15 @@ class_repr(PyClassObject *op)
{
PyObject *mod = PyDict_GetItemString(op->cl_dict, "__module__");
char *name;
- if (op->cl_name == NULL || !PyBytes_Check(op->cl_name))
+ if (op->cl_name == NULL || !PyString_Check(op->cl_name))
name = "?";
else
- name = PyBytes_AsString(op->cl_name);
- if (mod == NULL || !PyBytes_Check(mod))
- return PyBytes_FromFormat("<class ?.%s at %p>", name, op);
+ name = PyString_AsString(op->cl_name);
+ if (mod == NULL || !PyString_Check(mod))
+ return PyString_FromFormat("<class ?.%s at %p>", name, op);
else
- return PyBytes_FromFormat("<class %s.%s at %p>",
- PyBytes_AsString(mod),
+ return PyString_FromFormat("<class %s.%s at %p>",
+ PyString_AsString(mod),
name, op);
}
@@ -397,21 +397,21 @@ class_str(PyClassObject *op)
PyObject *res;
Py_ssize_t m, n;
- if (name == NULL || !PyBytes_Check(name))
+ if (name == NULL || !PyString_Check(name))
return class_repr(op);
- if (mod == NULL || !PyBytes_Check(mod)) {
+ if (mod == NULL || !PyString_Check(mod)) {
Py_INCREF(name);
return name;
}
- m = PyBytes_GET_SIZE(mod);
- n = PyBytes_GET_SIZE(name);
- res = PyBytes_FromStringAndSize((char *)NULL, m+1+n);
+ m = PyString_GET_SIZE(mod);
+ n = PyString_GET_SIZE(name);
+ res = PyString_FromStringAndSize((char *)NULL, m+1+n);
if (res != NULL) {
- char *s = PyBytes_AS_STRING(res);
- memcpy(s, PyBytes_AS_STRING(mod), m);
+ char *s = PyString_AS_STRING(res);
+ memcpy(s, PyString_AS_STRING(mod), m);
s += m;
*s++ = '.';
- memcpy(s, PyBytes_AS_STRING(name), n);
+ memcpy(s, PyString_AS_STRING(name), n);
}
return res;
}
@@ -541,7 +541,7 @@ PyInstance_New(PyObject *klass, PyObject *arg, PyObject *kw)
static PyObject *initstr;
if (initstr == NULL) {
- initstr = PyBytes_InternFromString("__init__");
+ initstr = PyString_InternFromString("__init__");
if (initstr == NULL)
return NULL;
}
@@ -634,7 +634,7 @@ instance_dealloc(register PyInstanceObject *inst)
PyErr_Fetch(&error_type, &error_value, &error_traceback);
/* Execute __del__ method, if any. */
if (delstr == NULL) {
- delstr = PyBytes_InternFromString("__del__");
+ delstr = PyString_InternFromString("__del__");
if (delstr == NULL)
PyErr_WriteUnraisable((PyObject*)inst);
}
@@ -696,7 +696,7 @@ static PyObject *
instance_getattr1(register PyInstanceObject *inst, PyObject *name)
{
register PyObject *v;
- register char *sname = PyBytes_AsString(name);
+ register char *sname = PyString_AsString(name);
if (sname[0] == '_' && sname[1] == '_') {
if (strcmp(sname, "__dict__") == 0) {
if (PyEval_GetRestricted()) {
@@ -716,7 +716,7 @@ instance_getattr1(register PyInstanceObject *inst, PyObject *name)
if (v == NULL && !PyErr_Occurred()) {
PyErr_Format(PyExc_AttributeError,
"%.50s instance has no attribute '%.400s'",
- PyBytes_AS_STRING(inst->in_class->cl_name), sname);
+ PyString_AS_STRING(inst->in_class->cl_name), sname);
}
return v;
}
@@ -779,7 +779,7 @@ _PyInstance_Lookup(PyObject *pinst, PyObject *name)
assert(PyInstance_Check(pinst));
inst = (PyInstanceObject *)pinst;
- assert(PyBytes_Check(name));
+ assert(PyString_Check(name));
v = PyDict_GetItem(inst->in_dict, name);
if (v == NULL)
@@ -795,8 +795,8 @@ instance_setattr1(PyInstanceObject *inst, PyObject *name, PyObject *v)
if (rv < 0)
PyErr_Format(PyExc_AttributeError,
"%.50s instance has no attribute '%.400s'",
- PyBytes_AS_STRING(inst->in_class->cl_name),
- PyBytes_AS_STRING(name));
+ PyString_AS_STRING(inst->in_class->cl_name),
+ PyString_AS_STRING(name));
return rv;
}
else
@@ -807,9 +807,9 @@ static int
instance_setattr(PyInstanceObject *inst, PyObject *name, PyObject *v)
{
PyObject *func, *args, *res, *tmp;
- char *sname = PyBytes_AsString(name);
+ char *sname = PyString_AsString(name);
if (sname[0] == '_' && sname[1] == '_') {
- Py_ssize_t n = PyBytes_Size(name);
+ Py_ssize_t n = PyString_Size(name);
if (sname[n-1] == '_' && sname[n-2] == '_') {
if (strcmp(sname, "__dict__") == 0) {
if (PyEval_GetRestricted()) {
@@ -875,7 +875,7 @@ instance_repr(PyInstanceObject *inst)
static PyObject *reprstr;
if (reprstr == NULL) {
- reprstr = PyBytes_InternFromString("__repr__");
+ reprstr = PyString_InternFromString("__repr__");
if (reprstr == NULL)
return NULL;
}
@@ -889,16 +889,16 @@ instance_repr(PyInstanceObject *inst)
classname = inst->in_class->cl_name;
mod = PyDict_GetItemString(inst->in_class->cl_dict,
"__module__");
- if (classname != NULL && PyBytes_Check(classname))
- cname = PyBytes_AsString(classname);
+ if (classname != NULL && PyString_Check(classname))
+ cname = PyString_AsString(classname);
else
cname = "?";
- if (mod == NULL || !PyBytes_Check(mod))
- return PyBytes_FromFormat("<?.%s instance at %p>",
+ if (mod == NULL || !PyString_Check(mod))
+ return PyString_FromFormat("<?.%s instance at %p>",
cname, inst);
else
- return PyBytes_FromFormat("<%s.%s instance at %p>",
- PyBytes_AsString(mod),
+ return PyString_FromFormat("<%s.%s instance at %p>",
+ PyString_AsString(mod),
cname, inst);
}
res = PyEval_CallObject(func, (PyObject *)NULL);
@@ -914,7 +914,7 @@ instance_str(PyInstanceObject *inst)
static PyObject *strstr;
if (strstr == NULL) {
- strstr = PyBytes_InternFromString("__str__");
+ strstr = PyString_InternFromString("__str__");
if (strstr == NULL)
return NULL;
}
@@ -939,7 +939,7 @@ instance_hash(PyInstanceObject *inst)
static PyObject *hashstr, *eqstr, *cmpstr;
if (hashstr == NULL) {
- hashstr = PyBytes_InternFromString("__hash__");
+ hashstr = PyString_InternFromString("__hash__");
if (hashstr == NULL)
return -1;
}
@@ -952,7 +952,7 @@ instance_hash(PyInstanceObject *inst)
address. If an __eq__ or __cmp__ method exists, there must
be a __hash__. */
if (eqstr == NULL) {
- eqstr = PyBytes_InternFromString("__eq__");
+ eqstr = PyString_InternFromString("__eq__");
if (eqstr == NULL)
return -1;
}
@@ -962,7 +962,7 @@ instance_hash(PyInstanceObject *inst)
return -1;
PyErr_Clear();
if (cmpstr == NULL) {
- cmpstr = PyBytes_InternFromString("__cmp__");
+ cmpstr = PyString_InternFromString("__cmp__");
if (cmpstr == NULL)
return -1;
}
@@ -1014,7 +1014,7 @@ instance_length(PyInstanceObject *inst)
Py_ssize_t outcome;
if (lenstr == NULL) {
- lenstr = PyBytes_InternFromString("__len__");
+ lenstr = PyString_InternFromString("__len__");
if (lenstr == NULL)
return -1;
}
@@ -1063,7 +1063,7 @@ instance_subscript(PyInstanceObject *inst, PyObject *key)
PyObject *res;
if (getitemstr == NULL) {
- getitemstr = PyBytes_InternFromString("__getitem__");
+ getitemstr = PyString_InternFromString("__getitem__");
if (getitemstr == NULL)
return NULL;
}
@@ -1090,7 +1090,7 @@ instance_ass_subscript(PyInstanceObject *inst, PyObject *key, PyObject *value)
if (value == NULL) {
if (delitemstr == NULL) {
- delitemstr = PyBytes_InternFromString("__delitem__");
+ delitemstr = PyString_InternFromString("__delitem__");
if (delitemstr == NULL)
return -1;
}
@@ -1098,7 +1098,7 @@ instance_ass_subscript(PyInstanceObject *inst, PyObject *key, PyObject *value)
}
else {
if (setitemstr == NULL) {
- setitemstr = PyBytes_InternFromString("__setitem__");
+ setitemstr = PyString_InternFromString("__setitem__");
if (setitemstr == NULL)
return -1;
}
@@ -1135,7 +1135,7 @@ instance_item(PyInstanceObject *inst, Py_ssize_t i)
PyObject *func, *res;
if (getitemstr == NULL) {
- getitemstr = PyBytes_InternFromString("__getitem__");
+ getitemstr = PyString_InternFromString("__getitem__");
if (getitemstr == NULL)
return NULL;
}
@@ -1154,7 +1154,7 @@ instance_slice(PyInstanceObject *inst, Py_ssize_t i, Py_ssize_t j)
static PyObject *getslicestr;
if (getslicestr == NULL) {
- getslicestr = PyBytes_InternFromString("__getslice__");
+ getslicestr = PyString_InternFromString("__getslice__");
if (getslicestr == NULL)
return NULL;
}
@@ -1166,7 +1166,7 @@ instance_slice(PyInstanceObject *inst, Py_ssize_t i, Py_ssize_t j)
PyErr_Clear();
if (getitemstr == NULL) {
- getitemstr = PyBytes_InternFromString("__getitem__");
+ getitemstr = PyString_InternFromString("__getitem__");
if (getitemstr == NULL)
return NULL;
}
@@ -1194,7 +1194,7 @@ instance_ass_item(PyInstanceObject *inst, Py_ssize_t i, PyObject *item)
if (item == NULL) {
if (delitemstr == NULL) {
- delitemstr = PyBytes_InternFromString("__delitem__");
+ delitemstr = PyString_InternFromString("__delitem__");
if (delitemstr == NULL)
return -1;
}
@@ -1202,7 +1202,7 @@ instance_ass_item(PyInstanceObject *inst, Py_ssize_t i, PyObject *item)
}
else {
if (setitemstr == NULL) {
- setitemstr = PyBytes_InternFromString("__setitem__");
+ setitemstr = PyString_InternFromString("__setitem__");
if (setitemstr == NULL)
return -1;
}
@@ -1236,7 +1236,7 @@ instance_ass_slice(PyInstanceObject *inst, Py_ssize_t i, Py_ssize_t j, PyObject
if (value == NULL) {
if (delslicestr == NULL) {
delslicestr =
- PyBytes_InternFromString("__delslice__");
+ PyString_InternFromString("__delslice__");
if (delslicestr == NULL)
return -1;
}
@@ -1247,7 +1247,7 @@ instance_ass_slice(PyInstanceObject *inst, Py_ssize_t i, Py_ssize_t j, PyObject
PyErr_Clear();
if (delitemstr == NULL) {
delitemstr =
- PyBytes_InternFromString("__delitem__");
+ PyString_InternFromString("__delitem__");
if (delitemstr == NULL)
return -1;
}
@@ -1263,7 +1263,7 @@ instance_ass_slice(PyInstanceObject *inst, Py_ssize_t i, Py_ssize_t j, PyObject
else {
if (setslicestr == NULL) {
setslicestr =
- PyBytes_InternFromString("__setslice__");
+ PyString_InternFromString("__setslice__");
if (setslicestr == NULL)
return -1;
}
@@ -1274,7 +1274,7 @@ instance_ass_slice(PyInstanceObject *inst, Py_ssize_t i, Py_ssize_t j, PyObject
PyErr_Clear();
if (setitemstr == NULL) {
setitemstr =
- PyBytes_InternFromString("__setitem__");
+ PyString_InternFromString("__setitem__");
if (setitemstr == NULL)
return -1;
}
@@ -1311,7 +1311,7 @@ instance_contains(PyInstanceObject *inst, PyObject *member)
*/
if(__contains__ == NULL) {
- __contains__ = PyBytes_InternFromString("__contains__");
+ __contains__ = PyString_InternFromString("__contains__");
if(__contains__ == NULL)
return -1;
}
@@ -1417,7 +1417,7 @@ half_binop(PyObject *v, PyObject *w, char *opname, binaryfunc thisfunc,
}
if (coerce_obj == NULL) {
- coerce_obj = PyBytes_InternFromString("__coerce__");
+ coerce_obj = PyString_InternFromString("__coerce__");
if (coerce_obj == NULL)
return NULL;
}
@@ -1504,7 +1504,7 @@ instance_coerce(PyObject **pv, PyObject **pw)
PyObject *coerced;
if (coerce_obj == NULL) {
- coerce_obj = PyBytes_InternFromString("__coerce__");
+ coerce_obj = PyString_InternFromString("__coerce__");
if (coerce_obj == NULL)
return -1;
}
@@ -1552,7 +1552,7 @@ instance_coerce(PyObject **pv, PyObject **pw)
#define UNARY(funcname, methodname) \
static PyObject *funcname(PyInstanceObject *self) { \
static PyObject *o; \
- if (o == NULL) { o = PyBytes_InternFromString(methodname); \
+ if (o == NULL) { o = PyString_InternFromString(methodname); \
if (o == NULL) return NULL; } \
return generic_unary_op(self, o); \
}
@@ -1561,7 +1561,7 @@ static PyObject *funcname(PyInstanceObject *self) { \
#define UNARY_FB(funcname, methodname, funcname_fb) \
static PyObject *funcname(PyInstanceObject *self) { \
static PyObject *o; \
- if (o == NULL) { o = PyBytes_InternFromString(methodname); \
+ if (o == NULL) { o = PyString_InternFromString(methodname); \
if (o == NULL) return NULL; } \
if (PyObject_HasAttr((PyObject*)self, o)) \
return generic_unary_op(self, o); \
@@ -1630,7 +1630,7 @@ half_cmp(PyObject *v, PyObject *w)
assert(PyInstance_Check(v));
if (cmp_obj == NULL) {
- cmp_obj = PyBytes_InternFromString("__cmp__");
+ cmp_obj = PyString_InternFromString("__cmp__");
if (cmp_obj == NULL)
return -2;
}
@@ -1738,7 +1738,7 @@ instance_nonzero(PyInstanceObject *self)
static PyObject *nonzerostr;
if (nonzerostr == NULL) {
- nonzerostr = PyBytes_InternFromString("__nonzero__");
+ nonzerostr = PyString_InternFromString("__nonzero__");
if (nonzerostr == NULL)
return -1;
}
@@ -1747,7 +1747,7 @@ instance_nonzero(PyInstanceObject *self)
return -1;
PyErr_Clear();
if (lenstr == NULL) {
- lenstr = PyBytes_InternFromString("__len__");
+ lenstr = PyString_InternFromString("__len__");
if (lenstr == NULL)
return -1;
}
@@ -1787,7 +1787,7 @@ instance_index(PyInstanceObject *self)
static PyObject *indexstr = NULL;
if (indexstr == NULL) {
- indexstr = PyBytes_InternFromString("__index__");
+ indexstr = PyString_InternFromString("__index__");
if (indexstr == NULL)
return NULL;
}
@@ -1814,7 +1814,7 @@ instance_int(PyInstanceObject *self)
PyObject *truncated;
static PyObject *int_name;
if (int_name == NULL) {
- int_name = PyBytes_InternFromString("__int__");
+ int_name = PyString_InternFromString("__int__");
if (int_name == NULL)
return NULL;
}
@@ -1929,7 +1929,7 @@ init_name_op(void)
if (name_op == NULL)
return -1;
for (i = 0; i < NAME_OPS; ++i) {
- name_op[i] = PyBytes_InternFromString(_name_op[i]);
+ name_op[i] = PyString_InternFromString(_name_op[i]);
if (name_op[i] == NULL)
return -1;
}
@@ -2012,12 +2012,12 @@ instance_getiter(PyInstanceObject *self)
PyObject *func;
if (iterstr == NULL) {
- iterstr = PyBytes_InternFromString("__iter__");
+ iterstr = PyString_InternFromString("__iter__");
if (iterstr == NULL)
return NULL;
}
if (getitemstr == NULL) {
- getitemstr = PyBytes_InternFromString("__getitem__");
+ getitemstr = PyString_InternFromString("__getitem__");
if (getitemstr == NULL)
return NULL;
}
@@ -2055,7 +2055,7 @@ instance_iternext(PyInstanceObject *self)
PyObject *func;
if (nextstr == NULL) {
- nextstr = PyBytes_InternFromString("next");
+ nextstr = PyString_InternFromString("next");
if (nextstr == NULL)
return NULL;
}
@@ -2087,7 +2087,7 @@ instance_call(PyObject *func, PyObject *arg, PyObject *kw)
PyErr_Clear();
PyErr_Format(PyExc_AttributeError,
"%.200s instance has no __call__ method",
- PyBytes_AsString(inst->in_class->cl_name));
+ PyString_AsString(inst->in_class->cl_name));
return NULL;
}
/* We must check and increment the recursion depth here. Scenario:
@@ -2261,7 +2261,7 @@ instancemethod_get_doc(PyMethodObject *im, void *context)
{
static PyObject *docstr;
if (docstr == NULL) {
- docstr= PyBytes_InternFromString("__doc__");
+ docstr= PyString_InternFromString("__doc__");
if (docstr == NULL)
return NULL;
}
@@ -2384,12 +2384,12 @@ instancemethod_repr(PyMethodObject *a)
return NULL;
PyErr_Clear();
}
- else if (!PyBytes_Check(funcname)) {
+ else if (!PyString_Check(funcname)) {
Py_DECREF(funcname);
funcname = NULL;
}
else
- sfuncname = PyBytes_AS_STRING(funcname);
+ sfuncname = PyString_AS_STRING(funcname);
if (klass == NULL)
klassname = NULL;
else {
@@ -2399,28 +2399,28 @@ instancemethod_repr(PyMethodObject *a)
return NULL;
PyErr_Clear();
}
- else if (!PyBytes_Check(klassname)) {
+ else if (!PyString_Check(klassname)) {
Py_DECREF(klassname);
klassname = NULL;
}
else
- sklassname = PyBytes_AS_STRING(klassname);
+ sklassname = PyString_AS_STRING(klassname);
}
if (self == NULL)
- result = PyBytes_FromFormat("<unbound method %s.%s>",
+ result = PyString_FromFormat("<unbound method %s.%s>",
sklassname, sfuncname);
else {
/* XXX Shouldn't use repr() here! */
PyObject *selfrepr = PyObject_Repr(self);
if (selfrepr == NULL)
goto fail;
- if (!PyBytes_Check(selfrepr)) {
+ if (!PyString_Check(selfrepr)) {
Py_DECREF(selfrepr);
goto fail;
}
- result = PyBytes_FromFormat("<bound method %s.%s of %s>",
+ result = PyString_FromFormat("<bound method %s.%s of %s>",
sklassname, sfuncname,
- PyBytes_AS_STRING(selfrepr));
+ PyString_AS_STRING(selfrepr));
Py_DECREF(selfrepr);
}
fail:
@@ -2472,8 +2472,8 @@ getclassname(PyObject *klass, char *buf, int bufsize)
PyErr_Clear();
return;
}
- if (PyBytes_Check(name)) {
- strncpy(buf, PyBytes_AS_STRING(name), bufsize);
+ if (PyString_Check(name)) {
+ strncpy(buf, PyString_AS_STRING(name), bufsize);
buf[bufsize-1] = '\0';
}
Py_DECREF(name);
diff --git a/Objects/codeobject.c b/Objects/codeobject.c
index 9892d9c..e94b4cc 100644
--- a/Objects/codeobject.c
+++ b/Objects/codeobject.c
@@ -32,10 +32,10 @@ intern_strings(PyObject *tuple)
for (i = PyTuple_GET_SIZE(tuple); --i >= 0; ) {
PyObject *v = PyTuple_GET_ITEM(tuple, i);
- if (v == NULL || !PyBytes_CheckExact(v)) {
+ if (v == NULL || !PyString_CheckExact(v)) {
Py_FatalError("non-string found in code slot");
}
- PyBytes_InternInPlace(&PyTuple_GET_ITEM(tuple, i));
+ PyString_InternInPlace(&PyTuple_GET_ITEM(tuple, i));
}
}
@@ -57,9 +57,9 @@ PyCode_New(int argcount, int nlocals, int stacksize, int flags,
varnames == NULL || !PyTuple_Check(varnames) ||
freevars == NULL || !PyTuple_Check(freevars) ||
cellvars == NULL || !PyTuple_Check(cellvars) ||
- name == NULL || !PyBytes_Check(name) ||
- filename == NULL || !PyBytes_Check(filename) ||
- lnotab == NULL || !PyBytes_Check(lnotab) ||
+ name == NULL || !PyString_Check(name) ||
+ filename == NULL || !PyString_Check(filename) ||
+ lnotab == NULL || !PyString_Check(lnotab) ||
!PyObject_CheckReadBuffer(code)) {
PyErr_BadInternalCall();
return NULL;
@@ -71,11 +71,11 @@ PyCode_New(int argcount, int nlocals, int stacksize, int flags,
/* Intern selected string constants */
for (i = PyTuple_Size(consts); --i >= 0; ) {
PyObject *v = PyTuple_GetItem(consts, i);
- if (!PyBytes_Check(v))
+ if (!PyString_Check(v))
continue;
- if (!all_name_chars((unsigned char *)PyBytes_AS_STRING(v)))
+ if (!all_name_chars((unsigned char *)PyString_AS_STRING(v)))
continue;
- PyBytes_InternInPlace(&PyTuple_GET_ITEM(consts, i));
+ PyString_InternInPlace(&PyTuple_GET_ITEM(consts, i));
}
co = PyObject_NEW(PyCodeObject, &PyCode_Type);
if (co != NULL) {
@@ -145,10 +145,10 @@ validate_and_copy_tuple(PyObject *tup)
for (i = 0; i < len; i++) {
item = PyTuple_GET_ITEM(tup, i);
- if (PyBytes_CheckExact(item)) {
+ if (PyString_CheckExact(item)) {
Py_INCREF(item);
}
- else if (!PyBytes_Check(item)) {
+ else if (!PyString_Check(item)) {
PyErr_Format(
PyExc_TypeError,
"name tuples must contain only "
@@ -158,9 +158,9 @@ validate_and_copy_tuple(PyObject *tup)
return NULL;
}
else {
- item = PyBytes_FromStringAndSize(
- PyBytes_AS_STRING(item),
- PyBytes_GET_SIZE(item));
+ item = PyString_FromStringAndSize(
+ PyString_AS_STRING(item),
+ PyString_GET_SIZE(item));
if (item == NULL) {
Py_DECREF(newtuple);
return NULL;
@@ -281,14 +281,14 @@ code_repr(PyCodeObject *co)
if (co->co_firstlineno != 0)
lineno = co->co_firstlineno;
- if (co->co_filename && PyBytes_Check(co->co_filename))
- filename = PyBytes_AS_STRING(co->co_filename);
- if (co->co_name && PyBytes_Check(co->co_name))
- name = PyBytes_AS_STRING(co->co_name);
+ if (co->co_filename && PyString_Check(co->co_filename))
+ filename = PyString_AS_STRING(co->co_filename);
+ if (co->co_name && PyString_Check(co->co_name))
+ name = PyString_AS_STRING(co->co_name);
PyOS_snprintf(buf, sizeof(buf),
"<code object %.100s at %p, file \"%.300s\", line %d>",
name, co, filename, lineno);
- return PyBytes_FromString(buf);
+ return PyString_FromString(buf);
}
static int
@@ -508,8 +508,8 @@ was actually done until 2.2) expand 300, 300 to 255, 255, 45, 45, but to
int
PyCode_Addr2Line(PyCodeObject *co, int addrq)
{
- int size = PyBytes_Size(co->co_lnotab) / 2;
- unsigned char *p = (unsigned char*)PyBytes_AsString(co->co_lnotab);
+ int size = PyString_Size(co->co_lnotab) / 2;
+ unsigned char *p = (unsigned char*)PyString_AsString(co->co_lnotab);
int line = co->co_firstlineno;
int addr = 0;
while (--size >= 0) {
@@ -604,8 +604,8 @@ PyCode_CheckLineNumber(PyCodeObject* co, int lasti, PyAddrPair *bounds)
int size, addr, line;
unsigned char* p;
- p = (unsigned char*)PyBytes_AS_STRING(co->co_lnotab);
- size = PyBytes_GET_SIZE(co->co_lnotab) / 2;
+ p = (unsigned char*)PyString_AS_STRING(co->co_lnotab);
+ size = PyString_GET_SIZE(co->co_lnotab) / 2;
addr = 0;
line = co->co_firstlineno;
diff --git a/Objects/complexobject.c b/Objects/complexobject.c
index 6110b99..9943d0d 100644
--- a/Objects/complexobject.c
+++ b/Objects/complexobject.c
@@ -303,7 +303,7 @@ PyComplex_AsCComplex(PyObject *op)
cv.imag = 0.;
if (complex_str == NULL) {
- if (!(complex_str = PyBytes_InternFromString("__complex__")))
+ if (!(complex_str = PyString_InternFromString("__complex__")))
return cv;
}
@@ -421,7 +421,7 @@ complex_repr(PyComplexObject *v)
{
char buf[100];
complex_to_buf(buf, sizeof(buf), v, PREC_REPR);
- return PyBytes_FromString(buf);
+ return PyString_FromString(buf);
}
static PyObject *
@@ -429,7 +429,7 @@ complex_str(PyComplexObject *v)
{
char buf[100];
complex_to_buf(buf, sizeof(buf), v, PREC_STR);
- return PyBytes_FromString(buf);
+ return PyString_FromString(buf);
}
static long
@@ -877,9 +877,9 @@ complex_subtype_from_string(PyTypeObject *type, PyObject *v)
#endif
Py_ssize_t len;
- if (PyBytes_Check(v)) {
- s = PyBytes_AS_STRING(v);
- len = PyBytes_GET_SIZE(v);
+ if (PyString_Check(v)) {
+ s = PyString_AS_STRING(v);
+ len = PyString_GET_SIZE(v);
}
#ifdef Py_USING_UNICODE
else if (PyUnicode_Check(v)) {
@@ -1065,7 +1065,7 @@ complex_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
Py_INCREF(r);
return r;
}
- if (PyBytes_Check(r) || PyUnicode_Check(r)) {
+ if (PyString_Check(r) || PyUnicode_Check(r)) {
if (i != NULL) {
PyErr_SetString(PyExc_TypeError,
"complex() can't take second arg"
@@ -1074,7 +1074,7 @@ complex_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
}
return complex_subtype_from_string(type, r);
}
- if (i != NULL && (PyBytes_Check(i) || PyUnicode_Check(i))) {
+ if (i != NULL && (PyString_Check(i) || PyUnicode_Check(i))) {
PyErr_SetString(PyExc_TypeError,
"complex() second arg can't be a string");
return NULL;
@@ -1082,7 +1082,7 @@ complex_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
/* XXX Hack to support classes with __complex__ method */
if (complexstr == NULL) {
- complexstr = PyBytes_InternFromString("__complex__");
+ complexstr = PyString_InternFromString("__complex__");
if (complexstr == NULL)
return NULL;
}
diff --git a/Objects/descrobject.c b/Objects/descrobject.c
index 7cf5e62..fcc174e 100644
--- a/Objects/descrobject.c
+++ b/Objects/descrobject.c
@@ -15,8 +15,8 @@ descr_dealloc(PyDescrObject *descr)
static char *
descr_name(PyDescrObject *descr)
{
- if (descr->d_name != NULL && PyBytes_Check(descr->d_name))
- return PyBytes_AS_STRING(descr->d_name);
+ if (descr->d_name != NULL && PyString_Check(descr->d_name))
+ return PyString_AS_STRING(descr->d_name);
else
return "?";
}
@@ -24,7 +24,7 @@ descr_name(PyDescrObject *descr)
static PyObject *
descr_repr(PyDescrObject *descr, char *format)
{
- return PyBytes_FromFormat(format, descr_name(descr),
+ return PyString_FromFormat(format, descr_name(descr),
descr->d_type->tp_name);
}
@@ -314,7 +314,7 @@ method_get_doc(PyMethodDescrObject *descr, void *closure)
Py_INCREF(Py_None);
return Py_None;
}
- return PyBytes_FromString(descr->d_method->ml_doc);
+ return PyString_FromString(descr->d_method->ml_doc);
}
static PyMemberDef descr_members[] = {
@@ -335,7 +335,7 @@ member_get_doc(PyMemberDescrObject *descr, void *closure)
Py_INCREF(Py_None);
return Py_None;
}
- return PyBytes_FromString(descr->d_member->doc);
+ return PyString_FromString(descr->d_member->doc);
}
static PyGetSetDef member_getset[] = {
@@ -350,7 +350,7 @@ getset_get_doc(PyGetSetDescrObject *descr, void *closure)
Py_INCREF(Py_None);
return Py_None;
}
- return PyBytes_FromString(descr->d_getset->doc);
+ return PyString_FromString(descr->d_getset->doc);
}
static PyGetSetDef getset_getset[] = {
@@ -365,7 +365,7 @@ wrapperdescr_get_doc(PyWrapperDescrObject *descr, void *closure)
Py_INCREF(Py_None);
return Py_None;
}
- return PyBytes_FromString(descr->d_base->doc);
+ return PyString_FromString(descr->d_base->doc);
}
static PyGetSetDef wrapperdescr_getset[] = {
@@ -576,7 +576,7 @@ descr_new(PyTypeObject *descrtype, PyTypeObject *type, const char *name)
if (descr != NULL) {
Py_XINCREF(type);
descr->d_type = type;
- descr->d_name = PyBytes_InternFromString(name);
+ descr->d_name = PyString_InternFromString(name);
if (descr->d_name == NULL) {
Py_DECREF(descr);
descr = NULL;
@@ -922,7 +922,7 @@ wrapper_hash(wrapperobject *wp)
static PyObject *
wrapper_repr(wrapperobject *wp)
{
- return PyBytes_FromFormat("<method-wrapper '%s' of %s object at %p>",
+ return PyString_FromFormat("<method-wrapper '%s' of %s object at %p>",
wp->descr->d_base->name,
wp->self->ob_type->tp_name,
wp->self);
@@ -947,7 +947,7 @@ wrapper_name(wrapperobject *wp)
{
char *s = wp->descr->d_base->name;
- return PyBytes_FromString(s);
+ return PyString_FromString(s);
}
static PyObject *
@@ -960,7 +960,7 @@ wrapper_doc(wrapperobject *wp)
return Py_None;
}
else {
- return PyBytes_FromString(s);
+ return PyString_FromString(s);
}
}
diff --git a/Objects/dictobject.c b/Objects/dictobject.c
index 6b15131..9b14e63 100644
--- a/Objects/dictobject.c
+++ b/Objects/dictobject.c
@@ -224,7 +224,7 @@ PyDict_New(void)
{
register PyDictObject *mp;
if (dummy == NULL) { /* Auto-initialize dummy */
- dummy = PyBytes_FromString("<dummy key>");
+ dummy = PyString_FromString("<dummy key>");
if (dummy == NULL)
return NULL;
#ifdef SHOW_CONVERSION_COUNTS
@@ -373,7 +373,7 @@ lookdict(PyDictObject *mp, PyObject *key, register long hash)
* this assumption allows testing for errors during PyObject_RichCompareBool()
* to be dropped; string-string comparisons never raise exceptions. This also
* means we don't need to go through PyObject_RichCompareBool(); we can always
- * use _PyBytes_Eq() directly.
+ * use _PyString_Eq() directly.
*
* This is valuable because dicts with only string keys are very common.
*/
@@ -391,7 +391,7 @@ lookdict_string(PyDictObject *mp, PyObject *key, register long hash)
including subclasses of str; e.g., one reason to subclass
strings is to override __eq__, and for speed we don't cater to
that here. */
- if (!PyBytes_CheckExact(key)) {
+ if (!PyString_CheckExact(key)) {
#ifdef SHOW_CONVERSION_COUNTS
++converted;
#endif
@@ -405,7 +405,7 @@ lookdict_string(PyDictObject *mp, PyObject *key, register long hash)
if (ep->me_key == dummy)
freeslot = ep;
else {
- if (ep->me_hash == hash && _PyBytes_Eq(ep->me_key, key))
+ if (ep->me_hash == hash && _PyString_Eq(ep->me_key, key))
return ep;
freeslot = NULL;
}
@@ -420,7 +420,7 @@ lookdict_string(PyDictObject *mp, PyObject *key, register long hash)
if (ep->me_key == key
|| (ep->me_hash == hash
&& ep->me_key != dummy
- && _PyBytes_Eq(ep->me_key, key)))
+ && _PyString_Eq(ep->me_key, key)))
return ep;
if (ep->me_key == dummy && freeslot == NULL)
freeslot = ep;
@@ -626,8 +626,8 @@ PyDict_GetItem(PyObject *op, PyObject *key)
PyThreadState *tstate;
if (!PyDict_Check(op))
return NULL;
- if (!PyBytes_CheckExact(key) ||
- (hash = ((PyBytesObject *) key)->ob_shash) == -1)
+ if (!PyString_CheckExact(key) ||
+ (hash = ((PyStringObject *) key)->ob_shash) == -1)
{
hash = PyObject_Hash(key);
if (hash == -1) {
@@ -680,8 +680,8 @@ PyDict_SetItem(register PyObject *op, PyObject *key, PyObject *value)
assert(key);
assert(value);
mp = (PyDictObject *)op;
- if (PyBytes_CheckExact(key)) {
- hash = ((PyBytesObject *)key)->ob_shash;
+ if (PyString_CheckExact(key)) {
+ hash = ((PyStringObject *)key)->ob_shash;
if (hash == -1)
hash = PyObject_Hash(key);
}
@@ -728,8 +728,8 @@ PyDict_DelItem(PyObject *op, PyObject *key)
return -1;
}
assert(key);
- if (!PyBytes_CheckExact(key) ||
- (hash = ((PyBytesObject *) key)->ob_shash) == -1) {
+ if (!PyString_CheckExact(key) ||
+ (hash = ((PyStringObject *) key)->ob_shash) == -1) {
hash = PyObject_Hash(key);
if (hash == -1)
return -1;
@@ -982,11 +982,11 @@ dict_repr(PyDictObject *mp)
i = Py_ReprEnter((PyObject *)mp);
if (i != 0) {
- return i > 0 ? PyBytes_FromString("{...}") : NULL;
+ return i > 0 ? PyString_FromString("{...}") : NULL;
}
if (mp->ma_used == 0) {
- result = PyBytes_FromString("{}");
+ result = PyString_FromString("{}");
goto Done;
}
@@ -994,7 +994,7 @@ dict_repr(PyDictObject *mp)
if (pieces == NULL)
goto Done;
- colon = PyBytes_FromString(": ");
+ colon = PyString_FromString(": ");
if (colon == NULL)
goto Done;
@@ -1006,8 +1006,8 @@ dict_repr(PyDictObject *mp)
/* Prevent repr from deleting value during key format. */
Py_INCREF(value);
s = PyObject_Repr(key);
- PyBytes_Concat(&s, colon);
- PyBytes_ConcatAndDel(&s, PyObject_Repr(value));
+ PyString_Concat(&s, colon);
+ PyString_ConcatAndDel(&s, PyObject_Repr(value));
Py_DECREF(value);
if (s == NULL)
goto Done;
@@ -1019,29 +1019,29 @@ dict_repr(PyDictObject *mp)
/* Add "{}" decorations to the first and last items. */
assert(PyList_GET_SIZE(pieces) > 0);
- s = PyBytes_FromString("{");
+ s = PyString_FromString("{");
if (s == NULL)
goto Done;
temp = PyList_GET_ITEM(pieces, 0);
- PyBytes_ConcatAndDel(&s, temp);
+ PyString_ConcatAndDel(&s, temp);
PyList_SET_ITEM(pieces, 0, s);
if (s == NULL)
goto Done;
- s = PyBytes_FromString("}");
+ s = PyString_FromString("}");
if (s == NULL)
goto Done;
temp = PyList_GET_ITEM(pieces, PyList_GET_SIZE(pieces) - 1);
- PyBytes_ConcatAndDel(&temp, s);
+ PyString_ConcatAndDel(&temp, s);
PyList_SET_ITEM(pieces, PyList_GET_SIZE(pieces) - 1, temp);
if (temp == NULL)
goto Done;
/* Paste them all together with ", " between. */
- s = PyBytes_FromString(", ");
+ s = PyString_FromString(", ");
if (s == NULL)
goto Done;
- result = _PyBytes_Join(s, pieces);
+ result = _PyString_Join(s, pieces);
Py_DECREF(s);
Done:
@@ -1064,8 +1064,8 @@ dict_subscript(PyDictObject *mp, register PyObject *key)
long hash;
PyDictEntry *ep;
assert(mp->ma_table != NULL);
- if (!PyBytes_CheckExact(key) ||
- (hash = ((PyBytesObject *) key)->ob_shash) == -1) {
+ if (!PyString_CheckExact(key) ||
+ (hash = ((PyStringObject *) key)->ob_shash) == -1) {
hash = PyObject_Hash(key);
if (hash == -1)
return NULL;
@@ -1081,7 +1081,7 @@ dict_subscript(PyDictObject *mp, register PyObject *key)
static PyObject *missing_str = NULL;
if (missing_str == NULL)
missing_str =
- PyBytes_InternFromString("__missing__");
+ PyString_InternFromString("__missing__");
missing = _PyType_Lookup(Py_TYPE(mp), missing_str);
if (missing != NULL)
return PyObject_CallFunctionObjArgs(missing,
@@ -1794,8 +1794,8 @@ dict_contains(register PyDictObject *mp, PyObject *key)
long hash;
PyDictEntry *ep;
- if (!PyBytes_CheckExact(key) ||
- (hash = ((PyBytesObject *) key)->ob_shash) == -1) {
+ if (!PyString_CheckExact(key) ||
+ (hash = ((PyStringObject *) key)->ob_shash) == -1) {
hash = PyObject_Hash(key);
if (hash == -1)
return NULL;
@@ -1827,8 +1827,8 @@ dict_get(register PyDictObject *mp, PyObject *args)
if (!PyArg_UnpackTuple(args, "get", 1, 2, &key, &failobj))
return NULL;
- if (!PyBytes_CheckExact(key) ||
- (hash = ((PyBytesObject *) key)->ob_shash) == -1) {
+ if (!PyString_CheckExact(key) ||
+ (hash = ((PyStringObject *) key)->ob_shash) == -1) {
hash = PyObject_Hash(key);
if (hash == -1)
return NULL;
@@ -1856,8 +1856,8 @@ dict_setdefault(register PyDictObject *mp, PyObject *args)
if (!PyArg_UnpackTuple(args, "setdefault", 1, 2, &key, &failobj))
return NULL;
- if (!PyBytes_CheckExact(key) ||
- (hash = ((PyBytesObject *) key)->ob_shash) == -1) {
+ if (!PyString_CheckExact(key) ||
+ (hash = ((PyStringObject *) key)->ob_shash) == -1) {
hash = PyObject_Hash(key);
if (hash == -1)
return NULL;
@@ -1902,8 +1902,8 @@ dict_pop(PyDictObject *mp, PyObject *args)
"pop(): dictionary is empty");
return NULL;
}
- if (!PyBytes_CheckExact(key) ||
- (hash = ((PyBytesObject *) key)->ob_shash) == -1) {
+ if (!PyString_CheckExact(key) ||
+ (hash = ((PyStringObject *) key)->ob_shash) == -1) {
hash = PyObject_Hash(key);
if (hash == -1)
return NULL;
@@ -2148,8 +2148,8 @@ PyDict_Contains(PyObject *op, PyObject *key)
PyDictObject *mp = (PyDictObject *)op;
PyDictEntry *ep;
- if (!PyBytes_CheckExact(key) ||
- (hash = ((PyBytesObject *) key)->ob_shash) == -1) {
+ if (!PyString_CheckExact(key) ||
+ (hash = ((PyStringObject *) key)->ob_shash) == -1) {
hash = PyObject_Hash(key);
if (hash == -1)
return -1;
@@ -2275,7 +2275,7 @@ PyObject *
PyDict_GetItemString(PyObject *v, const char *key)
{
PyObject *kv, *rv;
- kv = PyBytes_FromString(key);
+ kv = PyString_FromString(key);
if (kv == NULL)
return NULL;
rv = PyDict_GetItem(v, kv);
@@ -2288,10 +2288,10 @@ PyDict_SetItemString(PyObject *v, const char *key, PyObject *item)
{
PyObject *kv;
int err;
- kv = PyBytes_FromString(key);
+ kv = PyString_FromString(key);
if (kv == NULL)
return -1;
- PyBytes_InternInPlace(&kv); /* XXX Should we really? */
+ PyString_InternInPlace(&kv); /* XXX Should we really? */
err = PyDict_SetItem(v, kv, item);
Py_DECREF(kv);
return err;
@@ -2302,7 +2302,7 @@ PyDict_DelItemString(PyObject *v, const char *key)
{
PyObject *kv;
int err;
- kv = PyBytes_FromString(key);
+ kv = PyString_FromString(key);
if (kv == NULL)
return -1;
err = PyDict_DelItem(v, kv);
diff --git a/Objects/exceptions.c b/Objects/exceptions.c
index 085ef36..48b47b0 100644
--- a/Objects/exceptions.c
+++ b/Objects/exceptions.c
@@ -44,7 +44,7 @@ BaseException_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
return NULL;
}
- self->message = PyBytes_FromString("");
+ self->message = PyString_FromString("");
if (!self->message) {
Py_DECREF(self);
return NULL;
@@ -104,7 +104,7 @@ BaseException_str(PyBaseExceptionObject *self)
switch (PyTuple_GET_SIZE(self->args)) {
case 0:
- out = PyBytes_FromString("");
+ out = PyString_FromString("");
break;
case 1:
out = PyObject_Str(PyTuple_GET_ITEM(self->args, 0));
@@ -133,13 +133,13 @@ BaseException_repr(PyBaseExceptionObject *self)
dot = strrchr(name, '.');
if (dot != NULL) name = dot+1;
- repr = PyBytes_FromString(name);
+ repr = PyString_FromString(name);
if (!repr) {
Py_DECREF(repr_suffix);
return NULL;
}
- PyBytes_ConcatAndDel(&repr, repr_suffix);
+ PyString_ConcatAndDel(&repr, repr_suffix);
return repr;
}
@@ -610,7 +610,7 @@ EnvironmentError_str(PyEnvironmentErrorObject *self)
PyObject *repr;
PyObject *tuple;
- fmt = PyBytes_FromString("[Errno %s] %s: %s");
+ fmt = PyString_FromString("[Errno %s] %s: %s");
if (!fmt)
return NULL;
@@ -645,7 +645,7 @@ EnvironmentError_str(PyEnvironmentErrorObject *self)
PyTuple_SET_ITEM(tuple, 2, repr);
- rtnval = PyBytes_Format(fmt, tuple);
+ rtnval = PyString_Format(fmt, tuple);
Py_DECREF(fmt);
Py_DECREF(tuple);
@@ -654,7 +654,7 @@ EnvironmentError_str(PyEnvironmentErrorObject *self)
PyObject *fmt;
PyObject *tuple;
- fmt = PyBytes_FromString("[Errno %s] %s");
+ fmt = PyString_FromString("[Errno %s] %s");
if (!fmt)
return NULL;
@@ -681,7 +681,7 @@ EnvironmentError_str(PyEnvironmentErrorObject *self)
PyTuple_SET_ITEM(tuple, 1, Py_None);
}
- rtnval = PyBytes_Format(fmt, tuple);
+ rtnval = PyString_Format(fmt, tuple);
Py_DECREF(fmt);
Py_DECREF(tuple);
@@ -841,7 +841,7 @@ WindowsError_str(PyWindowsErrorObject *self)
PyObject *repr;
PyObject *tuple;
- fmt = PyBytes_FromString("[Error %s] %s: %s");
+ fmt = PyString_FromString("[Error %s] %s: %s");
if (!fmt)
return NULL;
@@ -876,7 +876,7 @@ WindowsError_str(PyWindowsErrorObject *self)
PyTuple_SET_ITEM(tuple, 2, repr);
- rtnval = PyBytes_Format(fmt, tuple);
+ rtnval = PyString_Format(fmt, tuple);
Py_DECREF(fmt);
Py_DECREF(tuple);
@@ -885,7 +885,7 @@ WindowsError_str(PyWindowsErrorObject *self)
PyObject *fmt;
PyObject *tuple;
- fmt = PyBytes_FromString("[Error %s] %s");
+ fmt = PyString_FromString("[Error %s] %s");
if (!fmt)
return NULL;
@@ -912,7 +912,7 @@ WindowsError_str(PyWindowsErrorObject *self)
PyTuple_SET_ITEM(tuple, 1, Py_None);
}
- rtnval = PyBytes_Format(fmt, tuple);
+ rtnval = PyString_Format(fmt, tuple);
Py_DECREF(fmt);
Py_DECREF(tuple);
@@ -1109,21 +1109,21 @@ SyntaxError_str(PySyntaxErrorObject *self)
str = PyObject_Str(Py_None);
if (!str) return NULL;
/* Don't fiddle with non-string return (shouldn't happen anyway) */
- if (!PyBytes_Check(str)) return str;
+ if (!PyString_Check(str)) return str;
/* XXX -- do all the additional formatting with filename and
lineno here */
have_filename = (self->filename != NULL) &&
- PyBytes_Check(self->filename);
+ PyString_Check(self->filename);
have_lineno = (self->lineno != NULL) && PyInt_Check(self->lineno);
if (!have_filename && !have_lineno)
return str;
- bufsize = PyBytes_GET_SIZE(str) + 64;
+ bufsize = PyString_GET_SIZE(str) + 64;
if (have_filename)
- bufsize += PyBytes_GET_SIZE(self->filename);
+ bufsize += PyString_GET_SIZE(self->filename);
buffer = PyMem_MALLOC(bufsize);
if (buffer == NULL)
@@ -1131,19 +1131,19 @@ SyntaxError_str(PySyntaxErrorObject *self)
if (have_filename && have_lineno)
PyOS_snprintf(buffer, bufsize, "%s (%s, line %ld)",
- PyBytes_AS_STRING(str),
- my_basename(PyBytes_AS_STRING(self->filename)),
+ PyString_AS_STRING(str),
+ my_basename(PyString_AS_STRING(self->filename)),
PyInt_AsLong(self->lineno));
else if (have_filename)
PyOS_snprintf(buffer, bufsize, "%s (%s)",
- PyBytes_AS_STRING(str),
- my_basename(PyBytes_AS_STRING(self->filename)));
+ PyString_AS_STRING(str),
+ my_basename(PyString_AS_STRING(self->filename)));
else /* only have_lineno */
PyOS_snprintf(buffer, bufsize, "%s (line %ld)",
- PyBytes_AS_STRING(str),
+ PyString_AS_STRING(str),
PyInt_AsLong(self->lineno));
- result = PyBytes_FromString(buffer);
+ result = PyString_FromString(buffer);
PyMem_FREE(buffer);
if (result == NULL)
@@ -1250,7 +1250,7 @@ get_string(PyObject *attr, const char *name)
return NULL;
}
- if (!PyBytes_Check(attr)) {
+ if (!PyString_Check(attr)) {
PyErr_Format(PyExc_TypeError, "%.200s attribute must be str", name);
return NULL;
}
@@ -1262,7 +1262,7 @@ get_string(PyObject *attr, const char *name)
static int
set_string(PyObject **attr, const char *value)
{
- PyObject *obj = PyBytes_FromString(value);
+ PyObject *obj = PyString_FromString(value);
if (!obj)
return -1;
Py_CLEAR(*attr);
@@ -1345,7 +1345,7 @@ PyUnicodeDecodeError_GetStart(PyObject *exc, Py_ssize_t *start)
"object");
if (!obj)
return -1;
- size = PyBytes_GET_SIZE(obj);
+ size = PyString_GET_SIZE(obj);
*start = ((PyUnicodeErrorObject *)exc)->start;
if (*start<0)
*start = 0;
@@ -1415,7 +1415,7 @@ PyUnicodeDecodeError_GetEnd(PyObject *exc, Py_ssize_t *end)
if (!obj)
return -1;
*end = ((PyUnicodeErrorObject *)exc)->end;
- size = PyBytes_GET_SIZE(obj);
+ size = PyString_GET_SIZE(obj);
if (*end<1)
*end = 1;
if (*end>size)
@@ -1506,11 +1506,11 @@ UnicodeError_init(PyUnicodeErrorObject *self, PyObject *args, PyObject *kwds,
Py_CLEAR(self->reason);
if (!PyArg_ParseTuple(args, "O!O!nnO!",
- &PyBytes_Type, &self->encoding,
+ &PyString_Type, &self->encoding,
objecttype, &self->object,
&self->start,
&self->end,
- &PyBytes_Type, &self->reason)) {
+ &PyString_Type, &self->reason)) {
self->encoding = self->object = self->reason = NULL;
return -1;
}
@@ -1590,20 +1590,20 @@ UnicodeEncodeError_str(PyObject *self)
PyOS_snprintf(badchar_str, sizeof(badchar_str), "u%04x", badchar);
else
PyOS_snprintf(badchar_str, sizeof(badchar_str), "U%08x", badchar);
- return PyBytes_FromFormat(
+ return PyString_FromFormat(
"'%.400s' codec can't encode character u'\\%s' in position %zd: %.400s",
- PyBytes_AS_STRING(uself->encoding),
+ PyString_AS_STRING(uself->encoding),
badchar_str,
uself->start,
- PyBytes_AS_STRING(uself->reason)
+ PyString_AS_STRING(uself->reason)
);
}
- return PyBytes_FromFormat(
+ return PyString_FromFormat(
"'%.400s' codec can't encode characters in position %zd-%zd: %.400s",
- PyBytes_AS_STRING(uself->encoding),
+ PyString_AS_STRING(uself->encoding),
uself->start,
uself->end-1,
- PyBytes_AS_STRING(uself->reason)
+ PyString_AS_STRING(uself->reason)
);
}
@@ -1642,7 +1642,7 @@ UnicodeDecodeError_init(PyObject *self, PyObject *args, PyObject *kwds)
if (BaseException_init((PyBaseExceptionObject *)self, args, kwds) == -1)
return -1;
return UnicodeError_init((PyUnicodeErrorObject *)self, args,
- kwds, &PyBytes_Type);
+ kwds, &PyString_Type);
}
static PyObject *
@@ -1654,21 +1654,21 @@ UnicodeDecodeError_str(PyObject *self)
/* FromFormat does not support %02x, so format that separately */
char byte[4];
PyOS_snprintf(byte, sizeof(byte), "%02x",
- ((int)PyBytes_AS_STRING(uself->object)[uself->start])&0xff);
- return PyBytes_FromFormat(
+ ((int)PyString_AS_STRING(uself->object)[uself->start])&0xff);
+ return PyString_FromFormat(
"'%.400s' codec can't decode byte 0x%s in position %zd: %.400s",
- PyBytes_AS_STRING(uself->encoding),
+ PyString_AS_STRING(uself->encoding),
byte,
uself->start,
- PyBytes_AS_STRING(uself->reason)
+ PyString_AS_STRING(uself->reason)
);
}
- return PyBytes_FromFormat(
+ return PyString_FromFormat(
"'%.400s' codec can't decode bytes in position %zd-%zd: %.400s",
- PyBytes_AS_STRING(uself->encoding),
+ PyString_AS_STRING(uself->encoding),
uself->start,
uself->end-1,
- PyBytes_AS_STRING(uself->reason)
+ PyString_AS_STRING(uself->reason)
);
}
@@ -1718,7 +1718,7 @@ UnicodeTranslateError_init(PyUnicodeErrorObject *self, PyObject *args,
&PyUnicode_Type, &self->object,
&self->start,
&self->end,
- &PyBytes_Type, &self->reason)) {
+ &PyString_Type, &self->reason)) {
self->object = self->reason = NULL;
return -1;
}
@@ -1744,18 +1744,18 @@ UnicodeTranslateError_str(PyObject *self)
PyOS_snprintf(badchar_str, sizeof(badchar_str), "u%04x", badchar);
else
PyOS_snprintf(badchar_str, sizeof(badchar_str), "U%08x", badchar);
- return PyBytes_FromFormat(
+ return PyString_FromFormat(
"can't translate character u'\\%s' in position %zd: %.400s",
badchar_str,
uself->start,
- PyBytes_AS_STRING(uself->reason)
+ PyString_AS_STRING(uself->reason)
);
}
- return PyBytes_FromFormat(
+ return PyString_FromFormat(
"can't translate characters in position %zd-%zd: %.400s",
uself->start,
uself->end-1,
- PyBytes_AS_STRING(uself->reason)
+ PyString_AS_STRING(uself->reason)
);
}
@@ -2111,7 +2111,7 @@ _PyExc_Init(void)
(PyBaseExceptionObject *)PyExc_RecursionErrorInst;
PyObject *args_tuple;
PyObject *exc_message;
- exc_message = PyBytes_FromString("maximum recursion depth exceeded");
+ exc_message = PyString_FromString("maximum recursion depth exceeded");
if (!exc_message)
Py_FatalError("cannot allocate argument for RuntimeError "
"pre-allocation");
diff --git a/Objects/fileobject.c b/Objects/fileobject.c
index 4ea97f5..8cc829b 100644
--- a/Objects/fileobject.c
+++ b/Objects/fileobject.c
@@ -26,7 +26,7 @@
#include <io.h>
#endif
-#define BUF(v) PyBytes_AS_STRING((PyBytesObject *)v)
+#define BUF(v) PyString_AS_STRING((PyStringObject *)v)
#ifndef DONT_HAVE_ERRNO_H
#include <errno.h>
@@ -160,7 +160,7 @@ fill_file_fields(PyFileObject *f, FILE *fp, PyObject *name, char *mode,
Py_INCREF(name);
f->f_name = name;
- f->f_mode = PyBytes_FromString(mode);
+ f->f_mode = PyString_FromString(mode);
f->f_close = close;
f->f_softspace = 0;
@@ -370,7 +370,7 @@ PyFile_FromFile(FILE *fp, char *name, char *mode, int (*close)(FILE *))
PyFileObject *f = (PyFileObject *)PyFile_Type.tp_new(&PyFile_Type,
NULL, NULL);
if (f != NULL) {
- PyObject *o_name = PyBytes_FromString(name);
+ PyObject *o_name = PyString_FromString(name);
if (o_name == NULL)
return NULL;
if (fill_file_fields(f, fp, o_name, mode, close) == NULL) {
@@ -525,20 +525,20 @@ file_repr(PyFileObject *f)
#ifdef Py_USING_UNICODE
PyObject *ret = NULL;
PyObject *name = PyUnicode_AsUnicodeEscapeString(f->f_name);
- const char *name_str = name ? PyBytes_AsString(name) : "?";
- ret = PyBytes_FromFormat("<%s file u'%s', mode '%s' at %p>",
+ const char *name_str = name ? PyString_AsString(name) : "?";
+ ret = PyString_FromFormat("<%s file u'%s', mode '%s' at %p>",
f->f_fp == NULL ? "closed" : "open",
name_str,
- PyBytes_AsString(f->f_mode),
+ PyString_AsString(f->f_mode),
f);
Py_XDECREF(name);
return ret;
#endif
} else {
- return PyBytes_FromFormat("<%s file '%s', mode '%s' at %p>",
+ return PyString_FromFormat("<%s file '%s', mode '%s' at %p>",
f->f_fp == NULL ? "closed" : "open",
- PyBytes_AsString(f->f_name),
- PyBytes_AsString(f->f_mode),
+ PyString_AsString(f->f_name),
+ PyString_AsString(f->f_mode),
f);
}
}
@@ -958,7 +958,7 @@ file_read(PyFileObject *f, PyObject *args)
"requested number of bytes is more than a Python string can hold");
return NULL;
}
- v = PyBytes_FromStringAndSize((char *)NULL, buffersize);
+ v = PyString_FromStringAndSize((char *)NULL, buffersize);
if (v == NULL)
return NULL;
bytesread = 0;
@@ -989,7 +989,7 @@ file_read(PyFileObject *f, PyObject *args)
}
if (bytesrequested < 0) {
buffersize = new_buffersize(f, buffersize);
- if (_PyBytes_Resize(&v, buffersize) < 0)
+ if (_PyString_Resize(&v, buffersize) < 0)
return NULL;
} else {
/* Got what was requested. */
@@ -997,7 +997,7 @@ file_read(PyFileObject *f, PyObject *args)
}
}
if (bytesread != buffersize)
- _PyBytes_Resize(&v, bytesread);
+ _PyString_Resize(&v, bytesread);
return v;
}
@@ -1115,7 +1115,7 @@ getline_via_fgets(PyFileObject *f, FILE *fp)
size_t increment; /* amount to increment the buffer */
size_t prev_v_size;
- /* Optimize for normal case: avoid _PyBytes_Resize if at all
+ /* Optimize for normal case: avoid _PyString_Resize if at all
* possible via first reading into stack buffer "buf".
*/
total_v_size = INITBUFSIZE; /* start small and pray */
@@ -1133,7 +1133,7 @@ getline_via_fgets(PyFileObject *f, FILE *fp)
clearerr(fp);
if (PyErr_CheckSignals())
return NULL;
- v = PyBytes_FromStringAndSize(buf, pvfree - buf);
+ v = PyString_FromStringAndSize(buf, pvfree - buf);
return v;
}
/* fgets read *something* */
@@ -1162,7 +1162,7 @@ getline_via_fgets(PyFileObject *f, FILE *fp)
assert(p > pvfree && *(p-1) == '\0');
--p; /* don't include \0 from fgets */
}
- v = PyBytes_FromStringAndSize(buf, p - buf);
+ v = PyString_FromStringAndSize(buf, p - buf);
return v;
}
/* yuck: fgets overwrote all the newlines, i.e. the entire
@@ -1183,7 +1183,7 @@ getline_via_fgets(PyFileObject *f, FILE *fp)
* into its buffer.
*/
total_v_size = MAXBUFSIZE << 1;
- v = PyBytes_FromStringAndSize((char*)NULL, (int)total_v_size);
+ v = PyString_FromStringAndSize((char*)NULL, (int)total_v_size);
if (v == NULL)
return v;
/* copy over everything except the last null byte */
@@ -1238,13 +1238,13 @@ getline_via_fgets(PyFileObject *f, FILE *fp)
Py_DECREF(v);
return NULL;
}
- if (_PyBytes_Resize(&v, (int)total_v_size) < 0)
+ if (_PyString_Resize(&v, (int)total_v_size) < 0)
return NULL;
/* overwrite the trailing null byte */
pvfree = BUF(v) + (prev_v_size - 1);
}
if (BUF(v) + total_v_size != p)
- _PyBytes_Resize(&v, p - BUF(v));
+ _PyString_Resize(&v, p - BUF(v));
return v;
#undef INITBUFSIZE
#undef MAXBUFSIZE
@@ -1276,7 +1276,7 @@ get_line(PyFileObject *f, int n)
return getline_via_fgets(f, fp);
#endif
total_v_size = n > 0 ? n : 100;
- v = PyBytes_FromStringAndSize((char *)NULL, total_v_size);
+ v = PyString_FromStringAndSize((char *)NULL, total_v_size);
if (v == NULL)
return NULL;
buf = BUF(v);
@@ -1349,7 +1349,7 @@ get_line(PyFileObject *f, int n)
Py_DECREF(v);
return NULL;
}
- if (_PyBytes_Resize(&v, total_v_size) < 0)
+ if (_PyString_Resize(&v, total_v_size) < 0)
return NULL;
buf = BUF(v) + used_v_size;
end = BUF(v) + total_v_size;
@@ -1357,7 +1357,7 @@ get_line(PyFileObject *f, int n)
used_v_size = buf - BUF(v);
if (used_v_size != total_v_size)
- _PyBytes_Resize(&v, used_v_size);
+ _PyString_Resize(&v, used_v_size);
return v;
}
@@ -1402,7 +1402,7 @@ PyFile_GetLine(PyObject *f, int n)
result = PyEval_CallObject(reader, args);
Py_DECREF(reader);
Py_DECREF(args);
- if (result != NULL && !PyBytes_Check(result) &&
+ if (result != NULL && !PyString_Check(result) &&
!PyUnicode_Check(result)) {
Py_DECREF(result);
result = NULL;
@@ -1411,9 +1411,9 @@ PyFile_GetLine(PyObject *f, int n)
}
}
- if (n < 0 && result != NULL && PyBytes_Check(result)) {
- char *s = PyBytes_AS_STRING(result);
- Py_ssize_t len = PyBytes_GET_SIZE(result);
+ if (n < 0 && result != NULL && PyString_Check(result)) {
+ char *s = PyString_AS_STRING(result);
+ Py_ssize_t len = PyString_GET_SIZE(result);
if (len == 0) {
Py_DECREF(result);
result = NULL;
@@ -1422,10 +1422,10 @@ PyFile_GetLine(PyObject *f, int n)
}
else if (s[len-1] == '\n') {
if (result->ob_refcnt == 1)
- _PyBytes_Resize(&result, len-1);
+ _PyString_Resize(&result, len-1);
else {
PyObject *v;
- v = PyBytes_FromStringAndSize(s, len-1);
+ v = PyString_FromStringAndSize(s, len-1);
Py_DECREF(result);
result = v;
}
@@ -1473,7 +1473,7 @@ file_readline(PyFileObject *f, PyObject *args)
if (!PyArg_ParseTuple(args, "|i:readline", &n))
return NULL;
if (n == 0)
- return PyBytes_FromString("");
+ return PyString_FromString("");
if (n < 0)
n = 0;
return get_line(f, n);
@@ -1539,18 +1539,18 @@ file_readlines(PyFileObject *f, PyObject *args)
}
if (big_buffer == NULL) {
/* Create the big buffer */
- big_buffer = PyBytes_FromStringAndSize(
+ big_buffer = PyString_FromStringAndSize(
NULL, buffersize);
if (big_buffer == NULL)
goto error;
- buffer = PyBytes_AS_STRING(big_buffer);
+ buffer = PyString_AS_STRING(big_buffer);
memcpy(buffer, small_buffer, nfilled);
}
else {
/* Grow the big buffer */
- if ( _PyBytes_Resize(&big_buffer, buffersize) < 0 )
+ if ( _PyString_Resize(&big_buffer, buffersize) < 0 )
goto error;
- buffer = PyBytes_AS_STRING(big_buffer);
+ buffer = PyString_AS_STRING(big_buffer);
}
continue;
}
@@ -1559,7 +1559,7 @@ file_readlines(PyFileObject *f, PyObject *args)
do {
/* Process complete lines */
p++;
- line = PyBytes_FromStringAndSize(q, p-q);
+ line = PyString_FromStringAndSize(q, p-q);
if (line == NULL)
goto error;
err = PyList_Append(list, line);
@@ -1578,7 +1578,7 @@ file_readlines(PyFileObject *f, PyObject *args)
}
if (nfilled != 0) {
/* Partial last line */
- line = PyBytes_FromStringAndSize(buffer, nfilled);
+ line = PyString_FromStringAndSize(buffer, nfilled);
if (line == NULL)
goto error;
if (sizehint > 0) {
@@ -1588,7 +1588,7 @@ file_readlines(PyFileObject *f, PyObject *args)
Py_DECREF(line);
goto error;
}
- PyBytes_Concat(&line, rest);
+ PyString_Concat(&line, rest);
Py_DECREF(rest);
if (line == NULL)
goto error;
@@ -1695,7 +1695,7 @@ file_writelines(PyFileObject *f, PyObject *seq)
could potentially execute Python code. */
for (i = 0; i < j; i++) {
PyObject *v = PyList_GET_ITEM(list, i);
- if (!PyBytes_Check(v)) {
+ if (!PyString_Check(v)) {
const char *buffer;
if (((f->f_binary &&
PyObject_AsReadBuffer(v,
@@ -1708,7 +1708,7 @@ file_writelines(PyFileObject *f, PyObject *seq)
"writelines() argument must be a sequence of strings");
goto error;
}
- line = PyBytes_FromStringAndSize(buffer,
+ line = PyString_FromStringAndSize(buffer,
len);
if (line == NULL)
goto error;
@@ -1724,8 +1724,8 @@ file_writelines(PyFileObject *f, PyObject *seq)
errno = 0;
for (i = 0; i < j; i++) {
line = PyList_GET_ITEM(list, i);
- len = PyBytes_GET_SIZE(line);
- nwritten = fwrite(PyBytes_AS_STRING(line),
+ len = PyString_GET_SIZE(line);
+ nwritten = fwrite(PyString_AS_STRING(line),
1, len, f->f_fp);
if (nwritten != len) {
FILE_ABORT_ALLOW_THREADS(f)
@@ -1921,13 +1921,13 @@ get_newlines(PyFileObject *f, void *closure)
Py_INCREF(Py_None);
return Py_None;
case NEWLINE_CR:
- return PyBytes_FromString("\r");
+ return PyString_FromString("\r");
case NEWLINE_LF:
- return PyBytes_FromString("\n");
+ return PyString_FromString("\n");
case NEWLINE_CR|NEWLINE_LF:
return Py_BuildValue("(ss)", "\r", "\n");
case NEWLINE_CRLF:
- return PyBytes_FromString("\r\n");
+ return PyString_FromString("\r\n");
case NEWLINE_CR|NEWLINE_CRLF:
return Py_BuildValue("(ss)", "\r", "\r\n");
case NEWLINE_LF|NEWLINE_CRLF:
@@ -2029,10 +2029,10 @@ readahead(PyFileObject *f, int bufsize)
horrified by the recursive call: maximum recursion depth is limited by
logarithmic buffer growth to about 50 even when reading a 1gb line. */
-static PyBytesObject *
+static PyStringObject *
readahead_get_line_skip(PyFileObject *f, int skip, int bufsize)
{
- PyBytesObject* s;
+ PyStringObject* s;
char *bufptr;
char *buf;
Py_ssize_t len;
@@ -2043,17 +2043,17 @@ readahead_get_line_skip(PyFileObject *f, int skip, int bufsize)
len = f->f_bufend - f->f_bufptr;
if (len == 0)
- return (PyBytesObject *)
- PyBytes_FromStringAndSize(NULL, skip);
+ return (PyStringObject *)
+ PyString_FromStringAndSize(NULL, skip);
bufptr = (char *)memchr(f->f_bufptr, '\n', len);
if (bufptr != NULL) {
bufptr++; /* Count the '\n' */
len = bufptr - f->f_bufptr;
- s = (PyBytesObject *)
- PyBytes_FromStringAndSize(NULL, skip+len);
+ s = (PyStringObject *)
+ PyString_FromStringAndSize(NULL, skip+len);
if (s == NULL)
return NULL;
- memcpy(PyBytes_AS_STRING(s)+skip, f->f_bufptr, len);
+ memcpy(PyString_AS_STRING(s)+skip, f->f_bufptr, len);
f->f_bufptr = bufptr;
if (bufptr == f->f_bufend)
drop_readahead(f);
@@ -2068,7 +2068,7 @@ readahead_get_line_skip(PyFileObject *f, int skip, int bufsize)
PyMem_Free(buf);
return NULL;
}
- memcpy(PyBytes_AS_STRING(s)+skip, bufptr, len);
+ memcpy(PyString_AS_STRING(s)+skip, bufptr, len);
PyMem_Free(buf);
}
return s;
@@ -2080,13 +2080,13 @@ readahead_get_line_skip(PyFileObject *f, int skip, int bufsize)
static PyObject *
file_iternext(PyFileObject *f)
{
- PyBytesObject* l;
+ PyStringObject* l;
if (f->f_fp == NULL)
return err_closed();
l = readahead_get_line_skip(f, 0, READAHEAD_BUFSIZE);
- if (l == NULL || PyBytes_GET_SIZE(l) == 0) {
+ if (l == NULL || PyString_GET_SIZE(l) == 0) {
Py_XDECREF(l);
return NULL;
}
@@ -2103,7 +2103,7 @@ file_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
assert(type != NULL && type->tp_alloc != NULL);
if (not_yet_string == NULL) {
- not_yet_string = PyBytes_InternFromString("<uninitialized file>");
+ not_yet_string = PyString_InternFromString("<uninitialized file>");
if (not_yet_string == NULL)
return NULL;
}
@@ -2394,7 +2394,7 @@ PyFile_WriteString(const char *s, PyObject *f)
return 0;
}
else if (!PyErr_Occurred()) {
- PyObject *v = PyBytes_FromString(s);
+ PyObject *v = PyString_FromString(s);
int err;
if (v == NULL)
return -1;
diff --git a/Objects/floatobject.c b/Objects/floatobject.c
index baf55aa..32e7cc8 100644
--- a/Objects/floatobject.c
+++ b/Objects/floatobject.c
@@ -182,9 +182,9 @@ PyFloat_FromString(PyObject *v, char **pend)
if (pend)
*pend = NULL;
- if (PyBytes_Check(v)) {
- s = PyBytes_AS_STRING(v);
- len = PyBytes_GET_SIZE(v);
+ if (PyString_Check(v)) {
+ s = PyString_AS_STRING(v);
+ len = PyString_GET_SIZE(v);
}
#ifdef Py_USING_UNICODE
else if (PyUnicode_Check(v)) {
@@ -485,7 +485,7 @@ float_repr(PyFloatObject *v)
char buf[100];
format_float(buf, sizeof(buf), v, PREC_REPR);
- return PyBytes_FromString(buf);
+ return PyString_FromString(buf);
}
static PyObject *
@@ -493,7 +493,7 @@ float_str(PyFloatObject *v)
{
char buf[100];
format_float(buf, sizeof(buf), v, PREC_STR);
- return PyBytes_FromString(buf);
+ return PyString_FromString(buf);
}
/* Comparison is pretty much a nightmare. When comparing float to float,
@@ -1218,7 +1218,7 @@ float_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
return float_subtype_new(type, args, kwds); /* Wimp out */
if (!PyArg_ParseTupleAndKeywords(args, kwds, "|O:float", kwlist, &x))
return NULL;
- if (PyBytes_Check(x))
+ if (PyString_Check(x))
return PyFloat_FromString(x, NULL);
return PyNumber_Float(x);
}
@@ -1269,13 +1269,13 @@ float_getformat(PyTypeObject *v, PyObject* arg)
char* s;
float_format_type r;
- if (!PyBytes_Check(arg)) {
+ if (!PyString_Check(arg)) {
PyErr_Format(PyExc_TypeError,
"__getformat__() argument must be string, not %.500s",
Py_TYPE(arg)->tp_name);
return NULL;
}
- s = PyBytes_AS_STRING(arg);
+ s = PyString_AS_STRING(arg);
if (strcmp(s, "double") == 0) {
r = double_format;
}
@@ -1291,11 +1291,11 @@ float_getformat(PyTypeObject *v, PyObject* arg)
switch (r) {
case unknown_format:
- return PyBytes_FromString("unknown");
+ return PyString_FromString("unknown");
case ieee_little_endian_format:
- return PyBytes_FromString("IEEE, little-endian");
+ return PyString_FromString("IEEE, little-endian");
case ieee_big_endian_format:
- return PyBytes_FromString("IEEE, big-endian");
+ return PyString_FromString("IEEE, big-endian");
default:
Py_FatalError("insane float_format or double_format");
return NULL;
diff --git a/Objects/frameobject.c b/Objects/frameobject.c
index 36c1fc2..025431e 100644
--- a/Objects/frameobject.c
+++ b/Objects/frameobject.c
@@ -114,7 +114,7 @@ frame_setlineno(PyFrameObject *f, PyObject* p_new_lineno)
/* Find the bytecode offset for the start of the given line, or the
* first code-owning line after it. */
- PyBytes_AsStringAndSize(f->f_code->co_lnotab, &lnotab, &lnotab_len);
+ PyString_AsStringAndSize(f->f_code->co_lnotab, &lnotab, &lnotab_len);
addr = 0;
line = f->f_code->co_firstlineno;
new_lasti = -1;
@@ -137,7 +137,7 @@ frame_setlineno(PyFrameObject *f, PyObject* p_new_lineno)
}
/* We're now ready to look at the bytecode. */
- PyBytes_AsStringAndSize(f->f_code->co_code, (char **)&code, &code_len);
+ PyString_AsStringAndSize(f->f_code->co_code, (char **)&code, &code_len);
min_addr = MIN(new_lasti, f->f_lasti);
max_addr = MAX(new_lasti, f->f_lasti);
@@ -548,7 +548,7 @@ static PyObject *builtin_object;
int _PyFrame_Init()
{
- builtin_object = PyBytes_InternFromString("__builtins__");
+ builtin_object = PyString_InternFromString("__builtins__");
return (builtin_object != NULL);
}
@@ -728,7 +728,7 @@ map_to_dict(PyObject *map, Py_ssize_t nmap, PyObject *dict, PyObject **values,
for (j = nmap; --j >= 0; ) {
PyObject *key = PyTuple_GET_ITEM(map, j);
PyObject *value = values[j];
- assert(PyBytes_Check(key));
+ assert(PyString_Check(key));
if (deref) {
assert(PyCell_Check(value));
value = PyCell_GET(value);
@@ -776,7 +776,7 @@ dict_to_map(PyObject *map, Py_ssize_t nmap, PyObject *dict, PyObject **values,
for (j = nmap; --j >= 0; ) {
PyObject *key = PyTuple_GET_ITEM(map, j);
PyObject *value = PyObject_GetItem(dict, key);
- assert(PyBytes_Check(key));
+ assert(PyString_Check(key));
/* We only care about NULLs if clear is true. */
if (value == NULL) {
PyErr_Clear();
diff --git a/Objects/funcobject.c b/Objects/funcobject.c
index 216b6da..a2e87b7 100644
--- a/Objects/funcobject.c
+++ b/Objects/funcobject.c
@@ -28,7 +28,7 @@ PyFunction_New(PyObject *code, PyObject *globals)
consts = ((PyCodeObject *)code)->co_consts;
if (PyTuple_Size(consts) >= 1) {
doc = PyTuple_GetItem(consts, 0);
- if (!PyBytes_Check(doc) && !PyUnicode_Check(doc))
+ if (!PyString_Check(doc) && !PyUnicode_Check(doc))
doc = Py_None;
}
else
@@ -42,7 +42,7 @@ PyFunction_New(PyObject *code, PyObject *globals)
Otherwise, use None.
*/
if (!__name__) {
- __name__ = PyBytes_InternFromString("__name__");
+ __name__ = PyString_InternFromString("__name__");
if (!__name__) {
Py_DECREF(op);
return NULL;
@@ -254,7 +254,7 @@ func_set_code(PyFunctionObject *op, PyObject *value)
PyErr_Format(PyExc_ValueError,
"%s() requires a code object with %zd free vars,"
" not %zd",
- PyBytes_AsString(op->func_name),
+ PyString_AsString(op->func_name),
nclosure, nfree);
return -1;
}
@@ -281,7 +281,7 @@ func_set_name(PyFunctionObject *op, PyObject *value)
return -1;
/* Not legal to del f.func_name or to set it to anything
* other than a string object. */
- if (value == NULL || !PyBytes_Check(value)) {
+ if (value == NULL || !PyString_Check(value)) {
PyErr_SetString(PyExc_TypeError,
"__name__ must be set to a string object");
return -1;
@@ -380,7 +380,7 @@ func_new(PyTypeObject* type, PyObject* args, PyObject* kw)
&PyDict_Type, &globals,
&name, &defaults, &closure))
return NULL;
- if (name != Py_None && !PyBytes_Check(name)) {
+ if (name != Py_None && !PyString_Check(name)) {
PyErr_SetString(PyExc_TypeError,
"arg 3 (name) must be None or string");
return NULL;
@@ -409,7 +409,7 @@ func_new(PyTypeObject* type, PyObject* args, PyObject* kw)
if (nfree != nclosure)
return PyErr_Format(PyExc_ValueError,
"%s requires closure of length %zd, not %zd",
- PyBytes_AS_STRING(code->co_name),
+ PyString_AS_STRING(code->co_name),
nfree, nclosure);
if (nclosure) {
Py_ssize_t i;
@@ -465,8 +465,8 @@ func_dealloc(PyFunctionObject *op)
static PyObject*
func_repr(PyFunctionObject *op)
{
- return PyBytes_FromFormat("<function %s at %p>",
- PyBytes_AsString(op->func_name),
+ return PyString_FromFormat("<function %s at %p>",
+ PyString_AsString(op->func_name),
op);
}
diff --git a/Objects/genobject.c b/Objects/genobject.c
index b1c51a8..d2ef508 100644
--- a/Objects/genobject.c
+++ b/Objects/genobject.c
@@ -285,10 +285,10 @@ static PyObject *
gen_repr(PyGenObject *gen)
{
char *code_name;
- code_name = PyBytes_AsString(((PyCodeObject *)gen->gi_code)->co_name);
+ code_name = PyString_AsString(((PyCodeObject *)gen->gi_code)->co_name);
if (code_name == NULL)
return NULL;
- return PyBytes_FromFormat("<generator object %.200s at %p>",
+ return PyString_FromFormat("<generator object %.200s at %p>",
code_name, gen);
}
diff --git a/Objects/intobject.c b/Objects/intobject.c
index 3b68640..f98aee0 100644
--- a/Objects/intobject.c
+++ b/Objects/intobject.c
@@ -367,7 +367,7 @@ PyInt_FromString(char *s, char **pend, int base)
if (*end != '\0') {
bad:
slen = strlen(s) < 200 ? strlen(s) : 200;
- sobj = PyBytes_FromStringAndSize(s, slen);
+ sobj = PyString_FromStringAndSize(s, slen);
if (sobj == NULL)
return NULL;
srepr = PyObject_Repr(sobj);
@@ -376,7 +376,7 @@ PyInt_FromString(char *s, char **pend, int base)
return NULL;
PyErr_Format(PyExc_ValueError,
"invalid literal for int() with base %d: %s",
- base, PyBytes_AS_STRING(srepr));
+ base, PyString_AS_STRING(srepr));
Py_DECREF(srepr);
return NULL;
}
@@ -964,11 +964,11 @@ int_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
return PyInt_FromLong(0L);
if (base == -909)
return PyNumber_Int(x);
- if (PyBytes_Check(x)) {
+ if (PyString_Check(x)) {
/* Since PyInt_FromString doesn't have a length parameter,
* check here for possible NULs in the string. */
- char *string = PyBytes_AS_STRING(x);
- if (strlen(string) != PyBytes_Size(x)) {
+ char *string = PyString_AS_STRING(x);
+ if (strlen(string) != PyString_Size(x)) {
/* create a repr() of the input string,
* just like PyInt_FromString does */
PyObject *srepr;
@@ -977,7 +977,7 @@ int_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
return NULL;
PyErr_Format(PyExc_ValueError,
"invalid literal for int() with base %d: %s",
- base, PyBytes_AS_STRING(srepr));
+ base, PyString_AS_STRING(srepr));
Py_DECREF(srepr);
return NULL;
}
@@ -1105,7 +1105,7 @@ _PyInt_Format(PyIntObject *v, int base, int newstyle)
if (negative)
*--p = '-';
- return PyBytes_FromStringAndSize(p, &buf[sizeof(buf)] - p);
+ return PyString_FromStringAndSize(p, &buf[sizeof(buf)] - p);
}
static PyObject *
diff --git a/Objects/listobject.c b/Objects/listobject.c
index 796e8cb..e72f81f 100644
--- a/Objects/listobject.c
+++ b/Objects/listobject.c
@@ -174,7 +174,7 @@ PyList_GetItem(PyObject *op, Py_ssize_t i)
}
if (i < 0 || i >= Py_SIZE(op)) {
if (indexerr == NULL)
- indexerr = PyBytes_FromString(
+ indexerr = PyString_FromString(
"list index out of range");
PyErr_SetObject(PyExc_IndexError, indexerr);
return NULL;
@@ -349,11 +349,11 @@ list_repr(PyListObject *v)
i = Py_ReprEnter((PyObject*)v);
if (i != 0) {
- return i > 0 ? PyBytes_FromString("[...]") : NULL;
+ return i > 0 ? PyString_FromString("[...]") : NULL;
}
if (Py_SIZE(v) == 0) {
- result = PyBytes_FromString("[]");
+ result = PyString_FromString("[]");
goto Done;
}
@@ -379,29 +379,29 @@ list_repr(PyListObject *v)
/* Add "[]" decorations to the first and last items. */
assert(PyList_GET_SIZE(pieces) > 0);
- s = PyBytes_FromString("[");
+ s = PyString_FromString("[");
if (s == NULL)
goto Done;
temp = PyList_GET_ITEM(pieces, 0);
- PyBytes_ConcatAndDel(&s, temp);
+ PyString_ConcatAndDel(&s, temp);
PyList_SET_ITEM(pieces, 0, s);
if (s == NULL)
goto Done;
- s = PyBytes_FromString("]");
+ s = PyString_FromString("]");
if (s == NULL)
goto Done;
temp = PyList_GET_ITEM(pieces, PyList_GET_SIZE(pieces) - 1);
- PyBytes_ConcatAndDel(&temp, s);
+ PyString_ConcatAndDel(&temp, s);
PyList_SET_ITEM(pieces, PyList_GET_SIZE(pieces) - 1, temp);
if (temp == NULL)
goto Done;
/* Paste them all together with ", " between. */
- s = PyBytes_FromString(", ");
+ s = PyString_FromString(", ");
if (s == NULL)
goto Done;
- result = _PyBytes_Join(s, pieces);
+ result = _PyString_Join(s, pieces);
Py_DECREF(s);
Done:
@@ -433,7 +433,7 @@ list_item(PyListObject *a, Py_ssize_t i)
{
if (i < 0 || i >= Py_SIZE(a)) {
if (indexerr == NULL)
- indexerr = PyBytes_FromString(
+ indexerr = PyString_FromString(
"list index out of range");
PyErr_SetObject(PyExc_IndexError, indexerr);
return NULL;
diff --git a/Objects/longobject.c b/Objects/longobject.c
index c9d138b..c65d0c0 100644
--- a/Objects/longobject.c
+++ b/Objects/longobject.c
@@ -1199,7 +1199,7 @@ PyAPI_FUNC(PyObject *)
_PyLong_Format(PyObject *aa, int base, int addL, int newstyle)
{
register PyLongObject *a = (PyLongObject *)aa;
- PyBytesObject *str;
+ PyStringObject *str;
Py_ssize_t i, j, sz;
Py_ssize_t size_a;
char *p;
@@ -1228,10 +1228,10 @@ _PyLong_Format(PyObject *aa, int base, int addL, int newstyle)
"long is too large to format");
return NULL;
}
- str = (PyBytesObject *) PyBytes_FromStringAndSize((char *)0, sz);
+ str = (PyStringObject *) PyString_FromStringAndSize((char *)0, sz);
if (str == NULL)
return NULL;
- p = PyBytes_AS_STRING(str) + sz;
+ p = PyString_AS_STRING(str) + sz;
*p = '\0';
if (addL)
*--p = 'L';
@@ -1257,7 +1257,7 @@ _PyLong_Format(PyObject *aa, int base, int addL, int newstyle)
do {
char cdigit = (char)(accum & (base - 1));
cdigit += (cdigit < 10) ? '0' : 'a'-10;
- assert(p > PyBytes_AS_STRING(str));
+ assert(p > PyString_AS_STRING(str));
*--p = cdigit;
accumbits -= basebits;
accum >>= basebits;
@@ -1309,7 +1309,7 @@ _PyLong_Format(PyObject *aa, int base, int addL, int newstyle)
do {
digit nextrem = (digit)(rem / base);
char c = (char)(rem - nextrem * base);
- assert(p > PyBytes_AS_STRING(str));
+ assert(p > PyString_AS_STRING(str));
c += (c < 10) ? '0' : 'a'-10;
*--p = c;
rem = nextrem;
@@ -1347,14 +1347,14 @@ _PyLong_Format(PyObject *aa, int base, int addL, int newstyle)
}
if (sign)
*--p = sign;
- if (p != PyBytes_AS_STRING(str)) {
- char *q = PyBytes_AS_STRING(str);
+ if (p != PyString_AS_STRING(str)) {
+ char *q = PyString_AS_STRING(str);
assert(p > q);
do {
} while ((*q++ = *p++) != '\0');
q--;
- _PyBytes_Resize((PyObject **)&str,
- (Py_ssize_t) (q - PyBytes_AS_STRING(str)));
+ _PyString_Resize((PyObject **)&str,
+ (Py_ssize_t) (q - PyString_AS_STRING(str)));
}
return (PyObject *)str;
}
@@ -1718,7 +1718,7 @@ digit beyond the first.
onError:
Py_XDECREF(z);
slen = strlen(orig_str) < 200 ? strlen(orig_str) : 200;
- strobj = PyBytes_FromStringAndSize(orig_str, slen);
+ strobj = PyString_FromStringAndSize(orig_str, slen);
if (strobj == NULL)
return NULL;
strrepr = PyObject_Repr(strobj);
@@ -1727,7 +1727,7 @@ digit beyond the first.
return NULL;
PyErr_Format(PyExc_ValueError,
"invalid literal for long() with base %d: %s",
- base, PyBytes_AS_STRING(strrepr));
+ base, PyString_AS_STRING(strrepr));
Py_DECREF(strrepr);
return NULL;
}
@@ -3331,11 +3331,11 @@ long_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
return PyLong_FromLong(0L);
if (base == -909)
return PyNumber_Long(x);
- else if (PyBytes_Check(x)) {
+ else if (PyString_Check(x)) {
/* Since PyLong_FromString doesn't have a length parameter,
* check here for possible NULs in the string. */
- char *string = PyBytes_AS_STRING(x);
- if (strlen(string) != PyBytes_Size(x)) {
+ char *string = PyString_AS_STRING(x);
+ if (strlen(string) != PyString_Size(x)) {
/* create a repr() of the input string,
* just like PyLong_FromString does. */
PyObject *srepr;
@@ -3344,11 +3344,11 @@ long_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
return NULL;
PyErr_Format(PyExc_ValueError,
"invalid literal for long() with base %d: %s",
- base, PyBytes_AS_STRING(srepr));
+ base, PyString_AS_STRING(srepr));
Py_DECREF(srepr);
return NULL;
}
- return PyLong_FromString(PyBytes_AS_STRING(x), NULL, base);
+ return PyLong_FromString(PyString_AS_STRING(x), NULL, base);
}
#ifdef Py_USING_UNICODE
else if (PyUnicode_Check(x))
diff --git a/Objects/methodobject.c b/Objects/methodobject.c
index 57ab5c5..737a3f7 100644
--- a/Objects/methodobject.c
+++ b/Objects/methodobject.c
@@ -149,7 +149,7 @@ meth_get__doc__(PyCFunctionObject *m, void *closure)
const char *doc = m->m_ml->ml_doc;
if (doc != NULL)
- return PyBytes_FromString(doc);
+ return PyString_FromString(doc);
Py_INCREF(Py_None);
return Py_None;
}
@@ -157,7 +157,7 @@ meth_get__doc__(PyCFunctionObject *m, void *closure)
static PyObject *
meth_get__name__(PyCFunctionObject *m, void *closure)
{
- return PyBytes_FromString(m->m_ml->ml_name);
+ return PyString_FromString(m->m_ml->ml_name);
}
static int
@@ -202,9 +202,9 @@ static PyObject *
meth_repr(PyCFunctionObject *m)
{
if (m->m_self == NULL)
- return PyBytes_FromFormat("<built-in function %s>",
+ return PyString_FromFormat("<built-in function %s>",
m->m_ml->ml_name);
- return PyBytes_FromFormat("<built-in method %s of %s object at %p>",
+ return PyString_FromFormat("<built-in method %s of %s object at %p>",
m->m_ml->ml_name,
m->m_self->ob_type->tp_name,
m->m_self);
@@ -333,7 +333,7 @@ listmethodchain(PyMethodChain *chain)
i = 0;
for (c = chain; c != NULL; c = c->link) {
for (ml = c->methods; ml->ml_name != NULL; ml++) {
- PyList_SetItem(v, i, PyBytes_FromString(ml->ml_name));
+ PyList_SetItem(v, i, PyString_FromString(ml->ml_name));
i++;
}
}
@@ -360,7 +360,7 @@ Py_FindMethodInChain(PyMethodChain *chain, PyObject *self, const char *name)
if (strcmp(name, "__doc__") == 0) {
const char *doc = self->ob_type->tp_doc;
if (doc != NULL)
- return PyBytes_FromString(doc);
+ return PyString_FromString(doc);
}
}
while (chain != NULL) {
diff --git a/Objects/moduleobject.c b/Objects/moduleobject.c
index fa3daa9..d1aa771 100644
--- a/Objects/moduleobject.c
+++ b/Objects/moduleobject.c
@@ -22,7 +22,7 @@ PyModule_New(const char *name)
m = PyObject_GC_New(PyModuleObject, &PyModule_Type);
if (m == NULL)
return NULL;
- nameobj = PyBytes_FromString(name);
+ nameobj = PyString_FromString(name);
m->md_dict = PyDict_New();
if (m->md_dict == NULL || nameobj == NULL)
goto fail;
@@ -68,12 +68,12 @@ PyModule_GetName(PyObject *m)
d = ((PyModuleObject *)m)->md_dict;
if (d == NULL ||
(nameobj = PyDict_GetItemString(d, "__name__")) == NULL ||
- !PyBytes_Check(nameobj))
+ !PyString_Check(nameobj))
{
PyErr_SetString(PyExc_SystemError, "nameless module");
return NULL;
}
- return PyBytes_AsString(nameobj);
+ return PyString_AsString(nameobj);
}
char *
@@ -88,12 +88,12 @@ PyModule_GetFilename(PyObject *m)
d = ((PyModuleObject *)m)->md_dict;
if (d == NULL ||
(fileobj = PyDict_GetItemString(d, "__file__")) == NULL ||
- !PyBytes_Check(fileobj))
+ !PyString_Check(fileobj))
{
PyErr_SetString(PyExc_SystemError, "module filename missing");
return NULL;
}
- return PyBytes_AsString(fileobj);
+ return PyString_AsString(fileobj);
}
void
@@ -117,8 +117,8 @@ _PyModule_Clear(PyObject *m)
/* First, clear only names starting with a single underscore */
pos = 0;
while (PyDict_Next(d, &pos, &key, &value)) {
- if (value != Py_None && PyBytes_Check(key)) {
- char *s = PyBytes_AsString(key);
+ if (value != Py_None && PyString_Check(key)) {
+ char *s = PyString_AsString(key);
if (s[0] == '_' && s[1] != '_') {
if (Py_VerboseFlag > 1)
PySys_WriteStderr("# clear[1] %s\n", s);
@@ -130,8 +130,8 @@ _PyModule_Clear(PyObject *m)
/* Next, clear all names except for __builtins__ */
pos = 0;
while (PyDict_Next(d, &pos, &key, &value)) {
- if (value != Py_None && PyBytes_Check(key)) {
- char *s = PyBytes_AsString(key);
+ if (value != Py_None && PyString_Check(key)) {
+ char *s = PyString_AsString(key);
if (s[0] != '_' || strcmp(s, "__builtins__") != 0) {
if (Py_VerboseFlag > 1)
PySys_WriteStderr("# clear[2] %s\n", s);
@@ -195,9 +195,9 @@ module_repr(PyModuleObject *m)
filename = PyModule_GetFilename((PyObject *)m);
if (filename == NULL) {
PyErr_Clear();
- return PyBytes_FromFormat("<module '%s' (built-in)>", name);
+ return PyString_FromFormat("<module '%s' (built-in)>", name);
}
- return PyBytes_FromFormat("<module '%s' from '%s'>", name, filename);
+ return PyString_FromFormat("<module '%s' from '%s'>", name, filename);
}
/* We only need a traverse function, no clear function: If the module
diff --git a/Objects/object.c b/Objects/object.c
index 8f9d731..ccb5ab7 100644
--- a/Objects/object.c
+++ b/Objects/object.c
@@ -357,9 +357,9 @@ PyObject_Repr(PyObject *v)
}
#endif
if (v == NULL)
- return PyBytes_FromString("<NULL>");
+ return PyString_FromString("<NULL>");
else if (Py_TYPE(v)->tp_repr == NULL)
- return PyBytes_FromFormat("<%s object at %p>",
+ return PyString_FromFormat("<%s object at %p>",
Py_TYPE(v)->tp_name, v);
else {
PyObject *res;
@@ -377,7 +377,7 @@ PyObject_Repr(PyObject *v)
return NULL;
}
#endif
- if (!PyBytes_Check(res)) {
+ if (!PyString_Check(res)) {
PyErr_Format(PyExc_TypeError,
"__repr__ returned non-string (type %.200s)",
Py_TYPE(res)->tp_name);
@@ -394,8 +394,8 @@ _PyObject_Str(PyObject *v)
PyObject *res;
int type_ok;
if (v == NULL)
- return PyBytes_FromString("<NULL>");
- if (PyBytes_CheckExact(v)) {
+ return PyString_FromString("<NULL>");
+ if (PyString_CheckExact(v)) {
Py_INCREF(v);
return v;
}
@@ -416,7 +416,7 @@ _PyObject_Str(PyObject *v)
Py_LeaveRecursiveCall();
if (res == NULL)
return NULL;
- type_ok = PyBytes_Check(res);
+ type_ok = PyString_Check(res);
#ifdef Py_USING_UNICODE
type_ok = type_ok || PyUnicode_Check(res);
#endif
@@ -447,7 +447,7 @@ PyObject_Str(PyObject *v)
return NULL;
}
#endif
- assert(PyBytes_Check(res));
+ assert(PyString_Check(res));
return res;
}
@@ -461,7 +461,7 @@ PyObject_Unicode(PyObject *v)
static PyObject *unicodestr;
if (v == NULL) {
- res = PyBytes_FromString("<NULL>");
+ res = PyString_FromString("<NULL>");
if (res == NULL)
return NULL;
str = PyUnicode_FromEncodedObject(res, NULL, "strict");
@@ -475,7 +475,7 @@ PyObject_Unicode(PyObject *v)
check this before trying the __unicode__
method. */
if (unicodestr == NULL) {
- unicodestr= PyBytes_InternFromString("__unicode__");
+ unicodestr= PyString_InternFromString("__unicode__");
if (unicodestr == NULL)
return NULL;
}
@@ -492,7 +492,7 @@ PyObject_Unicode(PyObject *v)
return PyUnicode_FromUnicode(PyUnicode_AS_UNICODE(v),
PyUnicode_GET_SIZE(v));
}
- if (PyBytes_CheckExact(v)) {
+ if (PyString_CheckExact(v)) {
Py_INCREF(v);
res = v;
}
@@ -1084,7 +1084,7 @@ PyObject_GetAttrString(PyObject *v, const char *name)
if (Py_TYPE(v)->tp_getattr != NULL)
return (*Py_TYPE(v)->tp_getattr)(v, (char*)name);
- w = PyBytes_InternFromString(name);
+ w = PyString_InternFromString(name);
if (w == NULL)
return NULL;
res = PyObject_GetAttr(v, w);
@@ -1112,7 +1112,7 @@ PyObject_SetAttrString(PyObject *v, const char *name, PyObject *w)
if (Py_TYPE(v)->tp_setattr != NULL)
return (*Py_TYPE(v)->tp_setattr)(v, (char*)name, w);
- s = PyBytes_InternFromString(name);
+ s = PyString_InternFromString(name);
if (s == NULL)
return -1;
res = PyObject_SetAttr(v, s, w);
@@ -1125,7 +1125,7 @@ PyObject_GetAttr(PyObject *v, PyObject *name)
{
PyTypeObject *tp = Py_TYPE(v);
- if (!PyBytes_Check(name)) {
+ if (!PyString_Check(name)) {
#ifdef Py_USING_UNICODE
/* The Unicode to string conversion is done here because the
existing tp_getattro slots expect a string object as name
@@ -1147,10 +1147,10 @@ PyObject_GetAttr(PyObject *v, PyObject *name)
if (tp->tp_getattro != NULL)
return (*tp->tp_getattro)(v, name);
if (tp->tp_getattr != NULL)
- return (*tp->tp_getattr)(v, PyBytes_AS_STRING(name));
+ return (*tp->tp_getattr)(v, PyString_AS_STRING(name));
PyErr_Format(PyExc_AttributeError,
"'%.50s' object has no attribute '%.400s'",
- tp->tp_name, PyBytes_AS_STRING(name));
+ tp->tp_name, PyString_AS_STRING(name));
return NULL;
}
@@ -1172,7 +1172,7 @@ PyObject_SetAttr(PyObject *v, PyObject *name, PyObject *value)
PyTypeObject *tp = Py_TYPE(v);
int err;
- if (!PyBytes_Check(name)){
+ if (!PyString_Check(name)){
#ifdef Py_USING_UNICODE
/* The Unicode to string conversion is done here because the
existing tp_setattro slots expect a string object as name
@@ -1194,14 +1194,14 @@ PyObject_SetAttr(PyObject *v, PyObject *name, PyObject *value)
else
Py_INCREF(name);
- PyBytes_InternInPlace(&name);
+ PyString_InternInPlace(&name);
if (tp->tp_setattro != NULL) {
err = (*tp->tp_setattro)(v, name, value);
Py_DECREF(name);
return err;
}
if (tp->tp_setattr != NULL) {
- err = (*tp->tp_setattr)(v, PyBytes_AS_STRING(name), value);
+ err = (*tp->tp_setattr)(v, PyString_AS_STRING(name), value);
Py_DECREF(name);
return err;
}
@@ -1212,14 +1212,14 @@ PyObject_SetAttr(PyObject *v, PyObject *name, PyObject *value)
"(%s .%.100s)",
tp->tp_name,
value==NULL ? "del" : "assign to",
- PyBytes_AS_STRING(name));
+ PyString_AS_STRING(name));
else
PyErr_Format(PyExc_TypeError,
"'%.100s' object has only read-only attributes "
"(%s .%.100s)",
tp->tp_name,
value==NULL ? "del" : "assign to",
- PyBytes_AS_STRING(name));
+ PyString_AS_STRING(name));
return -1;
}
@@ -1271,7 +1271,7 @@ PyObject_GenericGetAttr(PyObject *obj, PyObject *name)
Py_ssize_t dictoffset;
PyObject **dictptr;
- if (!PyBytes_Check(name)){
+ if (!PyString_Check(name)){
#ifdef Py_USING_UNICODE
/* The Unicode to string conversion is done here because the
existing tp_setattro slots expect a string object as name
@@ -1386,7 +1386,7 @@ PyObject_GenericGetAttr(PyObject *obj, PyObject *name)
PyErr_Format(PyExc_AttributeError,
"'%.50s' object has no attribute '%.400s'",
- tp->tp_name, PyBytes_AS_STRING(name));
+ tp->tp_name, PyString_AS_STRING(name));
done:
Py_DECREF(name);
return res;
@@ -1401,7 +1401,7 @@ PyObject_GenericSetAttr(PyObject *obj, PyObject *name, PyObject *value)
PyObject **dictptr;
int res = -1;
- if (!PyBytes_Check(name)){
+ if (!PyString_Check(name)){
#ifdef Py_USING_UNICODE
/* The Unicode to string conversion is done here because the
existing tp_setattro slots expect a string object as name
@@ -1469,13 +1469,13 @@ PyObject_GenericSetAttr(PyObject *obj, PyObject *name, PyObject *value)
if (descr == NULL) {
PyErr_Format(PyExc_AttributeError,
"'%.100s' object has no attribute '%.200s'",
- tp->tp_name, PyBytes_AS_STRING(name));
+ tp->tp_name, PyString_AS_STRING(name));
goto done;
}
PyErr_Format(PyExc_AttributeError,
"'%.50s' object attribute '%.400s' is read-only",
- tp->tp_name, PyBytes_AS_STRING(name));
+ tp->tp_name, PyString_AS_STRING(name));
done:
Py_DECREF(name);
return res;
@@ -1682,7 +1682,7 @@ merge_list_attr(PyObject* dict, PyObject* obj, const char *attrname)
int i;
for (i = 0; i < PyList_GET_SIZE(list); ++i) {
PyObject *item = PyList_GET_ITEM(list, i);
- if (PyBytes_Check(item)) {
+ if (PyString_Check(item)) {
result = PyDict_SetItem(dict, item, Py_None);
if (result < 0)
break;
@@ -1904,7 +1904,7 @@ so there is exactly one (which is indestructible, by the way).
static PyObject *
none_repr(PyObject *op)
{
- return PyBytes_FromString("None");
+ return PyString_FromString("None");
}
/* ARGUSED */
@@ -1946,7 +1946,7 @@ PyObject _Py_NoneStruct = {
static PyObject *
NotImplemented_repr(PyObject *op)
{
- return PyBytes_FromString("NotImplemented");
+ return PyString_FromString("NotImplemented");
}
static PyTypeObject PyNotImplemented_Type = {
@@ -1983,7 +1983,7 @@ _Py_ReadyTypes(void)
if (PyType_Ready(&PyBool_Type) < 0)
Py_FatalError("Can't initialize 'bool'");
- if (PyType_Ready(&PyBytes_Type) < 0)
+ if (PyType_Ready(&PyString_Type) < 0)
Py_FatalError("Can't initialize 'str'");
if (PyType_Ready(&PyByteArray_Type) < 0)
diff --git a/Objects/rangeobject.c b/Objects/rangeobject.c
index b3ed673..da4356b 100644
--- a/Objects/rangeobject.c
+++ b/Objects/rangeobject.c
@@ -113,16 +113,16 @@ range_repr(rangeobject *r)
PyObject *rtn;
if (r->start == 0 && r->step == 1)
- rtn = PyBytes_FromFormat("xrange(%ld)",
+ rtn = PyString_FromFormat("xrange(%ld)",
r->start + r->len * r->step);
else if (r->step == 1)
- rtn = PyBytes_FromFormat("xrange(%ld, %ld)",
+ rtn = PyString_FromFormat("xrange(%ld, %ld)",
r->start,
r->start + r->len * r->step);
else
- rtn = PyBytes_FromFormat("xrange(%ld, %ld, %ld)",
+ rtn = PyString_FromFormat("xrange(%ld, %ld, %ld)",
r->start,
r->start + r->len * r->step,
r->step);
diff --git a/Objects/setobject.c b/Objects/setobject.c
index 5e8e05d..371d8c1 100644
--- a/Objects/setobject.c
+++ b/Objects/setobject.c
@@ -151,7 +151,7 @@ set_lookkey(PySetObject *so, PyObject *key, register long hash)
/*
* Hacked up version of set_lookkey which can assume keys are always strings;
- * This means we can always use _PyBytes_Eq directly and not have to check to
+ * This means we can always use _PyString_Eq directly and not have to check to
* see if the comparison altered the table.
*/
static setentry *
@@ -168,7 +168,7 @@ set_lookkey_string(PySetObject *so, PyObject *key, register long hash)
including subclasses of str; e.g., one reason to subclass
strings is to override __eq__, and for speed we don't cater to
that here. */
- if (!PyBytes_CheckExact(key)) {
+ if (!PyString_CheckExact(key)) {
so->lookup = set_lookkey;
return set_lookkey(so, key, hash);
}
@@ -179,7 +179,7 @@ set_lookkey_string(PySetObject *so, PyObject *key, register long hash)
if (entry->key == dummy)
freeslot = entry;
else {
- if (entry->hash == hash && _PyBytes_Eq(entry->key, key))
+ if (entry->hash == hash && _PyString_Eq(entry->key, key))
return entry;
freeslot = NULL;
}
@@ -194,7 +194,7 @@ set_lookkey_string(PySetObject *so, PyObject *key, register long hash)
if (entry->key == key
|| (entry->hash == hash
&& entry->key != dummy
- && _PyBytes_Eq(entry->key, key)))
+ && _PyString_Eq(entry->key, key)))
return entry;
if (entry->key == dummy && freeslot == NULL)
freeslot = entry;
@@ -381,8 +381,8 @@ set_add_key(register PySetObject *so, PyObject *key)
register long hash;
register Py_ssize_t n_used;
- if (!PyBytes_CheckExact(key) ||
- (hash = ((PyBytesObject *) key)->ob_shash) == -1) {
+ if (!PyString_CheckExact(key) ||
+ (hash = ((PyStringObject *) key)->ob_shash) == -1) {
hash = PyObject_Hash(key);
if (hash == -1)
return -1;
@@ -428,8 +428,8 @@ set_discard_key(PySetObject *so, PyObject *key)
PyObject *old_key;
assert (PyAnySet_Check(so));
- if (!PyBytes_CheckExact(key) ||
- (hash = ((PyBytesObject *) key)->ob_shash) == -1) {
+ if (!PyString_CheckExact(key) ||
+ (hash = ((PyStringObject *) key)->ob_shash) == -1) {
hash = PyObject_Hash(key);
if (hash == -1)
return -1;
@@ -618,7 +618,7 @@ set_repr(PySetObject *so)
if (status != 0) {
if (status < 0)
return NULL;
- return PyBytes_FromFormat("%s(...)", so->ob_type->tp_name);
+ return PyString_FromFormat("%s(...)", so->ob_type->tp_name);
}
keys = PySequence_List((PyObject *)so);
@@ -629,8 +629,8 @@ set_repr(PySetObject *so)
if (listrepr == NULL)
goto done;
- result = PyBytes_FromFormat("%s(%s)", so->ob_type->tp_name,
- PyBytes_AS_STRING(listrepr));
+ result = PyString_FromFormat("%s(%s)", so->ob_type->tp_name,
+ PyString_AS_STRING(listrepr));
Py_DECREF(listrepr);
done:
Py_ReprLeave((PyObject*)so);
@@ -685,8 +685,8 @@ set_contains_key(PySetObject *so, PyObject *key)
long hash;
setentry *entry;
- if (!PyBytes_CheckExact(key) ||
- (hash = ((PyBytesObject *) key)->ob_shash) == -1) {
+ if (!PyString_CheckExact(key) ||
+ (hash = ((PyStringObject *) key)->ob_shash) == -1) {
hash = PyObject_Hash(key);
if (hash == -1)
return -1;
@@ -983,7 +983,7 @@ make_new_set(PyTypeObject *type, PyObject *iterable)
register PySetObject *so = NULL;
if (dummy == NULL) { /* Auto-initialize dummy */
- dummy = PyBytes_FromString("<dummy key>");
+ dummy = PyString_FromString("<dummy key>");
if (dummy == NULL)
return NULL;
}
@@ -2322,7 +2322,7 @@ test_c_api(PySetObject *so)
/* Exercise direct iteration */
i = 0, count = 0;
while (_PySet_Next((PyObject *)dup, &i, &x)) {
- s = PyBytes_AsString(x);
+ s = PyString_AsString(x);
assert(s && (s[0] == 'a' || s[0] == 'b' || s[0] == 'c'));
count++;
}
diff --git a/Objects/sliceobject.c b/Objects/sliceobject.c
index 75048e3..075418e 100644
--- a/Objects/sliceobject.c
+++ b/Objects/sliceobject.c
@@ -19,7 +19,7 @@ this type and there is exactly one in existence.
static PyObject *
ellipsis_repr(PyObject *op)
{
- return PyBytes_FromString("Ellipsis");
+ return PyString_FromString("Ellipsis");
}
static PyTypeObject PyEllipsis_Type = {
@@ -228,14 +228,14 @@ slice_repr(PySliceObject *r)
{
PyObject *s, *comma;
- s = PyBytes_FromString("slice(");
- comma = PyBytes_FromString(", ");
- PyBytes_ConcatAndDel(&s, PyObject_Repr(r->start));
- PyBytes_Concat(&s, comma);
- PyBytes_ConcatAndDel(&s, PyObject_Repr(r->stop));
- PyBytes_Concat(&s, comma);
- PyBytes_ConcatAndDel(&s, PyObject_Repr(r->step));
- PyBytes_ConcatAndDel(&s, PyBytes_FromString(")"));
+ s = PyString_FromString("slice(");
+ comma = PyString_FromString(", ");
+ PyString_ConcatAndDel(&s, PyObject_Repr(r->start));
+ PyString_Concat(&s, comma);
+ PyString_ConcatAndDel(&s, PyObject_Repr(r->stop));
+ PyString_Concat(&s, comma);
+ PyString_ConcatAndDel(&s, PyObject_Repr(r->step));
+ PyString_ConcatAndDel(&s, PyString_FromString(")"));
Py_DECREF(comma);
return s;
}
diff --git a/Objects/stringlib/string_format.h b/Objects/stringlib/string_format.h
index 2e9c7ef..be8e8080 100644
--- a/Objects/stringlib/string_format.h
+++ b/Objects/stringlib/string_format.h
@@ -496,7 +496,7 @@ render_field(PyObject *fieldobj, SubString *format_spec, OutputString *output)
#if PY_VERSION_HEX >= 0x03000000
assert(PyUnicode_Check(result));
#else
- assert(PyBytes_Check(result) || PyUnicode_Check(result));
+ assert(PyString_Check(result) || PyUnicode_Check(result));
/* Convert result to our type. We could be str, and result could
be unicode */
diff --git a/Objects/stringlib/stringdefs.h b/Objects/stringlib/stringdefs.h
index bdc3a29..daaa2e2 100644
--- a/Objects/stringlib/stringdefs.h
+++ b/Objects/stringlib/stringdefs.h
@@ -6,7 +6,7 @@
compiled as unicode. */
#define STRINGLIB_IS_UNICODE 0
-#define STRINGLIB_OBJECT PyBytesObject
+#define STRINGLIB_OBJECT PyStringObject
#define STRINGLIB_CHAR char
#define STRINGLIB_TYPE_NAME "string"
#define STRINGLIB_PARSE_CODE "S"
@@ -16,13 +16,13 @@
#define STRINGLIB_TOUPPER toupper
#define STRINGLIB_TOLOWER tolower
#define STRINGLIB_FILL memset
-#define STRINGLIB_STR PyBytes_AS_STRING
-#define STRINGLIB_LEN PyBytes_GET_SIZE
-#define STRINGLIB_NEW PyBytes_FromStringAndSize
-#define STRINGLIB_RESIZE _PyBytes_Resize
-#define STRINGLIB_CHECK PyBytes_Check
+#define STRINGLIB_STR PyString_AS_STRING
+#define STRINGLIB_LEN PyString_GET_SIZE
+#define STRINGLIB_NEW PyString_FromStringAndSize
+#define STRINGLIB_RESIZE _PyString_Resize
+#define STRINGLIB_CHECK PyString_Check
#define STRINGLIB_CMP memcmp
#define STRINGLIB_TOSTR PyObject_Str
-#define STRINGLIB_GROUPING _PyBytes_InsertThousandsGrouping
+#define STRINGLIB_GROUPING _PyString_InsertThousandsGrouping
#endif /* !STRINGLIB_STRINGDEFS_H */
diff --git a/Objects/structseq.c b/Objects/structseq.c
index c348254..b6126ba 100644
--- a/Objects/structseq.c
+++ b/Objects/structseq.c
@@ -270,7 +270,7 @@ structseq_repr(PyStructSequence *obj)
Py_DECREF(tup);
return NULL;
}
- crepr = PyBytes_AsString(repr);
+ crepr = PyString_AsString(repr);
if (crepr == NULL) {
Py_DECREF(tup);
Py_DECREF(repr);
@@ -306,7 +306,7 @@ structseq_repr(PyStructSequence *obj)
*pbuf++ = ')';
*pbuf = '\0';
- return PyBytes_FromString(buf);
+ return PyString_FromString(buf);
}
static PyObject *
diff --git a/Objects/tupleobject.c b/Objects/tupleobject.c
index 0524aae..e9cb3ef 100644
--- a/Objects/tupleobject.c
+++ b/Objects/tupleobject.c
@@ -218,7 +218,7 @@ tuplerepr(PyTupleObject *v)
n = Py_SIZE(v);
if (n == 0)
- return PyBytes_FromString("()");
+ return PyString_FromString("()");
/* While not mutable, it is still possible to end up with a cycle in a
tuple through an object that stores itself within a tuple (and thus
@@ -226,7 +226,7 @@ tuplerepr(PyTupleObject *v)
possible within a type. */
i = Py_ReprEnter((PyObject *)v);
if (i != 0) {
- return i > 0 ? PyBytes_FromString("(...)") : NULL;
+ return i > 0 ? PyString_FromString("(...)") : NULL;
}
pieces = PyTuple_New(n);
@@ -246,29 +246,29 @@ tuplerepr(PyTupleObject *v)
/* Add "()" decorations to the first and last items. */
assert(n > 0);
- s = PyBytes_FromString("(");
+ s = PyString_FromString("(");
if (s == NULL)
goto Done;
temp = PyTuple_GET_ITEM(pieces, 0);
- PyBytes_ConcatAndDel(&s, temp);
+ PyString_ConcatAndDel(&s, temp);
PyTuple_SET_ITEM(pieces, 0, s);
if (s == NULL)
goto Done;
- s = PyBytes_FromString(n == 1 ? ",)" : ")");
+ s = PyString_FromString(n == 1 ? ",)" : ")");
if (s == NULL)
goto Done;
temp = PyTuple_GET_ITEM(pieces, n-1);
- PyBytes_ConcatAndDel(&temp, s);
+ PyString_ConcatAndDel(&temp, s);
PyTuple_SET_ITEM(pieces, n-1, temp);
if (temp == NULL)
goto Done;
/* Paste them all together with ", " between. */
- s = PyBytes_FromString(", ");
+ s = PyString_FromString(", ");
if (s == NULL)
goto Done;
- result = _PyBytes_Join(s, pieces);
+ result = _PyString_Join(s, pieces);
Py_DECREF(s);
Done:
diff --git a/Objects/typeobject.c b/Objects/typeobject.c
index e88ca05..e0ae55b 100644
--- a/Objects/typeobject.c
+++ b/Objects/typeobject.c
@@ -19,10 +19,10 @@
>> (8*sizeof(unsigned int) - MCACHE_SIZE_EXP))
#define MCACHE_HASH_METHOD(type, name) \
MCACHE_HASH((type)->tp_version_tag, \
- ((PyBytesObject *)(name))->ob_shash)
+ ((PyStringObject *)(name))->ob_shash)
#define MCACHE_CACHEABLE_NAME(name) \
- PyBytes_CheckExact(name) && \
- PyBytes_GET_SIZE(name) <= MCACHE_MAX_ATTR_SIZE
+ PyString_CheckExact(name) && \
+ PyString_GET_SIZE(name) <= MCACHE_MAX_ATTR_SIZE
struct method_cache_entry {
unsigned int version;
@@ -217,7 +217,7 @@ type_name(PyTypeObject *type, void *context)
s = type->tp_name;
else
s++;
- return PyBytes_FromString(s);
+ return PyString_FromString(s);
}
}
@@ -236,14 +236,14 @@ type_set_name(PyTypeObject *type, PyObject *value, void *context)
"can't delete %s.__name__", type->tp_name);
return -1;
}
- if (!PyBytes_Check(value)) {
+ if (!PyString_Check(value)) {
PyErr_Format(PyExc_TypeError,
"can only assign string to %s.__name__, not '%s'",
type->tp_name, Py_TYPE(value)->tp_name);
return -1;
}
- if (strlen(PyBytes_AS_STRING(value))
- != (size_t)PyBytes_GET_SIZE(value)) {
+ if (strlen(PyString_AS_STRING(value))
+ != (size_t)PyString_GET_SIZE(value)) {
PyErr_Format(PyExc_ValueError,
"__name__ must not contain null bytes");
return -1;
@@ -256,7 +256,7 @@ type_set_name(PyTypeObject *type, PyObject *value, void *context)
Py_DECREF(et->ht_name);
et->ht_name = value;
- type->tp_name = PyBytes_AS_STRING(value);
+ type->tp_name = PyString_AS_STRING(value);
return 0;
}
@@ -279,9 +279,9 @@ type_module(PyTypeObject *type, void *context)
else {
s = strrchr(type->tp_name, '.');
if (s != NULL)
- return PyBytes_FromStringAndSize(
+ return PyString_FromStringAndSize(
type->tp_name, (Py_ssize_t)(s - type->tp_name));
- return PyBytes_FromString("__builtin__");
+ return PyString_FromString("__builtin__");
}
}
@@ -555,7 +555,7 @@ type_get_doc(PyTypeObject *type, void *context)
{
PyObject *result;
if (!(type->tp_flags & Py_TPFLAGS_HEAPTYPE) && type->tp_doc != NULL)
- return PyBytes_FromString(type->tp_doc);
+ return PyString_FromString(type->tp_doc);
result = PyDict_GetItemString(type->tp_dict, "__doc__");
if (result == NULL) {
result = Py_None;
@@ -644,7 +644,7 @@ type_repr(PyTypeObject *type)
mod = type_module(type, NULL);
if (mod == NULL)
PyErr_Clear();
- else if (!PyBytes_Check(mod)) {
+ else if (!PyString_Check(mod)) {
Py_DECREF(mod);
mod = NULL;
}
@@ -657,14 +657,14 @@ type_repr(PyTypeObject *type)
else
kind = "type";
- if (mod != NULL && strcmp(PyBytes_AS_STRING(mod), "__builtin__")) {
- rtn = PyBytes_FromFormat("<%s '%s.%s'>",
+ if (mod != NULL && strcmp(PyString_AS_STRING(mod), "__builtin__")) {
+ rtn = PyString_FromFormat("<%s '%s.%s'>",
kind,
- PyBytes_AS_STRING(mod),
- PyBytes_AS_STRING(name));
+ PyString_AS_STRING(mod),
+ PyString_AS_STRING(name));
}
else
- rtn = PyBytes_FromFormat("<%s '%s'>", kind, type->tp_name);
+ rtn = PyString_FromFormat("<%s '%s'>", kind, type->tp_name);
Py_XDECREF(mod);
Py_DECREF(name);
@@ -1136,7 +1136,7 @@ lookup_maybe(PyObject *self, char *attrstr, PyObject **attrobj)
PyObject *res;
if (*attrobj == NULL) {
- *attrobj = PyBytes_InternFromString(attrstr);
+ *attrobj = PyString_InternFromString(attrstr);
if (*attrobj == NULL)
return NULL;
}
@@ -1328,7 +1328,7 @@ class_name(PyObject *cls)
}
if (name == NULL)
return NULL;
- if (!PyBytes_Check(name)) {
+ if (!PyString_Check(name)) {
Py_DECREF(name);
return NULL;
}
@@ -1350,7 +1350,7 @@ check_duplicates(PyObject *list)
o = class_name(o);
PyErr_Format(PyExc_TypeError,
"duplicate base class %s",
- o ? PyBytes_AS_STRING(o) : "?");
+ o ? PyString_AS_STRING(o) : "?");
Py_XDECREF(o);
return -1;
}
@@ -1396,7 +1396,7 @@ consistent method resolution\norder (MRO) for bases");
while (PyDict_Next(set, &i, &k, &v) && (size_t)off < sizeof(buf)) {
PyObject *name = class_name(k);
off += PyOS_snprintf(buf + off, sizeof(buf) - off, " %s",
- name ? PyBytes_AS_STRING(name) : "?");
+ name ? PyString_AS_STRING(name) : "?");
Py_XDECREF(name);
if (--n && (size_t)(off+1) < sizeof(buf)) {
buf[off++] = ',';
@@ -1749,7 +1749,7 @@ get_dict_descriptor(PyTypeObject *type)
PyObject *descr;
if (dict_str == NULL) {
- dict_str = PyBytes_InternFromString("__dict__");
+ dict_str = PyString_InternFromString("__dict__");
if (dict_str == NULL)
return NULL;
}
@@ -1898,14 +1898,14 @@ valid_identifier(PyObject *s)
unsigned char *p;
Py_ssize_t i, n;
- if (!PyBytes_Check(s)) {
+ if (!PyString_Check(s)) {
PyErr_Format(PyExc_TypeError,
"__slots__ items must be strings, not '%.200s'",
Py_TYPE(s)->tp_name);
return 0;
}
- p = (unsigned char *) PyBytes_AS_STRING(s);
- n = PyBytes_GET_SIZE(s);
+ p = (unsigned char *) PyString_AS_STRING(s);
+ n = PyString_GET_SIZE(s);
/* We must reject an empty name. As a hack, we bump the
length to 1 so that the loop will balk on the trailing \0. */
if (n == 0)
@@ -2107,7 +2107,7 @@ type_new(PyTypeObject *metatype, PyObject *args, PyObject *kwds)
/* Have slots */
/* Make it into a tuple */
- if (PyBytes_Check(slots) || PyUnicode_Check(slots))
+ if (PyString_Check(slots) || PyUnicode_Check(slots))
slots = PyTuple_Pack(1, slots);
else
slots = PySequence_Tuple(slots);
@@ -2145,8 +2145,8 @@ type_new(PyTypeObject *metatype, PyObject *args, PyObject *kwds)
char *s;
if (!valid_identifier(tmp))
goto bad_slots;
- assert(PyBytes_Check(tmp));
- s = PyBytes_AS_STRING(tmp);
+ assert(PyString_Check(tmp));
+ s = PyString_AS_STRING(tmp);
if (strcmp(s, "__dict__") == 0) {
if (!may_add_dict || add_dict) {
PyErr_SetString(PyExc_TypeError,
@@ -2178,7 +2178,7 @@ type_new(PyTypeObject *metatype, PyObject *args, PyObject *kwds)
for (i = j = 0; i < nslots; i++) {
char *s;
tmp = PyTuple_GET_ITEM(slots, i);
- s = PyBytes_AS_STRING(tmp);
+ s = PyString_AS_STRING(tmp);
if ((add_dict && strcmp(s, "__dict__") == 0) ||
(add_weak && strcmp(s, "__weakref__") == 0))
continue;
@@ -2271,7 +2271,7 @@ type_new(PyTypeObject *metatype, PyObject *args, PyObject *kwds)
type->tp_as_sequence = &et->as_sequence;
type->tp_as_mapping = &et->as_mapping;
type->tp_as_buffer = &et->as_buffer;
- type->tp_name = PyBytes_AS_STRING(name);
+ type->tp_name = PyString_AS_STRING(name);
/* Set tp_base and tp_bases */
type->tp_bases = bases;
@@ -2304,14 +2304,14 @@ type_new(PyTypeObject *metatype, PyObject *args, PyObject *kwds)
*/
{
PyObject *doc = PyDict_GetItemString(dict, "__doc__");
- if (doc != NULL && PyBytes_Check(doc)) {
- const size_t n = (size_t)PyBytes_GET_SIZE(doc);
+ if (doc != NULL && PyString_Check(doc)) {
+ const size_t n = (size_t)PyString_GET_SIZE(doc);
char *tp_doc = (char *)PyObject_MALLOC(n+1);
if (tp_doc == NULL) {
Py_DECREF(type);
return NULL;
}
- memcpy(tp_doc, PyBytes_AS_STRING(doc), n+1);
+ memcpy(tp_doc, PyString_AS_STRING(doc), n+1);
type->tp_doc = tp_doc;
}
}
@@ -2334,7 +2334,7 @@ type_new(PyTypeObject *metatype, PyObject *args, PyObject *kwds)
slotoffset = base->tp_basicsize;
if (slots != NULL) {
for (i = 0; i < nslots; i++, mp++) {
- mp->name = PyBytes_AS_STRING(
+ mp->name = PyString_AS_STRING(
PyTuple_GET_ITEM(slots, i));
mp->type = T_OBJECT_EX;
mp->offset = slotoffset;
@@ -2535,7 +2535,7 @@ type_getattro(PyTypeObject *type, PyObject *name)
/* Give up */
PyErr_Format(PyExc_AttributeError,
"type object '%.50s' has no attribute '%.400s'",
- type->tp_name, PyBytes_AS_STRING(name));
+ type->tp_name, PyString_AS_STRING(name));
return NULL;
}
@@ -2854,7 +2854,7 @@ object_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
if (sorted_methods == NULL)
goto error;
if (comma == NULL) {
- comma = PyBytes_InternFromString(", ");
+ comma = PyString_InternFromString(", ");
if (comma == NULL)
goto error;
}
@@ -2862,7 +2862,7 @@ object_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
"O", sorted_methods);
if (joined == NULL)
goto error;
- joined_str = PyBytes_AsString(joined);
+ joined_str = PyString_AsString(joined);
if (joined_str == NULL)
goto error;
@@ -2896,20 +2896,20 @@ object_repr(PyObject *self)
mod = type_module(type, NULL);
if (mod == NULL)
PyErr_Clear();
- else if (!PyBytes_Check(mod)) {
+ else if (!PyString_Check(mod)) {
Py_DECREF(mod);
mod = NULL;
}
name = type_name(type, NULL);
if (name == NULL)
return NULL;
- if (mod != NULL && strcmp(PyBytes_AS_STRING(mod), "__builtin__"))
- rtn = PyBytes_FromFormat("<%s.%s object at %p>",
- PyBytes_AS_STRING(mod),
- PyBytes_AS_STRING(name),
+ if (mod != NULL && strcmp(PyString_AS_STRING(mod), "__builtin__"))
+ rtn = PyString_FromFormat("<%s.%s object at %p>",
+ PyString_AS_STRING(mod),
+ PyString_AS_STRING(name),
self);
else
- rtn = PyBytes_FromFormat("<%s object at %p>",
+ rtn = PyString_FromFormat("<%s object at %p>",
type->tp_name, self);
Py_XDECREF(mod);
Py_DECREF(name);
@@ -3069,7 +3069,7 @@ import_copyreg(void)
static PyObject *copyreg_str;
if (!copyreg_str) {
- copyreg_str = PyBytes_InternFromString("copy_reg");
+ copyreg_str = PyString_InternFromString("copy_reg");
if (copyreg_str == NULL)
return NULL;
}
@@ -3375,7 +3375,7 @@ object_format(PyObject *self, PyObject *args)
return NULL;
if (PyUnicode_Check(format_spec)) {
self_as_str = PyObject_Unicode(self);
- } else if (PyBytes_Check(format_spec)) {
+ } else if (PyString_Check(format_spec)) {
self_as_str = PyObject_Str(self);
} else {
PyErr_SetString(PyExc_TypeError, "argument to __format__ must be unicode or str");
@@ -3634,7 +3634,7 @@ inherit_special(PyTypeObject *type, PyTypeObject *base)
type->tp_flags |= Py_TPFLAGS_INT_SUBCLASS;
else if (PyType_IsSubtype(base, &PyLong_Type))
type->tp_flags |= Py_TPFLAGS_LONG_SUBCLASS;
- else if (PyType_IsSubtype(base, &PyBytes_Type))
+ else if (PyType_IsSubtype(base, &PyString_Type))
type->tp_flags |= Py_TPFLAGS_STRING_SUBCLASS;
#ifdef Py_USING_UNICODE
else if (PyType_IsSubtype(base, &PyUnicode_Type))
@@ -3973,7 +3973,7 @@ PyType_Ready(PyTypeObject *type)
*/
if (PyDict_GetItemString(type->tp_dict, "__doc__") == NULL) {
if (type->tp_doc != NULL) {
- PyObject *doc = PyBytes_FromString(type->tp_doc);
+ PyObject *doc = PyString_FromString(type->tp_doc);
if (doc == NULL)
goto error;
PyDict_SetItemString(type->tp_dict, "__doc__", doc);
@@ -4861,7 +4861,7 @@ slot_sq_item(PyObject *self, Py_ssize_t i)
descrgetfunc f;
if (getitem_str == NULL) {
- getitem_str = PyBytes_InternFromString("__getitem__");
+ getitem_str = PyString_InternFromString("__getitem__");
if (getitem_str == NULL)
return NULL;
}
@@ -5229,7 +5229,7 @@ slot_tp_repr(PyObject *self)
return res;
}
PyErr_Clear();
- return PyBytes_FromFormat("<%s object at %p>",
+ return PyString_FromFormat("<%s object at %p>",
Py_TYPE(self)->tp_name, self);
}
@@ -5337,13 +5337,13 @@ slot_tp_getattr_hook(PyObject *self, PyObject *name)
static PyObject *getattr_str = NULL;
if (getattr_str == NULL) {
- getattr_str = PyBytes_InternFromString("__getattr__");
+ getattr_str = PyString_InternFromString("__getattr__");
if (getattr_str == NULL)
return NULL;
}
if (getattribute_str == NULL) {
getattribute_str =
- PyBytes_InternFromString("__getattribute__");
+ PyString_InternFromString("__getattribute__");
if (getattribute_str == NULL)
return NULL;
}
@@ -5484,7 +5484,7 @@ slot_tp_descr_get(PyObject *self, PyObject *obj, PyObject *type)
static PyObject *get_str = NULL;
if (get_str == NULL) {
- get_str = PyBytes_InternFromString("__get__");
+ get_str = PyString_InternFromString("__get__");
if (get_str == NULL)
return NULL;
}
@@ -5554,7 +5554,7 @@ slot_tp_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
Py_ssize_t i, n;
if (new_str == NULL) {
- new_str = PyBytes_InternFromString("__new__");
+ new_str = PyString_InternFromString("__new__");
if (new_str == NULL)
return NULL;
}
@@ -6084,7 +6084,7 @@ init_slotdefs(void)
if (initialized)
return;
for (p = slotdefs; p->name; p++) {
- p->name_strobj = PyBytes_InternFromString(p->name);
+ p->name_strobj = PyString_InternFromString(p->name);
if (!p->name_strobj)
Py_FatalError("Out of memory interning slotdef names");
}
@@ -6299,12 +6299,12 @@ super_repr(PyObject *self)
superobject *su = (superobject *)self;
if (su->obj_type)
- return PyBytes_FromFormat(
+ return PyString_FromFormat(
"<super: <class '%s'>, <%s object>>",
su->type ? su->type->tp_name : "NULL",
su->obj_type->tp_name);
else
- return PyBytes_FromFormat(
+ return PyString_FromFormat(
"<super: <class '%s'>, NULL>",
su->type ? su->type->tp_name : "NULL");
}
@@ -6318,9 +6318,9 @@ super_getattro(PyObject *self, PyObject *name)
if (!skip) {
/* We want __class__ to return the class of the super object
(i.e. super, or a subclass), not the class of su->obj. */
- skip = (PyBytes_Check(name) &&
- PyBytes_GET_SIZE(name) == 9 &&
- strcmp(PyBytes_AS_STRING(name), "__class__") == 0);
+ skip = (PyString_Check(name) &&
+ PyString_GET_SIZE(name) == 9 &&
+ strcmp(PyString_AS_STRING(name), "__class__") == 0);
}
if (!skip) {
@@ -6412,7 +6412,7 @@ supercheck(PyTypeObject *type, PyObject *obj)
PyObject *class_attr;
if (class_str == NULL) {
- class_str = PyBytes_FromString("__class__");
+ class_str = PyString_FromString("__class__");
if (class_str == NULL)
return NULL;
}
diff --git a/Objects/unicodeobject.c b/Objects/unicodeobject.c
index 3ffe99c..873f1c4 100644
--- a/Objects/unicodeobject.c
+++ b/Objects/unicodeobject.c
@@ -1078,9 +1078,9 @@ PyObject *PyUnicode_FromEncodedObject(register PyObject *obj,
#endif
/* Coerce object */
- if (PyBytes_Check(obj)) {
- s = PyBytes_AS_STRING(obj);
- len = PyBytes_GET_SIZE(obj);
+ if (PyString_Check(obj)) {
+ s = PyString_AS_STRING(obj);
+ len = PyString_GET_SIZE(obj);
}
else if (PyByteArray_Check(obj)) {
/* Python 2.x specific */
@@ -1252,7 +1252,7 @@ PyObject *PyUnicode_AsEncodedString(PyObject *unicode,
v = PyCodec_Encode(unicode, encoding, errors);
if (v == NULL)
goto onError;
- if (!PyBytes_Check(v)) {
+ if (!PyString_Check(v)) {
PyErr_Format(PyExc_TypeError,
"encoder did not return a string object (type=%.400s)",
Py_TYPE(v)->tp_name);
@@ -1652,13 +1652,13 @@ PyObject *PyUnicode_EncodeUTF7(const Py_UNICODE *s,
char * start;
if (size == 0)
- return PyBytes_FromStringAndSize(NULL, 0);
+ return PyString_FromStringAndSize(NULL, 0);
- v = PyBytes_FromStringAndSize(NULL, cbAllocated);
+ v = PyString_FromStringAndSize(NULL, cbAllocated);
if (v == NULL)
return NULL;
- start = out = PyBytes_AS_STRING(v);
+ start = out = PyString_AS_STRING(v);
for (;i < size; ++i) {
Py_UNICODE ch = s[i];
@@ -1724,7 +1724,7 @@ PyObject *PyUnicode_EncodeUTF7(const Py_UNICODE *s,
*out++ = '-';
}
- _PyBytes_Resize(&v, out - start);
+ _PyString_Resize(&v, out - start);
return v;
}
@@ -1989,10 +1989,10 @@ PyUnicode_EncodeUTF8(const Py_UNICODE *s,
nallocated = size * 4;
if (nallocated / 4 != size) /* overflow! */
return PyErr_NoMemory();
- v = PyBytes_FromStringAndSize(NULL, nallocated);
+ v = PyString_FromStringAndSize(NULL, nallocated);
if (v == NULL)
return NULL;
- p = PyBytes_AS_STRING(v);
+ p = PyString_AS_STRING(v);
}
for (i = 0; i < size;) {
@@ -2040,13 +2040,13 @@ encodeUCS4:
/* This was stack allocated. */
nneeded = p - stackbuf;
assert(nneeded <= nallocated);
- v = PyBytes_FromStringAndSize(stackbuf, nneeded);
+ v = PyString_FromStringAndSize(stackbuf, nneeded);
}
else {
/* Cut back to size actually needed. */
- nneeded = p - PyBytes_AS_STRING(v);
+ nneeded = p - PyString_AS_STRING(v);
assert(nneeded <= nallocated);
- _PyBytes_Resize(&v, nneeded);
+ _PyString_Resize(&v, nneeded);
}
return v;
@@ -2274,12 +2274,12 @@ PyUnicode_EncodeUTF32(const Py_UNICODE *s,
0xDC00 <= s[i+1] && s[i+1] <= 0xDFFF)
pairs++;
#endif
- v = PyBytes_FromStringAndSize(NULL,
+ v = PyString_FromStringAndSize(NULL,
4 * (size - pairs + (byteorder == 0)));
if (v == NULL)
return NULL;
- p = (unsigned char *)PyBytes_AS_STRING(v);
+ p = (unsigned char *)PyString_AS_STRING(v);
if (byteorder == 0)
STORECHAR(0xFEFF);
if (size == 0)
@@ -2539,12 +2539,12 @@ PyUnicode_EncodeUTF16(const Py_UNICODE *s,
if (s[i] >= 0x10000)
pairs++;
#endif
- v = PyBytes_FromStringAndSize(NULL,
+ v = PyString_FromStringAndSize(NULL,
2 * (size + pairs + (byteorder == 0)));
if (v == NULL)
return NULL;
- p = (unsigned char *)PyBytes_AS_STRING(v);
+ p = (unsigned char *)PyString_AS_STRING(v);
if (byteorder == 0)
STORECHAR(0xFEFF);
if (size == 0)
@@ -2887,7 +2887,7 @@ PyObject *unicodeescape_string(const Py_UNICODE *s,
escape.
*/
- repr = PyBytes_FromStringAndSize(NULL,
+ repr = PyString_FromStringAndSize(NULL,
2
#ifdef Py_UNICODE_WIDE
+ 10*size
@@ -2898,7 +2898,7 @@ PyObject *unicodeescape_string(const Py_UNICODE *s,
if (repr == NULL)
return NULL;
- p = PyBytes_AS_STRING(repr);
+ p = PyString_AS_STRING(repr);
if (quotes) {
*p++ = 'u';
@@ -2910,7 +2910,7 @@ PyObject *unicodeescape_string(const Py_UNICODE *s,
/* Escape quotes and backslashes */
if ((quotes &&
- ch == (Py_UNICODE) PyBytes_AS_STRING(repr)[1]) || ch == '\\') {
+ ch == (Py_UNICODE) PyString_AS_STRING(repr)[1]) || ch == '\\') {
*p++ = '\\';
*p++ = (char) ch;
continue;
@@ -2996,10 +2996,10 @@ PyObject *unicodeescape_string(const Py_UNICODE *s,
*p++ = (char) ch;
}
if (quotes)
- *p++ = PyBytes_AS_STRING(repr)[1];
+ *p++ = PyString_AS_STRING(repr)[1];
*p = '\0';
- _PyBytes_Resize(&repr, p - PyBytes_AS_STRING(repr));
+ _PyString_Resize(&repr, p - PyString_AS_STRING(repr));
return repr;
}
@@ -3148,16 +3148,16 @@ PyObject *PyUnicode_EncodeRawUnicodeEscape(const Py_UNICODE *s,
static const char *hexdigit = "0123456789abcdef";
#ifdef Py_UNICODE_WIDE
- repr = PyBytes_FromStringAndSize(NULL, 10 * size);
+ repr = PyString_FromStringAndSize(NULL, 10 * size);
#else
- repr = PyBytes_FromStringAndSize(NULL, 6 * size);
+ repr = PyString_FromStringAndSize(NULL, 6 * size);
#endif
if (repr == NULL)
return NULL;
if (size == 0)
return repr;
- p = q = PyBytes_AS_STRING(repr);
+ p = q = PyString_AS_STRING(repr);
while (size-- > 0) {
Py_UNICODE ch = *s++;
#ifdef Py_UNICODE_WIDE
@@ -3216,7 +3216,7 @@ PyObject *PyUnicode_EncodeRawUnicodeEscape(const Py_UNICODE *s,
*p++ = (char) ch;
}
*p = '\0';
- _PyBytes_Resize(&repr, p - q);
+ _PyString_Resize(&repr, p - q);
return repr;
}
@@ -3456,12 +3456,12 @@ static PyObject *unicode_encode_ucs1(const Py_UNICODE *p,
/* allocate enough for a simple encoding without
replacements, if we need more, we'll resize */
- res = PyBytes_FromStringAndSize(NULL, size);
+ res = PyString_FromStringAndSize(NULL, size);
if (res == NULL)
goto onError;
if (size == 0)
return res;
- str = PyBytes_AS_STRING(res);
+ str = PyString_AS_STRING(res);
ressize = size;
while (p<endp) {
@@ -3511,7 +3511,7 @@ static PyObject *unicode_encode_ucs1(const Py_UNICODE *p,
p = collend;
break;
case 4: /* xmlcharrefreplace */
- respos = str-PyBytes_AS_STRING(res);
+ respos = str-PyString_AS_STRING(res);
/* determine replacement size (temporarily (mis)uses p) */
for (p = collstart, repsize = 0; p < collend; ++p) {
if (*p<10)
@@ -3538,9 +3538,9 @@ static PyObject *unicode_encode_ucs1(const Py_UNICODE *p,
if (requiredsize > ressize) {
if (requiredsize<2*ressize)
requiredsize = 2*ressize;
- if (_PyBytes_Resize(&res, requiredsize))
+ if (_PyString_Resize(&res, requiredsize))
goto onError;
- str = PyBytes_AS_STRING(res) + respos;
+ str = PyString_AS_STRING(res) + respos;
ressize = requiredsize;
}
/* generate replacement (temporarily (mis)uses p) */
@@ -3558,17 +3558,17 @@ static PyObject *unicode_encode_ucs1(const Py_UNICODE *p,
/* need more space? (at least enough for what we
have+the replacement+the rest of the string, so
we won't have to check space for encodable characters) */
- respos = str-PyBytes_AS_STRING(res);
+ respos = str-PyString_AS_STRING(res);
repsize = PyUnicode_GET_SIZE(repunicode);
requiredsize = respos+repsize+(endp-collend);
if (requiredsize > ressize) {
if (requiredsize<2*ressize)
requiredsize = 2*ressize;
- if (_PyBytes_Resize(&res, requiredsize)) {
+ if (_PyString_Resize(&res, requiredsize)) {
Py_DECREF(repunicode);
goto onError;
}
- str = PyBytes_AS_STRING(res) + respos;
+ str = PyString_AS_STRING(res) + respos;
ressize = requiredsize;
}
/* check if there is anything unencodable in the replacement
@@ -3589,10 +3589,10 @@ static PyObject *unicode_encode_ucs1(const Py_UNICODE *p,
}
}
/* Resize if we allocated to much */
- respos = str-PyBytes_AS_STRING(res);
+ respos = str-PyString_AS_STRING(res);
if (respos<ressize)
/* If this falls res will be NULL */
- _PyBytes_Resize(&res, respos);
+ _PyString_Resize(&res, respos);
Py_XDECREF(errorHandler);
Py_XDECREF(exc);
return res;
@@ -3669,7 +3669,7 @@ PyObject *PyUnicode_DecodeASCII(const char *s,
goto onError;
}
}
- if (p - PyUnicode_AS_UNICODE(v) < PyBytes_GET_SIZE(v))
+ if (p - PyUnicode_AS_UNICODE(v) < PyString_GET_SIZE(v))
if (_PyUnicode_Resize(&v, p - PyUnicode_AS_UNICODE(v)) < 0)
goto onError;
Py_XDECREF(errorHandler);
@@ -3847,20 +3847,20 @@ static int encode_mbcs(PyObject **repr,
if (*repr == NULL) {
/* Create string object */
- *repr = PyBytes_FromStringAndSize(NULL, mbcssize);
+ *repr = PyString_FromStringAndSize(NULL, mbcssize);
if (*repr == NULL)
return -1;
}
else {
/* Extend string object */
- n = PyBytes_Size(*repr);
- if (_PyBytes_Resize(repr, n + mbcssize) < 0)
+ n = PyString_Size(*repr);
+ if (_PyString_Resize(repr, n + mbcssize) < 0)
return -1;
}
/* Do the conversion */
if (size > 0) {
- char *s = PyBytes_AS_STRING(*repr) + n;
+ char *s = PyString_AS_STRING(*repr) + n;
if (0 == WideCharToMultiByte(CP_ACP, 0, p, size, s, mbcssize, NULL, NULL)) {
PyErr_SetFromWindowsErrWithFilename(0, NULL);
return -1;
@@ -4327,7 +4327,7 @@ static PyObject *charmapencode_lookup(Py_UNICODE c, PyObject *mapping)
}
return x;
}
- else if (PyBytes_Check(x))
+ else if (PyString_Check(x))
return x;
else {
/* wrong return value */
@@ -4341,11 +4341,11 @@ static PyObject *charmapencode_lookup(Py_UNICODE c, PyObject *mapping)
static int
charmapencode_resize(PyObject **outobj, Py_ssize_t *outpos, Py_ssize_t requiredsize)
{
- Py_ssize_t outsize = PyBytes_GET_SIZE(*outobj);
+ Py_ssize_t outsize = PyString_GET_SIZE(*outobj);
/* exponentially overallocate to minimize reallocations */
if (requiredsize < 2*outsize)
requiredsize = 2*outsize;
- if (_PyBytes_Resize(outobj, requiredsize)) {
+ if (_PyString_Resize(outobj, requiredsize)) {
return 0;
}
return 1;
@@ -4366,7 +4366,7 @@ charmapencode_result charmapencode_output(Py_UNICODE c, PyObject *mapping,
{
PyObject *rep;
char *outstart;
- Py_ssize_t outsize = PyBytes_GET_SIZE(*outobj);
+ Py_ssize_t outsize = PyString_GET_SIZE(*outobj);
if (Py_TYPE(mapping) == &EncodingMapType) {
int res = encoding_map_lookup(c, mapping);
@@ -4376,7 +4376,7 @@ charmapencode_result charmapencode_output(Py_UNICODE c, PyObject *mapping,
if (outsize<requiredsize)
if (!charmapencode_resize(outobj, outpos, requiredsize))
return enc_EXCEPTION;
- outstart = PyBytes_AS_STRING(*outobj);
+ outstart = PyString_AS_STRING(*outobj);
outstart[(*outpos)++] = (char)res;
return enc_SUCCESS;
}
@@ -4395,19 +4395,19 @@ charmapencode_result charmapencode_output(Py_UNICODE c, PyObject *mapping,
Py_DECREF(rep);
return enc_EXCEPTION;
}
- outstart = PyBytes_AS_STRING(*outobj);
+ outstart = PyString_AS_STRING(*outobj);
outstart[(*outpos)++] = (char)PyInt_AS_LONG(rep);
}
else {
- const char *repchars = PyBytes_AS_STRING(rep);
- Py_ssize_t repsize = PyBytes_GET_SIZE(rep);
+ const char *repchars = PyString_AS_STRING(rep);
+ Py_ssize_t repsize = PyString_GET_SIZE(rep);
Py_ssize_t requiredsize = *outpos+repsize;
if (outsize<requiredsize)
if (!charmapencode_resize(outobj, outpos, requiredsize)) {
Py_DECREF(rep);
return enc_EXCEPTION;
}
- outstart = PyBytes_AS_STRING(*outobj);
+ outstart = PyString_AS_STRING(*outobj);
memcpy(outstart + *outpos, repchars, repsize);
*outpos += repsize;
}
@@ -4558,7 +4558,7 @@ PyObject *PyUnicode_EncodeCharmap(const Py_UNICODE *p,
/* allocate enough for a simple encoding without
replacements, if we need more, we'll resize */
- res = PyBytes_FromStringAndSize(NULL, size);
+ res = PyString_FromStringAndSize(NULL, size);
if (res == NULL)
goto onError;
if (size == 0)
@@ -4583,8 +4583,8 @@ PyObject *PyUnicode_EncodeCharmap(const Py_UNICODE *p,
}
/* Resize if we allocated to much */
- if (respos<PyBytes_GET_SIZE(res)) {
- if (_PyBytes_Resize(&res, respos))
+ if (respos<PyString_GET_SIZE(res)) {
+ if (_PyString_Resize(&res, respos))
goto onError;
}
Py_XDECREF(exc);
@@ -5482,7 +5482,7 @@ PyUnicode_Join(PyObject *separator, PyObject *seq)
item = PySequence_Fast_GET_ITEM(fseq, i);
/* Convert item to Unicode. */
- if (! PyUnicode_Check(item) && ! PyBytes_Check(item)) {
+ if (! PyUnicode_Check(item) && ! PyString_Check(item)) {
PyErr_Format(PyExc_TypeError,
"sequence item %zd: expected string or Unicode,"
" %.80s found",
@@ -6486,7 +6486,7 @@ unicode_encode(PyUnicodeObject *self, PyObject *args)
v = PyUnicode_AsEncodedObject((PyObject *)self, encoding, errors);
if (v == NULL)
goto onError;
- if (!PyBytes_Check(v) && !PyUnicode_Check(v)) {
+ if (!PyString_Check(v) && !PyUnicode_Check(v)) {
PyErr_Format(PyExc_TypeError,
"encoder did not return a string/unicode object "
"(type=%.400s)",
@@ -6522,7 +6522,7 @@ unicode_decode(PyUnicodeObject *self, PyObject *args)
v = PyUnicode_AsDecodedObject((PyObject *)self, encoding, errors);
if (v == NULL)
goto onError;
- if (!PyBytes_Check(v) && !PyUnicode_Check(v)) {
+ if (!PyString_Check(v) && !PyUnicode_Check(v)) {
PyErr_Format(PyExc_TypeError,
"decoder did not return a string/unicode object "
"(type=%.400s)",
@@ -7152,7 +7152,7 @@ do_argstrip(PyUnicodeObject *self, int striptype, PyObject *args)
if (sep != NULL && sep != Py_None) {
if (PyUnicode_Check(sep))
return _PyUnicode_XStrip(self, striptype, sep);
- else if (PyBytes_Check(sep)) {
+ else if (PyString_Check(sep)) {
PyObject *res;
sep = PyUnicode_FromObject(sep);
if (sep==NULL)
@@ -8098,8 +8098,8 @@ unicode_buffer_getcharbuf(PyUnicodeObject *self,
str = _PyUnicode_AsDefaultEncodedString((PyObject *)self, NULL);
if (str == NULL)
return -1;
- *ptr = (void *) PyBytes_AS_STRING(str);
- return PyBytes_GET_SIZE(str);
+ *ptr = (void *) PyString_AS_STRING(str);
+ return PyString_GET_SIZE(str);
}
/* Helpers for PyUnicode_Format() */
@@ -8218,7 +8218,7 @@ formatlong(PyObject *val, int flags, int prec, int type)
PyObject *str; /* temporary string object. */
PyUnicodeObject *result;
- str = _PyBytes_FormatLong(val, flags, prec, type, &buf, &len);
+ str = _PyString_FormatLong(val, flags, prec, type, &buf, &len);
if (!str)
return NULL;
result = _PyUnicode_New(len);
@@ -8320,10 +8320,10 @@ formatchar(Py_UNICODE *buf,
buf[0] = PyUnicode_AS_UNICODE(v)[0];
}
- else if (PyBytes_Check(v)) {
- if (PyBytes_GET_SIZE(v) != 1)
+ else if (PyString_Check(v)) {
+ if (PyString_GET_SIZE(v) != 1)
goto onError;
- buf[0] = (Py_UNICODE)PyBytes_AS_STRING(v)[0];
+ buf[0] = (Py_UNICODE)PyString_AS_STRING(v)[0];
}
else {
@@ -8606,10 +8606,10 @@ PyObject *PyUnicode_Format(PyObject *format,
goto onError;
if (PyUnicode_Check(temp))
/* nothing to do */;
- else if (PyBytes_Check(temp)) {
+ else if (PyString_Check(temp)) {
/* convert to string to Unicode */
- unicode = PyUnicode_Decode(PyBytes_AS_STRING(temp),
- PyBytes_GET_SIZE(temp),
+ unicode = PyUnicode_Decode(PyString_AS_STRING(temp),
+ PyString_GET_SIZE(temp),
NULL,
"strict");
Py_DECREF(temp);
diff --git a/Objects/weakrefobject.c b/Objects/weakrefobject.c
index 2899bc70..1aee5a5 100644
--- a/Objects/weakrefobject.c
+++ b/Objects/weakrefobject.c
@@ -166,8 +166,8 @@ weakref_repr(PyWeakReference *self)
"__name__");
if (nameobj == NULL)
PyErr_Clear();
- else if (PyBytes_Check(nameobj))
- name = PyBytes_AS_STRING(nameobj);
+ else if (PyString_Check(nameobj))
+ name = PyString_AS_STRING(nameobj);
PyOS_snprintf(buffer, sizeof(buffer),
name ? "<weakref at %p; to '%.50s' at %p (%s)>"
: "<weakref at %p; to '%.50s' at %p>",
@@ -177,7 +177,7 @@ weakref_repr(PyWeakReference *self)
name);
Py_XDECREF(nameobj);
}
- return PyBytes_FromString(buffer);
+ return PyString_FromString(buffer);
}
/* Weak references only support equality, not ordering. Two weak references
@@ -448,7 +448,7 @@ proxy_repr(PyWeakReference *proxy)
"<weakproxy at %p to %.100s at %p>", proxy,
Py_TYPE(PyWeakref_GET_OBJECT(proxy))->tp_name,
PyWeakref_GET_OBJECT(proxy));
- return PyBytes_FromString(buf);
+ return PyString_FromString(buf);
}