Skip to content

Commit dd96db6

Browse files
committed
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.
1 parent e98839a commit dd96db6

File tree

173 files changed

+2275
-2280
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

173 files changed

+2275
-2280
lines changed

Doc/includes/noddy2.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,14 @@ Noddy_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
2323

2424
self = (Noddy *)type->tp_alloc(type, 0);
2525
if (self != NULL) {
26-
self->first = PyBytes_FromString("");
26+
self->first = PyString_FromString("");
2727
if (self->first == NULL)
2828
{
2929
Py_DECREF(self);
3030
return NULL;
3131
}
3232

33-
self->last = PyBytes_FromString("");
33+
self->last = PyString_FromString("");
3434
if (self->last == NULL)
3535
{
3636
Py_DECREF(self);
@@ -90,7 +90,7 @@ Noddy_name(Noddy* self)
9090
PyObject *args, *result;
9191

9292
if (format == NULL) {
93-
format = PyBytes_FromString("%s %s");
93+
format = PyString_FromString("%s %s");
9494
if (format == NULL)
9595
return NULL;
9696
}
@@ -109,7 +109,7 @@ Noddy_name(Noddy* self)
109109
if (args == NULL)
110110
return NULL;
111111

112-
result = PyBytes_Format(format, args);
112+
result = PyString_Format(format, args);
113113
Py_DECREF(args);
114114

115115
return result;

Doc/includes/noddy3.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,14 @@ Noddy_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
2323

2424
self = (Noddy *)type->tp_alloc(type, 0);
2525
if (self != NULL) {
26-
self->first = PyBytes_FromString("");
26+
self->first = PyString_FromString("");
2727
if (self->first == NULL)
2828
{
2929
Py_DECREF(self);
3030
return NULL;
3131
}
3232

33-
self->last = PyBytes_FromString("");
33+
self->last = PyString_FromString("");
3434
if (self->last == NULL)
3535
{
3636
Py_DECREF(self);
@@ -93,7 +93,7 @@ Noddy_setfirst(Noddy *self, PyObject *value, void *closure)
9393
return -1;
9494
}
9595

96-
if (! PyBytes_Check(value)) {
96+
if (! PyString_Check(value)) {
9797
PyErr_SetString(PyExc_TypeError,
9898
"The first attribute value must be a string");
9999
return -1;
@@ -121,7 +121,7 @@ Noddy_setlast(Noddy *self, PyObject *value, void *closure)
121121
return -1;
122122
}
123123

124-
if (! PyBytes_Check(value)) {
124+
if (! PyString_Check(value)) {
125125
PyErr_SetString(PyExc_TypeError,
126126
"The last attribute value must be a string");
127127
return -1;
@@ -153,7 +153,7 @@ Noddy_name(Noddy* self)
153153
PyObject *args, *result;
154154

155155
if (format == NULL) {
156-
format = PyBytes_FromString("%s %s");
156+
format = PyString_FromString("%s %s");
157157
if (format == NULL)
158158
return NULL;
159159
}
@@ -162,7 +162,7 @@ Noddy_name(Noddy* self)
162162
if (args == NULL)
163163
return NULL;
164164

165-
result = PyBytes_Format(format, args);
165+
result = PyString_Format(format, args);
166166
Py_DECREF(args);
167167

168168
return result;

Doc/includes/noddy4.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,14 +57,14 @@ Noddy_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
5757

5858
self = (Noddy *)type->tp_alloc(type, 0);
5959
if (self != NULL) {
60-
self->first = PyBytes_FromString("");
60+
self->first = PyString_FromString("");
6161
if (self->first == NULL)
6262
{
6363
Py_DECREF(self);
6464
return NULL;
6565
}
6666

67-
self->last = PyBytes_FromString("");
67+
self->last = PyString_FromString("");
6868
if (self->last == NULL)
6969
{
7070
Py_DECREF(self);
@@ -124,7 +124,7 @@ Noddy_name(Noddy* self)
124124
PyObject *args, *result;
125125

126126
if (format == NULL) {
127-
format = PyBytes_FromString("%s %s");
127+
format = PyString_FromString("%s %s");
128128
if (format == NULL)
129129
return NULL;
130130
}
@@ -143,7 +143,7 @@ Noddy_name(Noddy* self)
143143
if (args == NULL)
144144
return NULL;
145145

146-
result = PyBytes_Format(format, args);
146+
result = PyString_Format(format, args);
147147
Py_DECREF(args);
148148

149149
return result;

Doc/includes/run-func.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ main(int argc, char *argv[])
1313
}
1414

1515
Py_Initialize();
16-
pName = PyBytes_FromString(argv[1]);
16+
pName = PyString_FromString(argv[1]);
1717
/* Error checking of pName left out */
1818

1919
pModule = PyImport_Import(pName);

Include/bytesobject.h

Lines changed: 38 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11

2-
/* Bytes (String) object interface */
2+
/* String (Bytes) object interface */
33

44
#ifndef Py_BYTESOBJECT_H
55
#define Py_BYTESOBJECT_H
@@ -10,7 +10,7 @@ extern "C" {
1010
#include <stdarg.h>
1111

1212
/*
13-
Type PyBytesObject represents a character string. An extra zero byte is
13+
Type PyStringObject represents a character string. An extra zero byte is
1414
reserved at the end to ensure it is zero-terminated, but a size is
1515
present so strings with null bytes in them can be represented. This
1616
is an immutable object type.
@@ -46,61 +46,61 @@ typedef struct {
4646
* 'interned' dictionary; in this case the two references
4747
* from 'interned' to this object are *not counted* in ob_refcnt.
4848
*/
49-
} PyBytesObject;
49+
} PyStringObject;
5050

5151
#define SSTATE_NOT_INTERNED 0
5252
#define SSTATE_INTERNED_MORTAL 1
5353
#define SSTATE_INTERNED_IMMORTAL 2
5454

5555
PyAPI_DATA(PyTypeObject) PyBaseString_Type;
56-
PyAPI_DATA(PyTypeObject) PyBytes_Type;
56+
PyAPI_DATA(PyTypeObject) PyString_Type;
5757

58-
#define PyBytes_Check(op) \
58+
#define PyString_Check(op) \
5959
PyType_FastSubclass(Py_TYPE(op), Py_TPFLAGS_STRING_SUBCLASS)
60-
#define PyBytes_CheckExact(op) (Py_TYPE(op) == &PyBytes_Type)
60+
#define PyString_CheckExact(op) (Py_TYPE(op) == &PyString_Type)
6161

62-
PyAPI_FUNC(PyObject *) PyBytes_FromStringAndSize(const char *, Py_ssize_t);
63-
PyAPI_FUNC(PyObject *) PyBytes_FromString(const char *);
64-
PyAPI_FUNC(PyObject *) PyBytes_FromFormatV(const char*, va_list)
62+
PyAPI_FUNC(PyObject *) PyString_FromStringAndSize(const char *, Py_ssize_t);
63+
PyAPI_FUNC(PyObject *) PyString_FromString(const char *);
64+
PyAPI_FUNC(PyObject *) PyString_FromFormatV(const char*, va_list)
6565
Py_GCC_ATTRIBUTE((format(printf, 1, 0)));
66-
PyAPI_FUNC(PyObject *) PyBytes_FromFormat(const char*, ...)
66+
PyAPI_FUNC(PyObject *) PyString_FromFormat(const char*, ...)
6767
Py_GCC_ATTRIBUTE((format(printf, 1, 2)));
68-
PyAPI_FUNC(Py_ssize_t) PyBytes_Size(PyObject *);
69-
PyAPI_FUNC(char *) PyBytes_AsString(PyObject *);
70-
PyAPI_FUNC(PyObject *) PyBytes_Repr(PyObject *, int);
71-
PyAPI_FUNC(void) PyBytes_Concat(PyObject **, PyObject *);
72-
PyAPI_FUNC(void) PyBytes_ConcatAndDel(PyObject **, PyObject *);
73-
PyAPI_FUNC(int) _PyBytes_Resize(PyObject **, Py_ssize_t);
74-
PyAPI_FUNC(int) _PyBytes_Eq(PyObject *, PyObject*);
75-
PyAPI_FUNC(PyObject *) PyBytes_Format(PyObject *, PyObject *);
76-
PyAPI_FUNC(PyObject *) _PyBytes_FormatLong(PyObject*, int, int,
68+
PyAPI_FUNC(Py_ssize_t) PyString_Size(PyObject *);
69+
PyAPI_FUNC(char *) PyString_AsString(PyObject *);
70+
PyAPI_FUNC(PyObject *) PyString_Repr(PyObject *, int);
71+
PyAPI_FUNC(void) PyString_Concat(PyObject **, PyObject *);
72+
PyAPI_FUNC(void) PyString_ConcatAndDel(PyObject **, PyObject *);
73+
PyAPI_FUNC(int) _PyString_Resize(PyObject **, Py_ssize_t);
74+
PyAPI_FUNC(int) _PyString_Eq(PyObject *, PyObject*);
75+
PyAPI_FUNC(PyObject *) PyString_Format(PyObject *, PyObject *);
76+
PyAPI_FUNC(PyObject *) _PyString_FormatLong(PyObject*, int, int,
7777
int, char**, int*);
78-
PyAPI_FUNC(PyObject *) PyBytes_DecodeEscape(const char *, Py_ssize_t,
78+
PyAPI_FUNC(PyObject *) PyString_DecodeEscape(const char *, Py_ssize_t,
7979
const char *, Py_ssize_t,
8080
const char *);
8181

82-
PyAPI_FUNC(void) PyBytes_InternInPlace(PyObject **);
83-
PyAPI_FUNC(void) PyBytes_InternImmortal(PyObject **);
84-
PyAPI_FUNC(PyObject *) PyBytes_InternFromString(const char *);
82+
PyAPI_FUNC(void) PyString_InternInPlace(PyObject **);
83+
PyAPI_FUNC(void) PyString_InternImmortal(PyObject **);
84+
PyAPI_FUNC(PyObject *) PyString_InternFromString(const char *);
8585
PyAPI_FUNC(void) _Py_ReleaseInternedStrings(void);
8686

8787
/* Use only if you know it's a string */
88-
#define PyBytes_CHECK_INTERNED(op) (((PyBytesObject *)(op))->ob_sstate)
88+
#define PyString_CHECK_INTERNED(op) (((PyStringObject *)(op))->ob_sstate)
8989

9090
/* Macro, trading safety for speed */
91-
#define PyBytes_AS_STRING(op) (((PyBytesObject *)(op))->ob_sval)
92-
#define PyBytes_GET_SIZE(op) Py_SIZE(op)
91+
#define PyString_AS_STRING(op) (((PyStringObject *)(op))->ob_sval)
92+
#define PyString_GET_SIZE(op) Py_SIZE(op)
9393

94-
/* _PyBytes_Join(sep, x) is like sep.join(x). sep must be PyBytesObject*,
94+
/* _PyString_Join(sep, x) is like sep.join(x). sep must be PyStringObject*,
9595
x must be an iterable object. */
96-
PyAPI_FUNC(PyObject *) _PyBytes_Join(PyObject *sep, PyObject *x);
96+
PyAPI_FUNC(PyObject *) _PyString_Join(PyObject *sep, PyObject *x);
9797

9898
/* --- Generic Codecs ----------------------------------------------------- */
9999

100100
/* Create an object by decoding the encoded string s of the
101101
given size. */
102102

103-
PyAPI_FUNC(PyObject*) PyBytes_Decode(
103+
PyAPI_FUNC(PyObject*) PyString_Decode(
104104
const char *s, /* encoded string */
105105
Py_ssize_t size, /* size of buffer */
106106
const char *encoding, /* encoding */
@@ -110,7 +110,7 @@ PyAPI_FUNC(PyObject*) PyBytes_Decode(
110110
/* Encodes a char buffer of the given size and returns a
111111
Python object. */
112112

113-
PyAPI_FUNC(PyObject*) PyBytes_Encode(
113+
PyAPI_FUNC(PyObject*) PyString_Encode(
114114
const char *s, /* string char buffer */
115115
Py_ssize_t size, /* number of chars to encode */
116116
const char *encoding, /* encoding */
@@ -120,7 +120,7 @@ PyAPI_FUNC(PyObject*) PyBytes_Encode(
120120
/* Encodes a string object and returns the result as Python
121121
object. */
122122

123-
PyAPI_FUNC(PyObject*) PyBytes_AsEncodedObject(
123+
PyAPI_FUNC(PyObject*) PyString_AsEncodedObject(
124124
PyObject *str, /* string object */
125125
const char *encoding, /* encoding */
126126
const char *errors /* error handling */
@@ -132,9 +132,9 @@ PyAPI_FUNC(PyObject*) PyBytes_AsEncodedObject(
132132
If the codec returns an Unicode object, the object is converted
133133
back to a string using the default encoding.
134134
135-
DEPRECATED - use PyBytes_AsEncodedObject() instead. */
135+
DEPRECATED - use PyString_AsEncodedObject() instead. */
136136

137-
PyAPI_FUNC(PyObject*) PyBytes_AsEncodedString(
137+
PyAPI_FUNC(PyObject*) PyString_AsEncodedString(
138138
PyObject *str, /* string object */
139139
const char *encoding, /* encoding */
140140
const char *errors /* error handling */
@@ -143,7 +143,7 @@ PyAPI_FUNC(PyObject*) PyBytes_AsEncodedString(
143143
/* Decodes a string object and returns the result as Python
144144
object. */
145145

146-
PyAPI_FUNC(PyObject*) PyBytes_AsDecodedObject(
146+
PyAPI_FUNC(PyObject*) PyString_AsDecodedObject(
147147
PyObject *str, /* string object */
148148
const char *encoding, /* encoding */
149149
const char *errors /* error handling */
@@ -155,9 +155,9 @@ PyAPI_FUNC(PyObject*) PyBytes_AsDecodedObject(
155155
If the codec returns an Unicode object, the object is converted
156156
back to a string using the default encoding.
157157
158-
DEPRECATED - use PyBytes_AsDecodedObject() instead. */
158+
DEPRECATED - use PyString_AsDecodedObject() instead. */
159159

160-
PyAPI_FUNC(PyObject*) PyBytes_AsDecodedString(
160+
PyAPI_FUNC(PyObject*) PyString_AsDecodedString(
161161
PyObject *str, /* string object */
162162
const char *encoding, /* encoding */
163163
const char *errors /* error handling */
@@ -169,7 +169,7 @@ PyAPI_FUNC(PyObject*) PyBytes_AsDecodedString(
169169
0-terminated (passing a string with embedded NULL characters will
170170
cause an exception). */
171171

172-
PyAPI_FUNC(int) PyBytes_AsStringAndSize(
172+
PyAPI_FUNC(int) PyString_AsStringAndSize(
173173
register PyObject *obj, /* string or Unicode object */
174174
register char **s, /* pointer to buffer variable */
175175
register Py_ssize_t *len /* pointer to length variable or NULL
@@ -181,7 +181,7 @@ PyAPI_FUNC(int) PyBytes_AsStringAndSize(
181181
into the string pointed to by buffer. For the argument descriptions,
182182
see Objects/stringlib/localeutil.h */
183183

184-
PyAPI_FUNC(int) _PyBytes_InsertThousandsGrouping(char *buffer,
184+
PyAPI_FUNC(int) _PyString_InsertThousandsGrouping(char *buffer,
185185
Py_ssize_t len,
186186
char *plast,
187187
Py_ssize_t buf_size,

Include/object.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -504,7 +504,7 @@ PyAPI_FUNC(long) _Py_HashDouble(double);
504504
PyAPI_FUNC(long) _Py_HashPointer(void*);
505505

506506
/* Helper for passing objects to printf and the like */
507-
#define PyObject_REPR(obj) PyBytes_AS_STRING(PyObject_Repr(obj))
507+
#define PyObject_REPR(obj) PyString_AS_STRING(PyObject_Repr(obj))
508508

509509
/* Flag bits for printing: */
510510
#define Py_PRINT_RAW 1 /* No string quotes etc. */
@@ -598,7 +598,7 @@ given type object has a specified feature.
598598
#define Py_TPFLAGS_LONG_SUBCLASS (1L<<24)
599599
#define Py_TPFLAGS_LIST_SUBCLASS (1L<<25)
600600
#define Py_TPFLAGS_TUPLE_SUBCLASS (1L<<26)
601-
#define Py_TPFLAGS_BYTES_SUBCLASS (1L<<27)
601+
#define Py_TPFLAGS_STRING_SUBCLASS (1L<<27)
602602
#define Py_TPFLAGS_UNICODE_SUBCLASS (1L<<28)
603603
#define Py_TPFLAGS_DICT_SUBCLASS (1L<<29)
604604
#define Py_TPFLAGS_BASE_EXC_SUBCLASS (1L<<30)

Include/py_curses.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ static PyObject *PyCurses_ ## X (PyObject *self) \
146146
static PyObject *PyCurses_ ## X (PyObject *self) \
147147
{ \
148148
PyCursesInitialised \
149-
return PyBytes_FromString(X()); }
149+
return PyString_FromString(X()); }
150150

151151
#define NoArgTrueFalseFunction(X) \
152152
static PyObject *PyCurses_ ## X (PyObject *self) \

Include/pyerrors.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ PyAPI_FUNC(void) PyErr_NormalizeException(PyObject**, PyObject**, PyObject**);
104104

105105
#define PyExceptionClass_Name(x) \
106106
(PyClass_Check((x)) \
107-
? PyBytes_AS_STRING(((PyClassObject*)(x))->cl_name) \
107+
? PyString_AS_STRING(((PyClassObject*)(x))->cl_name) \
108108
: (char *)(((PyTypeObject*)(x))->tp_name))
109109

110110
#define PyExceptionInstance_Class(x) \

Include/pyport.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -135,9 +135,9 @@ typedef Py_intptr_t Py_ssize_t;
135135
* all platforms (Python interprets the format string itself, and does whatever
136136
* the platform C requires to convert a size_t/Py_ssize_t argument):
137137
*
138-
* PyBytes_FromFormat
138+
* PyString_FromFormat
139139
* PyErr_Format
140-
* PyBytes_FromFormatV
140+
* PyString_FromFormatV
141141
*
142142
* Lower-level uses require that you interpolate the correct format modifier
143143
* yourself (e.g., calling printf, fprintf, sprintf, PyOS_snprintf); for

Include/pythonrun.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ PyAPI_FUNC(void) PyDict_Fini(void);
136136
PyAPI_FUNC(void) PyTuple_Fini(void);
137137
PyAPI_FUNC(void) PyList_Fini(void);
138138
PyAPI_FUNC(void) PySet_Fini(void);
139-
PyAPI_FUNC(void) PyBytes_Fini(void);
139+
PyAPI_FUNC(void) PyString_Fini(void);
140140
PyAPI_FUNC(void) PyInt_Fini(void);
141141
PyAPI_FUNC(void) PyFloat_Fini(void);
142142
PyAPI_FUNC(void) PyOS_FiniInterrupts(void);

0 commit comments

Comments
 (0)