]> granicus.if.org Git - python/commitdiff
This reverts r63675 based on the discussion in this thread:
authorGregory P. Smith <greg@mad-scientist.com>
Mon, 9 Jun 2008 04:58:54 +0000 (04:58 +0000)
committerGregory P. Smith <greg@mad-scientist.com>
Mon, 9 Jun 2008 04:58:54 +0000 (04:58 +0000)
 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.

173 files changed:
Doc/includes/noddy2.c
Doc/includes/noddy3.c
Doc/includes/noddy4.c
Doc/includes/run-func.c
Include/bytesobject.h
Include/object.h
Include/py_curses.h
Include/pyerrors.h
Include/pyport.h
Include/pythonrun.h
Include/stringobject.h
Mac/Modules/MacOS.c
Mac/Modules/Nav.c
Mac/Modules/ae/_AEmodule.c
Mac/Modules/cf/_CFmodule.c
Mac/Modules/cf/pycfbridge.c
Mac/Modules/file/_Filemodule.c
Mac/Modules/qd/_Qdmodule.c
Mac/Modules/qdoffs/_Qdoffsmodule.c
Mac/Modules/res/_Resmodule.c
Mac/Modules/scrap/_Scrapmodule.c
Mac/Modules/snd/_Sndihooks.c
Mac/Modules/win/_Winmodule.c
Makefile.pre.in
Modules/_bytesio.c
Modules/_codecsmodule.c
Modules/_collectionsmodule.c
Modules/_csv.c
Modules/_ctypes/_ctypes.c
Modules/_ctypes/callbacks.c
Modules/_ctypes/callproc.c
Modules/_ctypes/cfield.c
Modules/_curses_panel.c
Modules/_cursesmodule.c
Modules/_elementtree.c
Modules/_fileio.c
Modules/_hashopenssl.c
Modules/_heapqmodule.c
Modules/_hotshot.c
Modules/_json.c
Modules/_localemodule.c
Modules/_lsprof.c
Modules/_sqlite/cache.c
Modules/_sqlite/connection.c
Modules/_sqlite/connection.h
Modules/_sqlite/cursor.c
Modules/_sqlite/module.c
Modules/_sqlite/row.c
Modules/_sqlite/statement.c
Modules/_sre.c
Modules/_ssl.c
Modules/_struct.c
Modules/_testcapimodule.c
Modules/_tkinter.c
Modules/almodule.c
Modules/arraymodule.c
Modules/audioop.c
Modules/binascii.c
Modules/bsddbmodule.c
Modules/bz2module.c
Modules/cPickle.c
Modules/cStringIO.c
Modules/cdmodule.c
Modules/cgensupport.c
Modules/cjkcodecs/cjkcodecs.h
Modules/cjkcodecs/multibytecodec.c
Modules/clmodule.c
Modules/datetimemodule.c
Modules/dbmmodule.c
Modules/dlmodule.c
Modules/errnomodule.c
Modules/fcntlmodule.c
Modules/flmodule.c
Modules/fmmodule.c
Modules/gcmodule.c
Modules/gdbmmodule.c
Modules/glmodule.c
Modules/grpmodule.c
Modules/imageop.c
Modules/imgfile.c
Modules/itertoolsmodule.c
Modules/linuxaudiodev.c
Modules/main.c
Modules/md5module.c
Modules/mmapmodule.c
Modules/nismodule.c
Modules/operator.c
Modules/ossaudiodev.c
Modules/parsermodule.c
Modules/posixmodule.c
Modules/pwdmodule.c
Modules/pyexpat.c
Modules/readline.c
Modules/selectmodule.c
Modules/sha256module.c
Modules/sha512module.c
Modules/shamodule.c
Modules/socketmodule.c
Modules/spwdmodule.c
Modules/stropmodule.c
Modules/sunaudiodev.c
Modules/svmodule.c
Modules/syslogmodule.c
Modules/termios.c
Modules/threadmodule.c
Modules/timemodule.c
Modules/unicodedata.c
Modules/zipimport.c
Modules/zlibmodule.c
Objects/abstract.c
Objects/boolobject.c
Objects/bufferobject.c
Objects/bytes_methods.c
Objects/bytesobject.c
Objects/cellobject.c
Objects/classobject.c
Objects/codeobject.c
Objects/complexobject.c
Objects/descrobject.c
Objects/dictobject.c
Objects/exceptions.c
Objects/fileobject.c
Objects/floatobject.c
Objects/frameobject.c
Objects/funcobject.c
Objects/genobject.c
Objects/intobject.c
Objects/listobject.c
Objects/longobject.c
Objects/methodobject.c
Objects/moduleobject.c
Objects/object.c
Objects/rangeobject.c
Objects/setobject.c
Objects/sliceobject.c
Objects/stringlib/string_format.h
Objects/stringlib/stringdefs.h
Objects/structseq.c
Objects/tupleobject.c
Objects/typeobject.c
Objects/unicodeobject.c
Objects/weakrefobject.c
PC/_msi.c
PC/_subprocess.c
PC/_winreg.c
PC/msvcrtmodule.c
PC/winsound.c
Parser/asdl_c.py
Parser/tokenizer.c
Python/Python-ast.c
Python/_warnings.c
Python/ast.c
Python/bltinmodule.c
Python/ceval.c
Python/codecs.c
Python/compile.c
Python/errors.c
Python/future.c
Python/getargs.c
Python/import.c
Python/mactoolboxglue.c
Python/marshal.c
Python/modsupport.c
Python/peephole.c
Python/pystrtod.c
Python/pythonrun.c
Python/structmember.c
Python/symtable.c
Python/sysmodule.c
Python/traceback.c
RISCOS/Modules/drawfmodule.c
RISCOS/Modules/riscosmodule.c
RISCOS/Modules/swimodule.c

index 837f27035079e56bcded6f03d9cf47905de105d6..2caf9855c64052cb88749f719b7c09ebe84aedad 100644 (file)
@@ -23,14 +23,14 @@ Noddy_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
 
     self = (Noddy *)type->tp_alloc(type, 0);
     if (self != NULL) {
-        self->first = PyBytes_FromString("");
+        self->first = PyString_FromString("");
         if (self->first == NULL)
           {
             Py_DECREF(self);
             return NULL;
           }
         
-        self->last = PyBytes_FromString("");
+        self->last = PyString_FromString("");
         if (self->last == NULL)
           {
             Py_DECREF(self);
@@ -90,7 +90,7 @@ Noddy_name(Noddy* self)
     PyObject *args, *result;
 
     if (format == NULL) {
-        format = PyBytes_FromString("%s %s");
+        format = PyString_FromString("%s %s");
         if (format == NULL)
             return NULL;
     }
@@ -109,7 +109,7 @@ Noddy_name(Noddy* self)
     if (args == NULL)
         return NULL;
 
-    result = PyBytes_Format(format, args);
+    result = PyString_Format(format, args);
     Py_DECREF(args);
     
     return result;
index 5a0a6c135c9ef69f61b9536a10accd938cb18aae..60260ada52fa8e0dd68619f383011fe739a6338c 100644 (file)
@@ -23,14 +23,14 @@ Noddy_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
 
     self = (Noddy *)type->tp_alloc(type, 0);
     if (self != NULL) {
-        self->first = PyBytes_FromString("");
+        self->first = PyString_FromString("");
         if (self->first == NULL)
           {
             Py_DECREF(self);
             return NULL;
           }
         
-        self->last = PyBytes_FromString("");
+        self->last = PyString_FromString("");
         if (self->last == NULL)
           {
             Py_DECREF(self);
@@ -93,7 +93,7 @@ Noddy_setfirst(Noddy *self, PyObject *value, void *closure)
     return -1;
   }
   
-  if (! PyBytes_Check(value)) {
+  if (! PyString_Check(value)) {
     PyErr_SetString(PyExc_TypeError, 
                     "The first attribute value must be a string");
     return -1;
@@ -121,7 +121,7 @@ Noddy_setlast(Noddy *self, PyObject *value, void *closure)
     return -1;
   }
   
-  if (! PyBytes_Check(value)) {
+  if (! PyString_Check(value)) {
     PyErr_SetString(PyExc_TypeError, 
                     "The last attribute value must be a string");
     return -1;
@@ -153,7 +153,7 @@ Noddy_name(Noddy* self)
     PyObject *args, *result;
 
     if (format == NULL) {
-        format = PyBytes_FromString("%s %s");
+        format = PyString_FromString("%s %s");
         if (format == NULL)
             return NULL;
     }
@@ -162,7 +162,7 @@ Noddy_name(Noddy* self)
     if (args == NULL)
         return NULL;
 
-    result = PyBytes_Format(format, args);
+    result = PyString_Format(format, args);
     Py_DECREF(args);
     
     return result;
index da41b2b41dac5d47d8de274f9edbe7bdbb7fa7fe..878e0861d873fa96877aab40bd6a2783cd9a4e68 100644 (file)
@@ -57,14 +57,14 @@ Noddy_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
 
     self = (Noddy *)type->tp_alloc(type, 0);
     if (self != NULL) {
-        self->first = PyBytes_FromString("");
+        self->first = PyString_FromString("");
         if (self->first == NULL)
           {
             Py_DECREF(self);
             return NULL;
           }
         
-        self->last = PyBytes_FromString("");
+        self->last = PyString_FromString("");
         if (self->last == NULL)
           {
             Py_DECREF(self);
@@ -124,7 +124,7 @@ Noddy_name(Noddy* self)
     PyObject *args, *result;
 
     if (format == NULL) {
-        format = PyBytes_FromString("%s %s");
+        format = PyString_FromString("%s %s");
         if (format == NULL)
             return NULL;
     }
@@ -143,7 +143,7 @@ Noddy_name(Noddy* self)
     if (args == NULL)
         return NULL;
 
-    result = PyBytes_Format(format, args);
+    result = PyString_Format(format, args);
     Py_DECREF(args);
     
     return result;
index 1b7c94295683e5b456463ebfb6b60978f4dec390..5a7df0d98056bc371aaaf4e4fdadf616527803e9 100644 (file)
@@ -13,7 +13,7 @@ main(int argc, char *argv[])
     }
 
     Py_Initialize();
-    pName = PyBytes_FromString(argv[1]);
+    pName = PyString_FromString(argv[1]);
     /* Error checking of pName left out */
 
     pModule = PyImport_Import(pName);
index acb943b5f92661777ad21d05cd44de1a689f64af..268d7c6aa4f37ce3147bd25fa8200952a7f7cb91 100644 (file)
@@ -1,5 +1,5 @@
 
-/* Bytes (String) object interface */
+/* String (Bytes) object interface */
 
 #ifndef Py_BYTESOBJECT_H
 #define Py_BYTESOBJECT_H
@@ -10,7 +10,7 @@ extern "C" {
 #include <stdarg.h>
 
 /*
-Type PyBytesObject represents a character string.  An extra zero byte is
+Type PyStringObject represents a character string.  An extra zero byte is
 reserved at the end to ensure it is zero-terminated, but a size is
 present so strings with null bytes in them can be represented.  This
 is an immutable object type.
@@ -46,61 +46,61 @@ typedef struct {
      *       'interned' dictionary; in this case the two references
      *       from 'interned' to this object are *not counted* in ob_refcnt.
      */
-} PyBytesObject;
+} PyStringObject;
 
 #define SSTATE_NOT_INTERNED 0
 #define SSTATE_INTERNED_MORTAL 1
 #define SSTATE_INTERNED_IMMORTAL 2
 
 PyAPI_DATA(PyTypeObject) PyBaseString_Type;
-PyAPI_DATA(PyTypeObject) PyBytes_Type;
+PyAPI_DATA(PyTypeObject) PyString_Type;
 
-#define PyBytes_Check(op) \
+#define PyString_Check(op) \
                  PyType_FastSubclass(Py_TYPE(op), Py_TPFLAGS_STRING_SUBCLASS)
-#define PyBytes_CheckExact(op) (Py_TYPE(op) == &PyBytes_Type)
+#define PyString_CheckExact(op) (Py_TYPE(op) == &PyString_Type)
 
-PyAPI_FUNC(PyObject *) PyBytes_FromStringAndSize(const char *, Py_ssize_t);
-PyAPI_FUNC(PyObject *) PyBytes_FromString(const char *);
-PyAPI_FUNC(PyObject *) PyBytes_FromFormatV(const char*, va_list)
+PyAPI_FUNC(PyObject *) PyString_FromStringAndSize(const char *, Py_ssize_t);
+PyAPI_FUNC(PyObject *) PyString_FromString(const char *);
+PyAPI_FUNC(PyObject *) PyString_FromFormatV(const char*, va_list)
                                Py_GCC_ATTRIBUTE((format(printf, 1, 0)));
-PyAPI_FUNC(PyObject *) PyBytes_FromFormat(const char*, ...)
+PyAPI_FUNC(PyObject *) PyString_FromFormat(const char*, ...)
                                Py_GCC_ATTRIBUTE((format(printf, 1, 2)));
-PyAPI_FUNC(Py_ssize_t) PyBytes_Size(PyObject *);
-PyAPI_FUNC(char *) PyBytes_AsString(PyObject *);
-PyAPI_FUNC(PyObject *) PyBytes_Repr(PyObject *, int);
-PyAPI_FUNC(void) PyBytes_Concat(PyObject **, PyObject *);
-PyAPI_FUNC(void) PyBytes_ConcatAndDel(PyObject **, PyObject *);
-PyAPI_FUNC(int) _PyBytes_Resize(PyObject **, Py_ssize_t);
-PyAPI_FUNC(int) _PyBytes_Eq(PyObject *, PyObject*);
-PyAPI_FUNC(PyObject *) PyBytes_Format(PyObject *, PyObject *);
-PyAPI_FUNC(PyObject *) _PyBytes_FormatLong(PyObject*, int, int,
+PyAPI_FUNC(Py_ssize_t) PyString_Size(PyObject *);
+PyAPI_FUNC(char *) PyString_AsString(PyObject *);
+PyAPI_FUNC(PyObject *) PyString_Repr(PyObject *, int);
+PyAPI_FUNC(void) PyString_Concat(PyObject **, PyObject *);
+PyAPI_FUNC(void) PyString_ConcatAndDel(PyObject **, PyObject *);
+PyAPI_FUNC(int) _PyString_Resize(PyObject **, Py_ssize_t);
+PyAPI_FUNC(int) _PyString_Eq(PyObject *, PyObject*);
+PyAPI_FUNC(PyObject *) PyString_Format(PyObject *, PyObject *);
+PyAPI_FUNC(PyObject *) _PyString_FormatLong(PyObject*, int, int,
                                                  int, char**, int*);
-PyAPI_FUNC(PyObject *) PyBytes_DecodeEscape(const char *, Py_ssize_t, 
+PyAPI_FUNC(PyObject *) PyString_DecodeEscape(const char *, Py_ssize_t, 
                                                   const char *, Py_ssize_t,
                                                   const char *);
 
-PyAPI_FUNC(void) PyBytes_InternInPlace(PyObject **);
-PyAPI_FUNC(void) PyBytes_InternImmortal(PyObject **);
-PyAPI_FUNC(PyObject *) PyBytes_InternFromString(const char *);
+PyAPI_FUNC(void) PyString_InternInPlace(PyObject **);
+PyAPI_FUNC(void) PyString_InternImmortal(PyObject **);
+PyAPI_FUNC(PyObject *) PyString_InternFromString(const char *);
 PyAPI_FUNC(void) _Py_ReleaseInternedStrings(void);
 
 /* Use only if you know it's a string */
-#define PyBytes_CHECK_INTERNED(op) (((PyBytesObject *)(op))->ob_sstate)
+#define PyString_CHECK_INTERNED(op) (((PyStringObject *)(op))->ob_sstate)
 
 /* Macro, trading safety for speed */
-#define PyBytes_AS_STRING(op) (((PyBytesObject *)(op))->ob_sval)
-#define PyBytes_GET_SIZE(op)  Py_SIZE(op)
+#define PyString_AS_STRING(op) (((PyStringObject *)(op))->ob_sval)
+#define PyString_GET_SIZE(op)  Py_SIZE(op)
 
-/* _PyBytes_Join(sep, x) is like sep.join(x).  sep must be PyBytesObject*,
+/* _PyString_Join(sep, x) is like sep.join(x).  sep must be PyStringObject*,
    x must be an iterable object. */
-PyAPI_FUNC(PyObject *) _PyBytes_Join(PyObject *sep, PyObject *x);
+PyAPI_FUNC(PyObject *) _PyString_Join(PyObject *sep, PyObject *x);
 
 /* --- Generic Codecs ----------------------------------------------------- */
 
 /* Create an object by decoding the encoded string s of the
    given size. */
 
-PyAPI_FUNC(PyObject*) PyBytes_Decode(
+PyAPI_FUNC(PyObject*) PyString_Decode(
     const char *s,              /* encoded string */
     Py_ssize_t size,            /* size of buffer */
     const char *encoding,       /* encoding */
@@ -110,7 +110,7 @@ PyAPI_FUNC(PyObject*) PyBytes_Decode(
 /* Encodes a char buffer of the given size and returns a 
    Python object. */
 
-PyAPI_FUNC(PyObject*) PyBytes_Encode(
+PyAPI_FUNC(PyObject*) PyString_Encode(
     const char *s,              /* string char buffer */
     Py_ssize_t size,            /* number of chars to encode */
     const char *encoding,       /* encoding */
@@ -120,7 +120,7 @@ PyAPI_FUNC(PyObject*) PyBytes_Encode(
 /* Encodes a string object and returns the result as Python 
    object. */
 
-PyAPI_FUNC(PyObject*) PyBytes_AsEncodedObject(
+PyAPI_FUNC(PyObject*) PyString_AsEncodedObject(
     PyObject *str,             /* string object */
     const char *encoding,      /* encoding */
     const char *errors         /* error handling */
@@ -132,9 +132,9 @@ PyAPI_FUNC(PyObject*) PyBytes_AsEncodedObject(
    If the codec returns an Unicode object, the object is converted
    back to a string using the default encoding.
 
-   DEPRECATED - use PyBytes_AsEncodedObject() instead. */
+   DEPRECATED - use PyString_AsEncodedObject() instead. */
 
-PyAPI_FUNC(PyObject*) PyBytes_AsEncodedString(
+PyAPI_FUNC(PyObject*) PyString_AsEncodedString(
     PyObject *str,             /* string object */
     const char *encoding,      /* encoding */
     const char *errors         /* error handling */
@@ -143,7 +143,7 @@ PyAPI_FUNC(PyObject*) PyBytes_AsEncodedString(
 /* Decodes a string object and returns the result as Python 
    object. */
 
-PyAPI_FUNC(PyObject*) PyBytes_AsDecodedObject(
+PyAPI_FUNC(PyObject*) PyString_AsDecodedObject(
     PyObject *str,             /* string object */
     const char *encoding,      /* encoding */
     const char *errors         /* error handling */
@@ -155,9 +155,9 @@ PyAPI_FUNC(PyObject*) PyBytes_AsDecodedObject(
    If the codec returns an Unicode object, the object is converted
    back to a string using the default encoding.
 
-   DEPRECATED - use PyBytes_AsDecodedObject() instead. */
+   DEPRECATED - use PyString_AsDecodedObject() instead. */
 
-PyAPI_FUNC(PyObject*) PyBytes_AsDecodedString(
+PyAPI_FUNC(PyObject*) PyString_AsDecodedString(
     PyObject *str,             /* string object */
     const char *encoding,      /* encoding */
     const char *errors         /* error handling */
@@ -169,7 +169,7 @@ PyAPI_FUNC(PyObject*) PyBytes_AsDecodedString(
    0-terminated (passing a string with embedded NULL characters will
    cause an exception).  */
 
-PyAPI_FUNC(int) PyBytes_AsStringAndSize(
+PyAPI_FUNC(int) PyString_AsStringAndSize(
     register PyObject *obj,    /* string or Unicode object */
     register char **s,         /* pointer to buffer variable */
     register Py_ssize_t *len   /* pointer to length variable or NULL
@@ -181,7 +181,7 @@ PyAPI_FUNC(int) PyBytes_AsStringAndSize(
    into the string pointed to by buffer.  For the argument descriptions,
    see Objects/stringlib/localeutil.h */
 
-PyAPI_FUNC(int) _PyBytes_InsertThousandsGrouping(char *buffer,
+PyAPI_FUNC(int) _PyString_InsertThousandsGrouping(char *buffer,
                                                  Py_ssize_t len,
                                                  char *plast,
                                                  Py_ssize_t buf_size,
index 96e7d8632f229626970ff15000a41f81f0d3b4dc..59f3b9e1b100c6815585243d3112ae25c3277115 100644 (file)
@@ -504,7 +504,7 @@ PyAPI_FUNC(long) _Py_HashDouble(double);
 PyAPI_FUNC(long) _Py_HashPointer(void*);
 
 /* Helper for passing objects to printf and the like */
-#define PyObject_REPR(obj) PyBytes_AS_STRING(PyObject_Repr(obj))
+#define PyObject_REPR(obj) PyString_AS_STRING(PyObject_Repr(obj))
 
 /* Flag bits for printing: */
 #define Py_PRINT_RAW   1       /* No string quotes etc. */
@@ -598,7 +598,7 @@ given type object has a specified feature.
 #define Py_TPFLAGS_LONG_SUBCLASS       (1L<<24)
 #define Py_TPFLAGS_LIST_SUBCLASS       (1L<<25)
 #define Py_TPFLAGS_TUPLE_SUBCLASS      (1L<<26)
-#define Py_TPFLAGS_BYTES_SUBCLASS      (1L<<27)
+#define Py_TPFLAGS_STRING_SUBCLASS     (1L<<27)
 #define Py_TPFLAGS_UNICODE_SUBCLASS    (1L<<28)
 #define Py_TPFLAGS_DICT_SUBCLASS       (1L<<29)
 #define Py_TPFLAGS_BASE_EXC_SUBCLASS   (1L<<30)
index 3a2f9f457e0e5dd4d344a0ce0a9d21e8a481e33f..f38f76543b150c25bdb9930178f42d06a9acfd1c 100644 (file)
@@ -146,7 +146,7 @@ static PyObject *PyCurses_ ## X (PyObject *self) \
 static PyObject *PyCurses_ ## X (PyObject *self) \
 { \
   PyCursesInitialised \
-  return PyBytes_FromString(X()); }
+  return PyString_FromString(X()); }
 
 #define NoArgTrueFalseFunction(X) \
 static PyObject *PyCurses_ ## X (PyObject *self) \
index cdc9b76ec5b6328378f442a7ae72620de1e80fe1..a4233c9748a495bdd106a516b802ad91277cd26e 100644 (file)
@@ -104,7 +104,7 @@ PyAPI_FUNC(void) PyErr_NormalizeException(PyObject**, PyObject**, PyObject**);
 
 #define PyExceptionClass_Name(x)                                  \
        (PyClass_Check((x))                                        \
-        ? PyBytes_AS_STRING(((PyClassObject*)(x))->cl_name)       \
+        ? PyString_AS_STRING(((PyClassObject*)(x))->cl_name)      \
         : (char *)(((PyTypeObject*)(x))->tp_name))
 
 #define PyExceptionInstance_Class(x)                                   \
index 5501164ffb2a6bc7dc4c9407494e38e328f0fecf..7c684f7320f32e25700b2566cf03a40196a91b5d 100644 (file)
@@ -135,9 +135,9 @@ typedef Py_intptr_t Py_ssize_t;
  * all platforms (Python interprets the format string itself, and does whatever
  * the platform C requires to convert a size_t/Py_ssize_t argument):
  *
- *     PyBytes_FromFormat
+ *     PyString_FromFormat
  *     PyErr_Format
- *     PyBytes_FromFormatV
+ *     PyString_FromFormatV
  *
  * Lower-level uses require that you interpolate the correct format modifier
  * yourself (e.g., calling printf, fprintf, sprintf, PyOS_snprintf); for
index 3fc70f5ddabfa663194210a3ac25a243bdb1155b..c5635ba01a5205e6d583348ca3e9ee447505d48e 100644 (file)
@@ -136,7 +136,7 @@ PyAPI_FUNC(void) PyDict_Fini(void);
 PyAPI_FUNC(void) PyTuple_Fini(void);
 PyAPI_FUNC(void) PyList_Fini(void);
 PyAPI_FUNC(void) PySet_Fini(void);
-PyAPI_FUNC(void) PyBytes_Fini(void);
+PyAPI_FUNC(void) PyString_Fini(void);
 PyAPI_FUNC(void) PyInt_Fini(void);
 PyAPI_FUNC(void) PyFloat_Fini(void);
 PyAPI_FUNC(void) PyOS_FiniInterrupts(void);
index e1cc17f0545a329c04bd5228b96794371105cb76..a50792c35bd92ffe39455bb89e8bed1d184ad131 100644 (file)
@@ -1,13 +1,12 @@
 #define PyBytesObject PyStringObject
 #define PyBytes_Type PyString_Type
 
-#define PyString_Check PyBytes_Check
-#define PyString_CheckExact PyBytes_CheckExact
-#define PyString_CHECK_INTERNED PyBytes_CHECK_INTERNED
-#define PyString_AS_STRING PyBytes_AS_STRING
-#define PyString_GET_SIZE PyBytes_GET_SIZE
-
-#define Py_TPFLAGS_STRING_SUBCLASS Py_TPFLAGS_BYTES_SUBCLASS
+#define PyBytes_Check PyString_Check
+#define PyBytes_CheckExact PyString_CheckExact 
+#define PyBytes_CHECK_INTERNED PyString_CHECK_INTERNED
+#define PyBytes_AS_STRING PyString_AS_STRING
+#define PyBytes_GET_SIZE PyString_GET_SIZE
+#define Py_TPFLAGS_BYTES_SUBCLASS Py_TPFLAGS_STRING_SUBCLASS
 
 #define PyBytes_FromStringAndSize PyString_FromStringAndSize
 #define PyBytes_FromString PyString_FromString
@@ -23,9 +22,6 @@
 #define PyBytes_Format PyString_Format
 #define _PyBytes_FormatLong _PyString_FormatLong
 #define PyBytes_DecodeEscape PyString_DecodeEscape
-#define PyBytes_InternInPlace PyString_InternInPlace
-#define PyBytes_InternImmortal PyString_InternImmortal
-#define PyBytes_InternFromString PyString_InternFromString
 #define _PyBytes_Join _PyString_Join
 #define PyBytes_Decode PyString_Decode
 #define PyBytes_Encode PyString_Encode
index 9148fe0f76395d45d36bfd16be56a617e5e86cae..07a3434bd87c70bf9b92df5958fec1b7a5a0ba66 100644 (file)
@@ -706,7 +706,7 @@ initMacOS(void)
        ** some of the image and sound processing interfaces on the mac:-(
        */
        {
-               PyBytesObject *p = 0;
+               PyStringObject *p = 0;
                long off = (long)&(p->ob_sval[0]);
                
                if( PyDict_SetItemString(d, "string_id_to_buffer", Py_BuildValue("i", off)) != 0)
index 3e2d9d670159078d8c7691de0e005dd92bb697e0..e03a06ea7309e9bf70080d25fbff3c0aea8ce639 100644 (file)
@@ -139,11 +139,11 @@ filldialogoptions(PyObject *d,
        NavGetDefaultDialogOptions(opt);
 
        while ( PyDict_Next(d, &pos, &key, &value) ) {
-               if ( !key || !value || !PyBytes_Check(key) ) {
+               if ( !key || !value || !PyString_Check(key) ) {
                        PyErr_SetString(ErrorObject, "DialogOption has non-string key");
                        return 0;
                }
-               keystr = PyBytes_AsString(key);
+               keystr = PyString_AsString(key);
                if( strcmp(keystr, "defaultLocation") == 0 ) {
                        if ( (defaultLocation_storage = PyMem_NEW(AEDesc, 1)) == NULL ) {
                                PyErr_NoMemory();
@@ -963,7 +963,7 @@ initNav(void)
 
        /* Add some symbolic constants to the module */
        d = PyModule_GetDict(m);
-       ErrorObject = PyBytes_FromString("Nav.error");
+       ErrorObject = PyString_FromString("Nav.error");
        PyDict_SetItemString(d, "error", ErrorObject);
 
        /* XXXX Add constants here */
index e12a30c1b27a8a83b1a7b16b05a4131a7b77ff5c..09105a56f51964a6af2b3a1a40c93e9ec0fac347 100644 (file)
@@ -840,9 +840,9 @@ static PyObject *AEDesc_get_data(AEDescObject *self, void *closure)
        OSErr err;
 
        size = AEGetDescDataSize(&self->ob_itself);
-       if ( (res = PyBytes_FromStringAndSize(NULL, size)) == NULL )
+       if ( (res = PyString_FromStringAndSize(NULL, size)) == NULL )
                return NULL;
-       if ( (ptr = PyBytes_AsString(res)) == NULL )
+       if ( (ptr = PyString_AsString(res)) == NULL )
                return NULL;
        if ( (err=AEGetDescData(&self->ob_itself, ptr, size)) < 0 )
                return PyMac_Error(err);
index 1ea5b7eb8c68a7695542a03a517ab1f52e28622c..0904ae100ee2b505b39f03f8654df4a795fdd7dd 100644 (file)
@@ -392,7 +392,7 @@ static PyObject * CFTypeRefObj_repr(CFTypeRefObject *self)
 {
        char buf[100];
        sprintf(buf, "<CFTypeRef type-%d object at 0x%8.8x for 0x%8.8x>", (int)CFGetTypeID(self->ob_itself), (unsigned)self, (unsigned)self->ob_itself);
-       return PyBytes_FromString(buf);
+       return PyString_FromString(buf);
 }
 
 static int CFTypeRefObj_hash(CFTypeRefObject *self)
@@ -596,7 +596,7 @@ static PyObject * CFArrayRefObj_repr(CFArrayRefObject *self)
 {
        char buf[100];
        sprintf(buf, "<CFArrayRef object at 0x%8.8x for 0x%8.8x>", (unsigned)self, (unsigned)self->ob_itself);
-       return PyBytes_FromString(buf);
+       return PyString_FromString(buf);
 }
 
 static int CFArrayRefObj_hash(CFArrayRefObject *self)
@@ -836,7 +836,7 @@ static PyObject * CFMutableArrayRefObj_repr(CFMutableArrayRefObject *self)
 {
        char buf[100];
        sprintf(buf, "<CFMutableArrayRef object at 0x%8.8x for 0x%8.8x>", (unsigned)self, (unsigned)self->ob_itself);
-       return PyBytes_FromString(buf);
+       return PyString_FromString(buf);
 }
 
 static int CFMutableArrayRefObj_hash(CFMutableArrayRefObject *self)
@@ -1029,7 +1029,7 @@ static PyObject * CFDictionaryRefObj_repr(CFDictionaryRefObject *self)
 {
        char buf[100];
        sprintf(buf, "<CFDictionaryRef object at 0x%8.8x for 0x%8.8x>", (unsigned)self, (unsigned)self->ob_itself);
-       return PyBytes_FromString(buf);
+       return PyString_FromString(buf);
 }
 
 static int CFDictionaryRefObj_hash(CFDictionaryRefObject *self)
@@ -1206,7 +1206,7 @@ static PyObject * CFMutableDictionaryRefObj_repr(CFMutableDictionaryRefObject *s
 {
        char buf[100];
        sprintf(buf, "<CFMutableDictionaryRef object at 0x%8.8x for 0x%8.8x>", (unsigned)self, (unsigned)self->ob_itself);
-       return PyBytes_FromString(buf);
+       return PyString_FromString(buf);
 }
 
 static int CFMutableDictionaryRefObj_hash(CFMutableDictionaryRefObject *self)
@@ -1327,10 +1327,10 @@ int CFDataRefObj_Convert(PyObject *v, CFDataRef *p_itself)
 {
 
        if (v == Py_None) { *p_itself = NULL; return 1; }
-       if (PyBytes_Check(v)) {
+       if (PyString_Check(v)) {
            char *cStr;
            Py_ssize_t cLen;
-           if( PyBytes_AsStringAndSize(v, &cStr, &cLen) < 0 ) return 0;
+           if( PyString_AsStringAndSize(v, &cStr, &cLen) < 0 ) return 0;
            *p_itself = CFDataCreate((CFAllocatorRef)NULL, (unsigned char *)cStr, cLen);
            return 1;
        }
@@ -1405,7 +1405,7 @@ static PyObject *CFDataRefObj_CFDataGetData(CFDataRefObject *_self, PyObject *_a
        int size = CFDataGetLength(_self->ob_itself);
        char *data = (char *)CFDataGetBytePtr(_self->ob_itself);
 
-       _res = (PyObject *)PyBytes_FromStringAndSize(data, size);
+       _res = (PyObject *)PyString_FromStringAndSize(data, size);
        return _res;
 
 }
@@ -1437,7 +1437,7 @@ static PyObject * CFDataRefObj_repr(CFDataRefObject *self)
 {
        char buf[100];
        sprintf(buf, "<CFDataRef object at 0x%8.8x for 0x%8.8x>", (unsigned)self, (unsigned)self->ob_itself);
-       return PyBytes_FromString(buf);
+       return PyString_FromString(buf);
 }
 
 static int CFDataRefObj_hash(CFDataRefObject *self)
@@ -1702,7 +1702,7 @@ static PyObject * CFMutableDataRefObj_repr(CFMutableDataRefObject *self)
 {
        char buf[100];
        sprintf(buf, "<CFMutableDataRef object at 0x%8.8x for 0x%8.8x>", (unsigned)self, (unsigned)self->ob_itself);
-       return PyBytes_FromString(buf);
+       return PyString_FromString(buf);
 }
 
 static int CFMutableDataRefObj_hash(CFMutableDataRefObject *self)
@@ -1823,7 +1823,7 @@ int CFStringRefObj_Convert(PyObject *v, CFStringRef *p_itself)
 {
 
        if (v == Py_None) { *p_itself = NULL; return 1; }
-       if (PyBytes_Check(v)) {
+       if (PyString_Check(v)) {
            char *cStr;
            if (!PyArg_Parse(v, "es", "ascii", &cStr))
                return 0;
@@ -2344,7 +2344,7 @@ static PyObject *CFStringRefObj_CFStringGetString(CFStringRefObject *_self, PyOb
 
        if( data == NULL ) return PyErr_NoMemory();
        if ( CFStringGetCString(_self->ob_itself, data, size, 0) ) {
-               _res = (PyObject *)PyBytes_FromString(data);
+               _res = (PyObject *)PyString_FromString(data);
        } else {
                PyErr_SetString(PyExc_RuntimeError, "CFStringGetCString could not fit the string");
                _res = NULL;
@@ -2445,7 +2445,7 @@ static PyObject * CFStringRefObj_repr(CFStringRefObject *self)
 {
        char buf[100];
        sprintf(buf, "<CFStringRef object at 0x%8.8x for 0x%8.8x>", (unsigned)self, (unsigned)self->ob_itself);
-       return PyBytes_FromString(buf);
+       return PyString_FromString(buf);
 }
 
 static int CFStringRefObj_hash(CFStringRefObject *self)
@@ -2833,7 +2833,7 @@ static PyObject * CFMutableStringRefObj_repr(CFMutableStringRefObject *self)
 {
        char buf[100];
        sprintf(buf, "<CFMutableStringRef object at 0x%8.8x for 0x%8.8x>", (unsigned)self, (unsigned)self->ob_itself);
-       return PyBytes_FromString(buf);
+       return PyString_FromString(buf);
 }
 
 static int CFMutableStringRefObj_hash(CFMutableStringRefObject *self)
@@ -3485,7 +3485,7 @@ static PyObject * CFURLRefObj_repr(CFURLRefObject *self)
 {
        char buf[100];
        sprintf(buf, "<CFURL object at 0x%8.8x for 0x%8.8x>", (unsigned)self, (unsigned)self->ob_itself);
-       return PyBytes_FromString(buf);
+       return PyString_FromString(buf);
 }
 
 static int CFURLRefObj_hash(CFURLRefObject *self)
index 7aa2386c250bbc24b707ae54d3534c1dcb3861e3..06700b365fdc9166f321f190e3ed3249e438c938 100644 (file)
@@ -146,7 +146,7 @@ PyCF_CF2Python_string(CFStringRef src) {
 int
 PyCF_Python2CF(PyObject *src, CFTypeRef *dst) {
 
-       if (PyBytes_Check(src) || PyUnicode_Check(src))
+       if (PyString_Check(src) || PyUnicode_Check(src))
                return PyCF_Python2CF_simple(src, dst);
        if (PySequence_Check(src))
                return PyCF_Python2CF_sequence(src, (CFArrayRef *)dst);
@@ -249,7 +249,7 @@ PyCF_Python2CF_simple(PyObject *src, CFTypeRef *dst) {
                return (*dst != NULL);
        }
 #endif
-       if (PyBytes_Check(src) || PyUnicode_Check(src)) 
+       if (PyString_Check(src) || PyUnicode_Check(src)) 
                return PyCF_Python2CF_string(src, (CFStringRef *)dst);
        if (PyBool_Check(src)) {
                if (src == Py_True)
@@ -281,7 +281,7 @@ PyCF_Python2CF_string(PyObject *src, CFStringRef *dst) {
        CFIndex size;
        UniChar *unichars;
        
-       if (PyBytes_Check(src)) {
+       if (PyString_Check(src)) {
                if (!PyArg_Parse(src, "es", "ascii", &chars))
                        return 0; /* This error is more descriptive than the general one below */
                *dst = CFStringCreateWithCString((CFAllocatorRef)NULL, chars, kCFStringEncodingASCII);
index 352ef640da8b1fc8d43108dab45493010eedff2e..a314e5bc9aaa8f710f2a2f56af68a410e162d74c 100644 (file)
@@ -961,7 +961,7 @@ static PyObject *Alias_get_data(AliasObject *self, void *closure)
 
                            size = GetHandleSize((Handle)self->ob_itself);
                            HLock((Handle)self->ob_itself);
-                           rv = PyBytes_FromStringAndSize(*(Handle)self->ob_itself, size);
+                           rv = PyString_FromStringAndSize(*(Handle)self->ob_itself, size);
                            HUnlock((Handle)self->ob_itself);
                            return rv;
                    
@@ -1362,7 +1362,7 @@ static PyObject *FSSpec_as_pathname(FSSpecObject *_self, PyObject *_args)
                PyMac_Error(err);
                return NULL;
        }
-       _res = PyBytes_FromString(strbuf);
+       _res = PyString_FromString(strbuf);
        return _res;
 
 }
@@ -1419,7 +1419,7 @@ static PyMethodDef FSSpec_methods[] = {
 
 static PyObject *FSSpec_get_data(FSSpecObject *self, void *closure)
 {
-       return PyBytes_FromStringAndSize((char *)&self->ob_itself, sizeof(self->ob_itself));
+       return PyString_FromStringAndSize((char *)&self->ob_itself, sizeof(self->ob_itself));
 }
 
 #define FSSpec_set_data NULL
@@ -1440,7 +1440,7 @@ static PyObject * FSSpec_repr(FSSpecObject *self)
                self->ob_itself.vRefNum,
                self->ob_itself.parID,
                self->ob_itself.name[0], self->ob_itself.name+1);
-       return PyBytes_FromString(buf);
+       return PyString_FromString(buf);
 }
 
 #define FSSpec_hash NULL
@@ -2015,7 +2015,7 @@ static PyMethodDef FSRef_methods[] = {
 
 static PyObject *FSRef_get_data(FSRefObject *self, void *closure)
 {
-       return PyBytes_FromStringAndSize((char *)&self->ob_itself, sizeof(self->ob_itself));
+       return PyString_FromStringAndSize((char *)&self->ob_itself, sizeof(self->ob_itself));
 }
 
 #define FSRef_set_data NULL
@@ -3131,7 +3131,7 @@ static PyObject *File_pathname(PyObject *_self, PyObject *_args)
 
        if (!PyArg_ParseTuple(_args, "O", &obj))
                return NULL;
-       if (PyBytes_Check(obj)) {
+       if (PyString_Check(obj)) {
                Py_INCREF(obj);
                return obj;
        }
@@ -3301,7 +3301,7 @@ PyMac_GetFSRef(PyObject *v, FSRef *fsr)
         }
 
         /* On OSX we now try a pathname */
-        if ( PyBytes_Check(v) || PyUnicode_Check(v)) {
+        if ( PyString_Check(v) || PyUnicode_Check(v)) {
                 char *path = NULL;
                 if (!PyArg_Parse(v, "et", Py_FileSystemDefaultEncoding, &path))
                         return 0;
index f2202e0104324946cfe3518c371d8618b1187d6c..8c98fa1aaa9fd3b765e14ab1b7973f742dde4aab 100644 (file)
@@ -1458,7 +1458,7 @@ static PyObject *BMObj_getdata(BitMapObject *_self, PyObject *_args)
        if ( !PyArg_ParseTuple(_args, "ii", &from, &length) )
                return NULL;
        cp = _self->ob_itself->baseAddr+from;
-       _res = PyBytes_FromStringAndSize(cp, length);
+       _res = PyString_FromStringAndSize(cp, length);
        return _res;
 
 }
@@ -1511,14 +1511,14 @@ static PyObject *BMObj_get_bounds(BitMapObject *self, void *closure)
 
 static PyObject *BMObj_get_bitmap_data(BitMapObject *self, void *closure)
 {
-       return PyBytes_FromStringAndSize((char *)self->ob_itself, sizeof(BitMap));
+       return PyString_FromStringAndSize((char *)self->ob_itself, sizeof(BitMap));
 }
 
 #define BMObj_set_bitmap_data NULL
 
 static PyObject *BMObj_get_pixmap_data(BitMapObject *self, void *closure)
 {
-       return PyBytes_FromStringAndSize((char *)self->ob_itself, sizeof(PixMap));
+       return PyString_FromStringAndSize((char *)self->ob_itself, sizeof(PixMap));
 }
 
 #define BMObj_set_pixmap_data NULL
@@ -6501,10 +6501,10 @@ static PyObject *Qd_BitMap(PyObject *_self, PyObject *_args)
        int rowbytes;
        char *data;
 
-       if ( !PyArg_ParseTuple(_args, "O!iO&", &PyBytes_Type, &source, &rowbytes, PyMac_GetRect,
+       if ( !PyArg_ParseTuple(_args, "O!iO&", &PyString_Type, &source, &rowbytes, PyMac_GetRect,
                        &bounds) )
                return NULL;
-       data = PyBytes_AsString(source);
+       data = PyString_AsString(source);
        if ((ptr=(BitMap *)malloc(sizeof(BitMap))) == NULL )
                return PyErr_NoMemory();
        ptr->baseAddr = (Ptr)data;
@@ -6528,15 +6528,15 @@ static PyObject *Qd_RawBitMap(PyObject *_self, PyObject *_args)
        BitMap *ptr;
        PyObject *source;
 
-       if ( !PyArg_ParseTuple(_args, "O!", &PyBytes_Type, &source) )
+       if ( !PyArg_ParseTuple(_args, "O!", &PyString_Type, &source) )
                return NULL;
-       if ( PyBytes_Size(source) != sizeof(BitMap) && PyBytes_Size(source) != sizeof(PixMap) ) {
+       if ( PyString_Size(source) != sizeof(BitMap) && PyString_Size(source) != sizeof(PixMap) ) {
                PyErr_Format(PyExc_TypeError,
                        "Argument size was %ld, should be %lu (sizeof BitMap) or %lu (sizeof PixMap)",
-                       PyBytes_Size(source), sizeof(BitMap), sizeof(PixMap));
+                       PyString_Size(source), sizeof(BitMap), sizeof(PixMap));
                return NULL;
        }
-       ptr = (BitMapPtr)PyBytes_AsString(source);
+       ptr = (BitMapPtr)PyString_AsString(source);
        if ( (_res = BMObj_New(ptr)) == NULL ) {
                return NULL;
        }
index 337754adf88c3926a25d9622dd4b9328720d2ee5..b451472ea3949b01eab041a5444e2ea4ce9eaf94 100644 (file)
@@ -609,7 +609,7 @@ static PyObject *Qdoffs_GetPixMapBytes(PyObject *_self, PyObject *_args)
        if ( !PyArg_ParseTuple(_args, "O&ii", ResObj_Convert, &pm, &from, &length) )
                return NULL;
        cp = GetPixBaseAddr(pm)+from;
-       _res = PyBytes_FromStringAndSize(cp, length);
+       _res = PyString_FromStringAndSize(cp, length);
        return _res;
 
 }
index 207037a7d70e49c7866b76cf002180a07cb25725..89fd02c4c6f8f2c5d8959ec9fad640dfa63638e3 100644 (file)
@@ -523,7 +523,7 @@ static PyObject *ResObj_get_data(ResourceObject *self, void *closure)
 
                    state = HGetState(self->ob_itself);
                    HLock(self->ob_itself);
-                   res = PyBytes_FromStringAndSize(
+                   res = PyString_FromStringAndSize(
                            *self->ob_itself,
                            GetHandleSize(self->ob_itself));
                    HUnlock(self->ob_itself);
@@ -540,10 +540,10 @@ static int ResObj_set_data(ResourceObject *self, PyObject *v, void *closure)
 
                    if ( v == NULL )
                            return -1;
-                   if ( !PyBytes_Check(v) )
+                   if ( !PyString_Check(v) )
                            return -1;
-                   size = PyBytes_Size(v);
-                   data = PyBytes_AsString(v);
+                   size = PyString_Size(v);
+                   data = PyString_AsString(v);
                    /* XXXX Do I need the GetState/SetState calls? */
                    SetHandleSize(self->ob_itself, size);
                    if ( MemError())
index f6f4e8c0efa003030a3832f39590f87f26c53fd9..14e3fd24e57ec423f6f75cebf411ba77b7376347 100644 (file)
@@ -106,12 +106,12 @@ static PyObject *ScrapObj_GetScrapFlavorData(ScrapObject *_self, PyObject *_args
                                  flavorType,
                                  &byteCount);
        if (_err != noErr) return PyMac_Error(_err);
-       _res = PyBytes_FromStringAndSize(NULL, (int)byteCount);
+       _res = PyString_FromStringAndSize(NULL, (int)byteCount);
        if ( _res == NULL ) return NULL;
        _err = GetScrapFlavorData(_self->ob_itself,
                                  flavorType,
                                  &byteCount,
-                                 PyBytes_AS_STRING(_res));
+                                 PyString_AS_STRING(_res));
        if (_err != noErr) {
                Py_XDECREF(_res);
                return PyMac_Error(_err);
index 582cf741b366c5dfddd54102f3232977c4a85558..74cad9be56d7c3f3fdc985eab4a803bbae081b7e 100644 (file)
@@ -500,7 +500,7 @@ init_Sndihooks()
 
        /* Add some symbolic constants to the module */
        d = PyModule_GetDict(m);
-       ErrorObject = PyBytes_FromString("Sndihooks.error");
+       ErrorObject = PyString_FromString("Sndihooks.error");
        PyDict_SetItemString(d, "error", ErrorObject);
 
        /* XXXX Add constants here */
index 1562a38433299fbd3f0aab46a906767d46b7e889..87f7591ed0fa7e3b2a7b1c272064f8df8be2047b 100644 (file)
@@ -2580,7 +2580,7 @@ static PyObject * WinObj_repr(WindowObject *self)
 {
        char buf[100];
        sprintf(buf, "<Window object at 0x%8.8x for 0x%8.8x>", (unsigned)self, (unsigned)self->ob_itself);
-       return PyBytes_FromString(buf);
+       return PyString_FromString(buf);
 }
 
 static int WinObj_hash(WindowObject *self)
index 98ccb14ea91040d95380707bf49a8cd3f239b359..94e937c4b833c935fa2008616c5b7951ce7a9036 100644 (file)
@@ -584,7 +584,6 @@ PYTHON_HEADERS= \
                Include/bitset.h \
                Include/boolobject.h \
                Include/bytes_methods.h \
-               Include/bytearrayobject.h \
                Include/bytesobject.h \
                Include/bufferobject.h \
                Include/cellobject.h \
index 88511c6fe5358e9779786b8ba48b7be480c29a0d..8c5bb82de326bf3c3b00876ca715c236648e2b12 100644 (file)
@@ -175,7 +175,7 @@ static PyObject *
 bytesio_getvalue(BytesIOObject *self)
 {
     CHECK_CLOSED(self);
-    return PyBytes_FromStringAndSize(self->buf, self->string_size);
+    return PyString_FromStringAndSize(self->buf, self->string_size);
 }
 
 PyDoc_STRVAR(isatty_doc,
@@ -244,7 +244,7 @@ bytesio_read(BytesIOObject *self, PyObject *args)
     output = self->buf + self->pos;
     self->pos += size;
 
-    return PyBytes_FromStringAndSize(output, size);
+    return PyString_FromStringAndSize(output, size);
 }
 
 
@@ -307,7 +307,7 @@ bytesio_readline(BytesIOObject *self, PyObject *args)
         self->pos -= size;
     }
 
-    return PyBytes_FromStringAndSize(output, n);
+    return PyString_FromStringAndSize(output, n);
 }
 
 PyDoc_STRVAR(readlines_doc,
@@ -349,7 +349,7 @@ bytesio_readlines(BytesIOObject *self, PyObject *args)
         return NULL;
 
     while ((n = get_line(self, &output)) != 0) {
-        line = PyBytes_FromStringAndSize(output, n);
+        line = PyString_FromStringAndSize(output, n);
         if (!line)
             goto on_error;
         if (PyList_Append(result, line) == -1) {
@@ -455,7 +455,7 @@ bytesio_iternext(BytesIOObject *self)
     if (!next || n == 0)
         return NULL;
 
-    return PyBytes_FromStringAndSize(next, n);
+    return PyString_FromStringAndSize(next, n);
 }
 
 PyDoc_STRVAR(seek_doc,
index e374766727d2045474d112b0012f2ec03aa2e4d6..d4eb0d5b9c0026cb5c8409ed9e7bd7087d153b03 100644 (file)
@@ -168,7 +168,7 @@ escape_decode(PyObject *self,
     if (!PyArg_ParseTuple(args, "s#|z:escape_decode",
                          &data, &size, &errors))
        return NULL;
-    return codec_tuple(PyBytes_DecodeEscape(data, size, errors, 0, NULL),
+    return codec_tuple(PyString_DecodeEscape(data, size, errors, 0, NULL),
                       size);
 }
 
@@ -182,21 +182,21 @@ escape_encode(PyObject *self,
        Py_ssize_t len;
 
        if (!PyArg_ParseTuple(args, "O!|z:escape_encode",
-                             &PyBytes_Type, &str, &errors))
+                             &PyString_Type, &str, &errors))
                return NULL;
 
-       str = PyBytes_Repr(str, 0);
+       str = PyString_Repr(str, 0);
        if (!str)
                return NULL;
 
        /* The string will be quoted. Unquote, similar to unicode-escape. */
-       buf = PyBytes_AS_STRING (str);
-       len = PyBytes_GET_SIZE (str);
+       buf = PyString_AS_STRING (str);
+       len = PyString_GET_SIZE (str);
        memmove(buf, buf+1, len-2);
-       if (_PyBytes_Resize(&str, len-2) < 0)
+       if (_PyString_Resize(&str, len-2) < 0)
                return NULL;
        
-       return codec_tuple(str, PyBytes_Size(str));
+       return codec_tuple(str, PyString_Size(str));
 }
 
 #ifdef Py_USING_UNICODE
@@ -640,7 +640,7 @@ readbuffer_encode(PyObject *self,
                          &data, &size, &errors))
        return NULL;
 
-    return codec_tuple(PyBytes_FromStringAndSize(data, size),
+    return codec_tuple(PyString_FromStringAndSize(data, size),
                       size);
 }
 
@@ -656,7 +656,7 @@ charbuffer_encode(PyObject *self,
                          &data, &size, &errors))
        return NULL;
 
-    return codec_tuple(PyBytes_FromStringAndSize(data, size),
+    return codec_tuple(PyString_FromStringAndSize(data, size),
                       size);
 }
 
@@ -676,13 +676,13 @@ unicode_internal_encode(PyObject *self,
     if (PyUnicode_Check(obj)) {
        data = PyUnicode_AS_DATA(obj);
        size = PyUnicode_GET_DATA_SIZE(obj);
-       return codec_tuple(PyBytes_FromStringAndSize(data, size),
+       return codec_tuple(PyString_FromStringAndSize(data, size),
                           size);
     }
     else {
        if (PyObject_AsReadBuffer(obj, (const void **)&data, &size))
            return NULL;
-       return codec_tuple(PyBytes_FromStringAndSize(data, size),
+       return codec_tuple(PyString_FromStringAndSize(data, size),
                           size);
     }
 }
index f7d8d771c58dd7a42cf5e493ffb0006ef3c89785..67700de72858f80225b145be00c2b76668b41d10 100644 (file)
@@ -668,7 +668,7 @@ deque_repr(PyObject *deque)
        if (i != 0) {
                if (i < 0)
                        return NULL;
-               return PyBytes_FromString("[...]");
+               return PyString_FromString("[...]");
        }
 
        aslist = PySequence_List(deque);
@@ -677,16 +677,16 @@ deque_repr(PyObject *deque)
                return NULL;
        }
        if (((dequeobject *)deque)->maxlen != -1)
-               fmt = PyBytes_FromFormat("deque(%%r, maxlen=%i)", 
+               fmt = PyString_FromFormat("deque(%%r, maxlen=%i)", 
                                        ((dequeobject *)deque)->maxlen);
        else
-               fmt = PyBytes_FromString("deque(%r)");  
+               fmt = PyString_FromString("deque(%r)");  
        if (fmt == NULL) {
                Py_DECREF(aslist);
                Py_ReprLeave(deque);
                return NULL;
        }
-       result = PyBytes_Format(fmt, aslist);
+       result = PyString_Format(fmt, aslist);
        Py_DECREF(fmt);
        Py_DECREF(aslist);
        Py_ReprLeave(deque);
@@ -1298,14 +1298,14 @@ defdict_repr(defdictobject *dd)
        if (baserepr == NULL)
                return NULL;
        if (dd->default_factory == NULL)
-               defrepr = PyBytes_FromString("None");
+               defrepr = PyString_FromString("None");
        else
        {
                int status = Py_ReprEnter(dd->default_factory);
                if (status != 0) {
                        if (status < 0)
                                return NULL;
-                       defrepr = PyBytes_FromString("...");
+                       defrepr = PyString_FromString("...");
                }
                else
                        defrepr = PyObject_Repr(dd->default_factory);
@@ -1315,9 +1315,9 @@ defdict_repr(defdictobject *dd)
                Py_DECREF(baserepr);
                return NULL;
        }
-       result = PyBytes_FromFormat("defaultdict(%s, %s)",
-                                    PyBytes_AS_STRING(defrepr),
-                                    PyBytes_AS_STRING(baserepr));
+       result = PyString_FromFormat("defaultdict(%s, %s)",
+                                    PyString_AS_STRING(defrepr),
+                                    PyString_AS_STRING(baserepr));
        Py_DECREF(defrepr);
        Py_DECREF(baserepr);
        return result;
index ba9057afc0acdc01295515dec7513c4fa7b426cb..c628927b53a29456b6e1cc250962058d63d88f56 100644 (file)
@@ -176,7 +176,7 @@ get_nullchar_as_None(char c)
                 return Py_None;
         }
         else
-                return PyBytes_FromStringAndSize((char*)&c, 1);
+                return PyString_FromStringAndSize((char*)&c, 1);
 }
 
 static PyObject *
@@ -235,16 +235,16 @@ _set_char(const char *name, char *target, PyObject *src, char dflt)
        if (src == NULL)
                *target = dflt;
        else {
-               if (src == Py_None || PyBytes_Size(src) == 0)
+               if (src == Py_None || PyString_Size(src) == 0)
                        *target = '\0';
-               else if (!PyBytes_Check(src) || PyBytes_Size(src) != 1) {
+               else if (!PyString_Check(src) || PyString_Size(src) != 1) {
                        PyErr_Format(PyExc_TypeError, 
                                     "\"%s\" must be an 1-character string", 
                                     name);
                        return -1;
                }
                else {
-                       char *s = PyBytes_AsString(src);
+                       char *s = PyString_AsString(src);
                        if (s == NULL)
                                return -1;
                        *target = s[0];
@@ -257,7 +257,7 @@ static int
 _set_str(const char *name, PyObject **target, PyObject *src, const char *dflt)
 {
        if (src == NULL)
-               *target = PyBytes_FromString(dflt);
+               *target = PyString_FromString(dflt);
        else {
                if (src == Py_None)
                        *target = NULL;
@@ -528,7 +528,7 @@ parse_save_field(ReaderObj *self)
 {
        PyObject *field;
 
-       field = PyBytes_FromStringAndSize(self->field, self->field_len);
+       field = PyString_FromStringAndSize(self->field, self->field_len);
        if (field == NULL)
                return -1;
        self->field_len = 0;
@@ -787,8 +787,8 @@ Reader_iternext(ReaderObj *self)
                 }
                ++self->line_num;
 
-                line = PyBytes_AsString(lineobj);
-               linelen = PyBytes_Size(lineobj);
+                line = PyString_AsString(lineobj);
+               linelen = PyString_Size(lineobj);
 
                 if (line == NULL || linelen < 0) {
                         Py_DECREF(lineobj);
@@ -976,7 +976,7 @@ join_append_data(WriterObj *self, char *field, int quote_empty,
                rec_len++;\
        } while(0)
 
-       lineterm = PyBytes_AsString(dialect->lineterminator);
+       lineterm = PyString_AsString(dialect->lineterminator);
        if (lineterm == NULL)
                return -1;
 
@@ -1101,7 +1101,7 @@ join_append_lineterminator(WriterObj *self)
        int terminator_len;
        char *terminator;
 
-       terminator_len = PyBytes_Size(self->dialect->lineterminator);
+       terminator_len = PyString_Size(self->dialect->lineterminator);
        if (terminator_len == -1)
                return 0;
 
@@ -1109,7 +1109,7 @@ join_append_lineterminator(WriterObj *self)
        if (!join_check_rec_size(self, self->rec_len + terminator_len))
                return 0;
 
-       terminator = PyBytes_AsString(self->dialect->lineterminator); 
+       terminator = PyString_AsString(self->dialect->lineterminator); 
        if (terminator == NULL)
                return 0;
        memmove(self->rec + self->rec_len, terminator, terminator_len);
@@ -1161,9 +1161,9 @@ csv_writerow(WriterObj *self, PyObject *seq)
                        break;
                }
 
-               if (PyBytes_Check(field)) {
+               if (PyString_Check(field)) {
                        append_ok = join_append(self,
-                                               PyBytes_AS_STRING(field),
+                                               PyString_AS_STRING(field),
                                                 &quoted, len == 1);
                        Py_DECREF(field);
                }
@@ -1179,7 +1179,7 @@ csv_writerow(WriterObj *self, PyObject *seq)
                        if (str == NULL)
                                return NULL;
 
-                       append_ok = join_append(self, PyBytes_AS_STRING(str), 
+                       append_ok = join_append(self, PyString_AS_STRING(str), 
                                                 &quoted, len == 1);
                        Py_DECREF(str);
                }
index 18851fd1f99a12e8b0ce442a25cbf52a5222a884..73542c7a0417d9d9a2224764b8bbbd9f796ab3c4 100644 (file)
@@ -714,8 +714,8 @@ StructType_setattro(PyObject *self, PyObject *key, PyObject *value)
        if (-1 == PyType_Type.tp_setattro(self, key, value))
                return -1;
        
-       if (value && PyBytes_Check(key) &&
-           0 == strcmp(PyBytes_AS_STRING(key), "_fields_"))
+       if (value && PyString_Check(key) &&
+           0 == strcmp(PyString_AS_STRING(key), "_fields_"))
                return StructUnionType_update_stgdict(self, value, 1);
        return 0;
 }
@@ -728,8 +728,8 @@ UnionType_setattro(PyObject *self, PyObject *key, PyObject *value)
        if (-1 == PyObject_GenericSetAttr(self, key, value))
                return -1;
        
-       if (PyBytes_Check(key) &&
-           0 == strcmp(PyBytes_AS_STRING(key), "_fields_"))
+       if (PyString_Check(key) &&
+           0 == strcmp(PyString_AS_STRING(key), "_fields_"))
                return StructUnionType_update_stgdict(self, value, 0);
        return 0;
 }
@@ -1065,7 +1065,7 @@ CharArray_set_raw(CDataObject *self, PyObject *value)
                size = Py_TYPE(value)->tp_as_buffer->bf_getreadbuffer(value, 0, (void *)&ptr);
                if (size < 0)
                        return -1;
-       } else if (-1 == PyBytes_AsStringAndSize(value, &ptr, &size)) {
+       } else if (-1 == PyString_AsStringAndSize(value, &ptr, &size)) {
                return -1;
        }
        if (size > self->b_size) {
@@ -1082,7 +1082,7 @@ CharArray_set_raw(CDataObject *self, PyObject *value)
 static PyObject *
 CharArray_get_raw(CDataObject *self)
 {
-       return PyBytes_FromStringAndSize(self->b_ptr, self->b_size);
+       return PyString_FromStringAndSize(self->b_ptr, self->b_size);
 }
 
 static PyObject *
@@ -1093,7 +1093,7 @@ CharArray_get_value(CDataObject *self)
        for (i = 0; i < self->b_size; ++i)
                if (*ptr++ == '\0')
                        break;
-       return PyBytes_FromStringAndSize(self->b_ptr, i);
+       return PyString_FromStringAndSize(self->b_ptr, i);
 }
 
 static int
@@ -1114,14 +1114,14 @@ CharArray_set_value(CDataObject *self, PyObject *value)
                                                  conversion_mode_errors);
                if (!value)
                        return -1;
-       } else if (!PyBytes_Check(value)) {
+       } else if (!PyString_Check(value)) {
                PyErr_Format(PyExc_TypeError,
                             "string expected instead of %s instance",
                             Py_TYPE(value)->tp_name);
                return -1;
        } else
                Py_INCREF(value);
-       size = PyBytes_GET_SIZE(value);
+       size = PyString_GET_SIZE(value);
        if (size > self->b_size) {
                PyErr_SetString(PyExc_ValueError,
                                "string too long");
@@ -1129,7 +1129,7 @@ CharArray_set_value(CDataObject *self, PyObject *value)
                return -1;
        }
 
-       ptr = PyBytes_AS_STRING(value);
+       ptr = PyString_AS_STRING(value);
        memcpy(self->b_ptr, ptr, size);
        if (size < self->b_size)
                self->b_ptr[size] = '\0';
@@ -1168,7 +1168,7 @@ WCharArray_set_value(CDataObject *self, PyObject *value)
                                "can't delete attribute");
                return -1;
        }
-       if (PyBytes_Check(value)) {
+       if (PyString_Check(value)) {
                value = PyUnicode_FromEncodedObject(value,
                                                    conversion_mode_encoding,
                                                    conversion_mode_errors);
@@ -1465,7 +1465,7 @@ c_wchar_p_from_param(PyObject *type, PyObject *value)
                Py_INCREF(Py_None);
                return Py_None;
        }
-       if (PyUnicode_Check(value) || PyBytes_Check(value)) {
+       if (PyUnicode_Check(value) || PyString_Check(value)) {
                PyCArgObject *parg;
                struct fielddesc *fd = getentry("Z");
 
@@ -1529,7 +1529,7 @@ c_char_p_from_param(PyObject *type, PyObject *value)
                Py_INCREF(Py_None);
                return Py_None;
        }
-       if (PyBytes_Check(value) || PyUnicode_Check(value)) {
+       if (PyString_Check(value) || PyUnicode_Check(value)) {
                PyCArgObject *parg;
                struct fielddesc *fd = getentry("z");
 
@@ -1615,7 +1615,7 @@ c_void_p_from_param(PyObject *type, PyObject *value)
                return (PyObject *)parg;
        }
 /* string */
-       if (PyBytes_Check(value)) {
+       if (PyString_Check(value)) {
                PyCArgObject *parg;
                struct fielddesc *fd = getentry("z");
 
@@ -1686,10 +1686,10 @@ c_void_p_from_param(PyObject *type, PyObject *value)
        }
 /* c_char_p, c_wchar_p */
        stgd = PyObject_stgdict(value);
-       if (stgd && CDataObject_Check(value) && stgd->proto && PyBytes_Check(stgd->proto)) {
+       if (stgd && CDataObject_Check(value) && stgd->proto && PyString_Check(stgd->proto)) {
                PyCArgObject *parg;
 
-               switch (PyBytes_AS_STRING(stgd->proto)[0]) {
+               switch (PyString_AS_STRING(stgd->proto)[0]) {
                case 'z': /* c_char_p */
                case 'Z': /* c_wchar_p */
                        parg = new_CArgObject();
@@ -1746,13 +1746,13 @@ static PyObject *CreateSwappedType(PyTypeObject *type, PyObject *args, PyObject
 
        if (suffix == NULL)
 #ifdef WORDS_BIGENDIAN
-               suffix = PyBytes_InternFromString("_le");
+               suffix = PyString_InternFromString("_le");
 #else
-               suffix = PyBytes_InternFromString("_be");
+               suffix = PyString_InternFromString("_be");
 #endif
 
        Py_INCREF(name);
-       PyBytes_Concat(&name, suffix);
+       PyString_Concat(&name, suffix);
        if (name == NULL)
                return NULL;
 
@@ -1807,7 +1807,7 @@ SimpleType_paramfunc(CDataObject *self)
        
        dict = PyObject_stgdict((PyObject *)self);
        assert(dict); /* Cannot be NULL for CDataObject instances */
-       fmt = PyBytes_AsString(dict->proto);
+       fmt = PyString_AsString(dict->proto);
        assert(fmt);
 
        fd = getentry(fmt);
@@ -1872,12 +1872,12 @@ SimpleType_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
                             SIMPLE_TYPE_CHARS);
                goto error;
        }
-       fmt = getentry(PyBytes_AS_STRING(proto));
+       fmt = getentry(PyString_AS_STRING(proto));
        if (fmt == NULL) {
                Py_DECREF(result);
                PyErr_Format(PyExc_ValueError,
                             "_type_ '%s' not supported",
-                            PyBytes_AS_STRING(proto));
+                            PyString_AS_STRING(proto));
                return NULL;
        }
 
@@ -1927,7 +1927,7 @@ SimpleType_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
           Overrides the SimpleType_from_param generic method.
         */
        if (result->tp_base == &Simple_Type) {
-               switch (PyBytes_AS_STRING(proto)[0]) {
+               switch (PyString_AS_STRING(proto)[0]) {
                case 'z': /* c_char_p */
                        ml = &c_char_p_method;
                        stgdict->flags |= TYPEFLAG_ISPOINTER;
@@ -2042,7 +2042,7 @@ SimpleType_from_param(PyObject *type, PyObject *value)
        assert(dict);
 
        /* I think we can rely on this being a one-character string */
-       fmt = PyBytes_AsString(dict->proto);
+       fmt = PyString_AsString(dict->proto);
        assert(fmt);
        
        fd = getentry(fmt);
@@ -2399,7 +2399,7 @@ unique_key(CDataObject *target, Py_ssize_t index)
 #endif
                target = target->b_base;
        }
-       return PyBytes_FromStringAndSize(string, cp-string);
+       return PyString_FromStringAndSize(string, cp-string);
 }
 
 /*
@@ -2571,7 +2571,7 @@ CData_reduce(PyObject *_self, PyObject *args)
                             _unpickle,
                             Py_TYPE(_self),
                             PyObject_GetAttrString(_self, "__dict__"),
-                            PyBytes_FromStringAndSize(self->b_ptr, self->b_size));
+                            PyString_FromStringAndSize(self->b_ptr, self->b_size));
 }
 
 static PyObject *
@@ -3120,9 +3120,9 @@ _check_outarg_type(PyObject *arg, Py_ssize_t index)
        dict = PyType_stgdict(arg);
        if (dict
            /* simple pointer types, c_void_p, c_wchar_p, BSTR, ... */
-           && PyBytes_Check(dict->proto)
+           && PyString_Check(dict->proto)
 /* We only allow c_void_p, c_char_p and c_wchar_p as a simple output parameter type */
-           && (strchr("PzZ", PyBytes_AS_STRING(dict->proto)[0]))) {
+           && (strchr("PzZ", PyString_AS_STRING(dict->proto)[0]))) {
                return 1;
        }
 
@@ -3207,8 +3207,8 @@ _get_name(PyObject *obj, char **pname)
                return 1;
        }
 #endif
-       if (PyBytes_Check(obj) || PyUnicode_Check(obj)) {
-               *pname = PyBytes_AsString(obj);
+       if (PyString_Check(obj) || PyUnicode_Check(obj)) {
+               *pname = PyString_AsString(obj);
                return *pname ? 1 : 0;
        }
        PyErr_SetString(PyExc_TypeError,
@@ -3558,7 +3558,7 @@ _build_callargs(CFuncPtrObject *self, PyObject *argtypes,
                /* We HAVE already checked that the tuple can be parsed with "i|zO", so... */
                Py_ssize_t tsize = PyTuple_GET_SIZE(item);
                flag = PyInt_AS_LONG(PyTuple_GET_ITEM(item, 0));
-               name = tsize > 1 ? PyBytes_AS_STRING(PyTuple_GET_ITEM(item, 1)) : NULL;
+               name = tsize > 1 ? PyString_AS_STRING(PyTuple_GET_ITEM(item, 1)) : NULL;
                defval = tsize > 2 ? PyTuple_GET_ITEM(item, 2) : NULL;
 
                switch (flag & (PARAMFLAG_FIN | PARAMFLAG_FOUT | PARAMFLAG_FLCID)) {
@@ -3612,7 +3612,7 @@ _build_callargs(CFuncPtrObject *self, PyObject *argtypes,
                                             "NULL stgdict unexpected");
                                goto error;
                        }
-                       if (PyBytes_Check(dict->proto)) {
+                       if (PyString_Check(dict->proto)) {
                                PyErr_Format(
                                        PyExc_TypeError,
                                        "%s 'out' parameter must be passed as default value",
@@ -3910,12 +3910,12 @@ CFuncPtr_repr(CFuncPtrObject *self)
 {
 #ifdef MS_WIN32
        if (self->index)
-               return PyBytes_FromFormat("<COM method offset %d: %s at %p>",
+               return PyString_FromFormat("<COM method offset %d: %s at %p>",
                                           self->index - 0x1000,
                                           Py_TYPE(self)->tp_name,
                                           self);
 #endif
-       return PyBytes_FromFormat("<%s object at %p>",
+       return PyString_FromFormat("<%s object at %p>",
                                   Py_TYPE(self)->tp_name,
                                   self);
 }
@@ -4044,7 +4044,7 @@ Struct_init(PyObject *self, PyObject *args, PyObject *kwds)
                        }
 
                        if (kwds && PyDict_GetItem(kwds, name)) {
-                               char *field = PyBytes_AsString(name);
+                               char *field = PyString_AsString(name);
                                if (field == NULL) {
                                        PyErr_Clear();
                                        field = "???";
@@ -4246,7 +4246,7 @@ Array_slice(PyObject *_self, Py_ssize_t ilow, Py_ssize_t ihigh)
                             type, so this cannot be NULL */
        if (itemdict->getfunc == getentry("c")->getfunc) {
                char *ptr = (char *)self->b_ptr;
-               return PyBytes_FromStringAndSize(ptr + ilow, len);
+               return PyString_FromStringAndSize(ptr + ilow, len);
 #ifdef CTYPES_UNICODE
        } else if (itemdict->getfunc == getentry("u")->getfunc) {
                wchar_t *ptr = (wchar_t *)self->b_ptr;
@@ -4303,9 +4303,9 @@ Array_subscript(PyObject *_self, PyObject *item)
                        char *dest;
 
                        if (slicelen <= 0)
-                               return PyBytes_FromString("");
+                               return PyString_FromString("");
                        if (step == 1) {
-                               return PyBytes_FromStringAndSize(ptr + start,
+                               return PyString_FromStringAndSize(ptr + start,
                                                                  slicelen);
                        }
                        dest = (char *)PyMem_Malloc(slicelen);
@@ -4318,7 +4318,7 @@ Array_subscript(PyObject *_self, PyObject *item)
                                dest[i] = ptr[cur];
                        }
 
-                       np = PyBytes_FromStringAndSize(dest, slicelen);
+                       np = PyString_FromStringAndSize(dest, slicelen);
                        PyMem_Free(dest);
                        return np;
                }
@@ -4728,12 +4728,12 @@ Simple_repr(CDataObject *self)
        static PyObject *format;
 
        if (Py_TYPE(self)->tp_base != &Simple_Type) {
-               return PyBytes_FromFormat("<%s object at %p>",
+               return PyString_FromFormat("<%s object at %p>",
                                           Py_TYPE(self)->tp_name, self);
        }
 
        if (format == NULL) {
-               format = PyBytes_InternFromString("%s(%r)");
+               format = PyString_InternFromString("%s(%r)");
                if (format == NULL)
                        return NULL;
        }
@@ -4742,7 +4742,7 @@ Simple_repr(CDataObject *self)
        if (val == NULL)
                return NULL;
 
-       name = PyBytes_FromString(Py_TYPE(self)->tp_name);
+       name = PyString_FromString(Py_TYPE(self)->tp_name);
        if (name == NULL) {
                Py_DECREF(val);
                return NULL;
@@ -4754,7 +4754,7 @@ Simple_repr(CDataObject *self)
        if (args == NULL)
                return NULL;
 
-       result = PyBytes_Format(format, args);
+       result = PyString_Format(format, args);
        Py_DECREF(args);
        return result;
 }
@@ -4988,7 +4988,7 @@ Pointer_slice(PyObject *_self, Py_ssize_t ilow, Py_ssize_t ihigh)
        assert(itemdict);
        if (itemdict->getfunc == getentry("c")->getfunc) {
                char *ptr = *(char **)self->b_ptr;
-               return PyBytes_FromStringAndSize(ptr + ilow, len);
+               return PyString_FromStringAndSize(ptr + ilow, len);
 #ifdef CTYPES_UNICODE
        } else if (itemdict->getfunc == getentry("u")->getfunc) {
                wchar_t *ptr = *(wchar_t **)self->b_ptr;
@@ -5085,9 +5085,9 @@ Pointer_subscript(PyObject *_self, PyObject *item)
                        char *dest;
                        
                        if (len <= 0)
-                               return PyBytes_FromString("");
+                               return PyString_FromString("");
                        if (step == 1) {
-                               return PyBytes_FromStringAndSize(ptr + start,
+                               return PyString_FromStringAndSize(ptr + start,
                                                                  len);
                        }
                        dest = (char *)PyMem_Malloc(len);
@@ -5096,7 +5096,7 @@ Pointer_subscript(PyObject *_self, PyObject *item)
                        for (cur = start, i = 0; i < len; cur += step, i++) {
                                dest[i] = ptr[cur];
                        }
-                       np = PyBytes_FromStringAndSize(dest, len);
+                       np = PyString_FromStringAndSize(dest, len);
                        PyMem_Free(dest);
                        return np;
                }
@@ -5276,7 +5276,7 @@ create_comerror(void)
                ++methods;
        }
 
-       s = PyBytes_FromString(comerror_doc);
+       s = PyString_FromString(comerror_doc);
        if (s == NULL)
                goto error;
        status = PyDict_SetItemString(dict, "__doc__", s);
@@ -5302,8 +5302,8 @@ static PyObject *
 string_at(const char *ptr, int size)
 {
        if (size == -1)
-               return PyBytes_FromString(ptr);
-       return PyBytes_FromStringAndSize(ptr, size);
+               return PyString_FromString(ptr);
+       return PyString_FromStringAndSize(ptr, size);
 }
 
 static int
@@ -5317,8 +5317,8 @@ cast_check_pointertype(PyObject *arg)
                return 1;
        dict = PyType_stgdict(arg);
        if (dict) {
-               if (PyBytes_Check(dict->proto)
-                   && (strchr("sPzUZXO", PyBytes_AS_STRING(dict->proto)[0]))) {
+               if (PyString_Check(dict->proto)
+                   && (strchr("sPzUZXO", PyString_AS_STRING(dict->proto)[0]))) {
                        /* simple pointer types, c_void_p, c_wchar_p, BSTR, ... */
                        return 1;
                }
index aa021545f88f41294201ebfd9faadd8cce1c1f10..0f8c8fa966da88cbf4b7209536e66529b63e01a5 100644 (file)
@@ -107,15 +107,15 @@ void _AddTraceback(char *funcname, char *filename, int lineno)
        PyCodeObject *py_code = 0;
        PyFrameObject *py_frame = 0;
     
-       py_srcfile = PyBytes_FromString(filename);
+       py_srcfile = PyString_FromString(filename);
        if (!py_srcfile) goto bad;
-       py_funcname = PyBytes_FromString(funcname);
+       py_funcname = PyString_FromString(funcname);
        if (!py_funcname) goto bad;
        py_globals = PyDict_New();
        if (!py_globals) goto bad;
        empty_tuple = PyTuple_New(0);
        if (!empty_tuple) goto bad;
-       empty_string = PyBytes_FromString("");
+       empty_string = PyString_FromString("");
        if (!empty_string) goto bad;
        py_code = PyCode_New(
                0,            /*int argcount,*/
@@ -498,7 +498,7 @@ long Call_GetClassObject(REFCLSID rclsid, REFIID riid, LPVOID *ppv)
        static PyObject *context;
 
        if (context == NULL)
-               context = PyBytes_InternFromString("_ctypes.DllGetClassObject");
+               context = PyString_InternFromString("_ctypes.DllGetClassObject");
 
        mod = PyImport_ImportModuleNoBlock("ctypes");
        if (!mod) {
@@ -577,7 +577,7 @@ long Call_CanUnloadNow(void)
        static PyObject *context;
 
        if (context == NULL)
-               context = PyBytes_InternFromString("_ctypes.DllCanUnloadNow");
+               context = PyString_InternFromString("_ctypes.DllCanUnloadNow");
 
        mod = PyImport_ImportModuleNoBlock("ctypes");
        if (!mod) {
index 12b0d7a41063537c145d393d817458cc849f3a9e..825a2c742344d70eb9429db7e67d423330a25a5d 100644 (file)
@@ -498,7 +498,7 @@ PyCArg_repr(PyCArgObject *self)
                        self->tag, self);
                break;
        }
-       return PyBytes_FromString(buffer);
+       return PyString_FromString(buffer);
 }
 
 static PyMemberDef PyCArgType_members[] = {
@@ -646,9 +646,9 @@ static int ConvParam(PyObject *obj, Py_ssize_t index, struct argument *pa)
                return 0;
        }
 
-       if (PyBytes_Check(obj)) {
+       if (PyString_Check(obj)) {
                pa->ffi_type = &ffi_type_pointer;
-               pa->value.p = PyBytes_AS_STRING(obj);
+               pa->value.p = PyString_AS_STRING(obj);
                Py_INCREF(obj);
                pa->keep = obj;
                return 0;
@@ -937,7 +937,7 @@ void Extend_Error_Info(PyObject *exc_class, char *fmt, ...)
        PyObject *tp, *v, *tb, *s, *cls_str, *msg_str;
 
        va_start(vargs, fmt);
-       s = PyBytes_FromFormatV(fmt, vargs);
+       s = PyString_FromFormatV(fmt, vargs);
        va_end(vargs);
        if (!s)
                return;
@@ -946,18 +946,18 @@ void Extend_Error_Info(PyObject *exc_class, char *fmt, ...)
        PyErr_NormalizeException(&tp, &v, &tb);
        cls_str = PyObject_Str(tp);
        if (cls_str) {
-               PyBytes_ConcatAndDel(&s, cls_str);
-               PyBytes_ConcatAndDel(&s, PyBytes_FromString(": "));
+               PyString_ConcatAndDel(&s, cls_str);
+               PyString_ConcatAndDel(&s, PyString_FromString(": "));
                if (s == NULL)
                        goto error;
        } else
                PyErr_Clear();
        msg_str = PyObject_Str(v);
        if (msg_str)
-               PyBytes_ConcatAndDel(&s, msg_str);
+               PyString_ConcatAndDel(&s, msg_str);
        else {
                PyErr_Clear();
-               PyBytes_ConcatAndDel(&s, PyBytes_FromString("???"));
+               PyString_ConcatAndDel(&s, PyString_FromString("???"));
                if (s == NULL)
                        goto error;
        }
@@ -1261,7 +1261,7 @@ static PyObject *load_library(PyObject *self, PyObject *args)
        if (!PyArg_ParseTuple(args, "O|O:LoadLibrary", &nameobj, &ignored))
                return NULL;
 #ifdef _UNICODE
-       name = alloca((PyBytes_Size(nameobj) + 1) * sizeof(WCHAR));
+       name = alloca((PyString_Size(nameobj) + 1) * sizeof(WCHAR));
        if (!name) {
                PyErr_NoMemory();
                return NULL;
@@ -1269,14 +1269,14 @@ static PyObject *load_library(PyObject *self, PyObject *args)
 
        {
                int r;
-               char *aname = PyBytes_AsString(nameobj);
+               char *aname = PyString_AsString(nameobj);
                if(!aname)
                        return NULL;
-               r = MultiByteToWideChar(CP_ACP, 0, aname, -1, name, PyBytes_Size(nameobj) + 1);
+               r = MultiByteToWideChar(CP_ACP, 0, aname, -1, name, PyString_Size(nameobj) + 1);
                name[r] = 0;
        }
 #else
-       name = PyBytes_AsString(nameobj);
+       name = PyString_AsString(nameobj);
        if(!name)
                return NULL;
 #endif
@@ -1769,9 +1769,9 @@ POINTER(PyObject *self, PyObject *cls)
                Py_INCREF(result);
                return result;
        }
-       if (PyBytes_CheckExact(cls)) {
-               buf = alloca(strlen(PyBytes_AS_STRING(cls)) + 3 + 1);
-               sprintf(buf, "LP_%s", PyBytes_AS_STRING(cls));
+       if (PyString_CheckExact(cls)) {
+               buf = alloca(strlen(PyString_AS_STRING(cls)) + 3 + 1);
+               sprintf(buf, "LP_%s", PyString_AS_STRING(cls));
                result = PyObject_CallFunction((PyObject *)Py_TYPE(&Pointer_Type),
                                               "s(O){}",
                                               buf,
index 5105493cb6ee18d1e745af5296751f916cde82fd..ba837ecca37958156950ce85c53d499273a7dd34 100644 (file)
@@ -272,7 +272,7 @@ CField_repr(CFieldObject *self)
        name = ((PyTypeObject *)self->proto)->tp_name;
 
        if (bits)
-               result = PyBytes_FromFormat(
+               result = PyString_FromFormat(
 #if (PY_VERSION_HEX < 0x02050000)
                        "<Field type=%s, ofs=%d:%d, bits=%d>",
 #else
@@ -280,7 +280,7 @@ CField_repr(CFieldObject *self)
 #endif
                        name, self->offset, size, bits);
        else
-               result = PyBytes_FromFormat(
+               result = PyString_FromFormat(
 #if (PY_VERSION_HEX < 0x02050000)
                        "<Field type=%s, ofs=%d, size=%d>",
 #else
@@ -1164,12 +1164,12 @@ O_set(void *ptr, PyObject *value, Py_ssize_t size)
 static PyObject *
 c_set(void *ptr, PyObject *value, Py_ssize_t size)
 {
-       if (!PyBytes_Check(value) || (1 != PyBytes_Size(value))) {
+       if (!PyString_Check(value) || (1 != PyString_Size(value))) {
                PyErr_Format(PyExc_TypeError,
                             "one character string expected");
                return NULL;
        }
-       *(char *)ptr = PyBytes_AS_STRING(value)[0];
+       *(char *)ptr = PyString_AS_STRING(value)[0];
        _RET(value);
 }
 
@@ -1177,7 +1177,7 @@ c_set(void *ptr, PyObject *value, Py_ssize_t size)
 static PyObject *
 c_get(void *ptr, Py_ssize_t size)
 {
-       return PyBytes_FromStringAndSize((char *)ptr, 1);
+       return PyString_FromStringAndSize((char *)ptr, 1);
 }
 
 #ifdef CTYPES_UNICODE
@@ -1187,7 +1187,7 @@ u_set(void *ptr, PyObject *value, Py_ssize_t size)
 {
        Py_ssize_t len;
 
-       if (PyBytes_Check(value)) {
+       if (PyString_Check(value)) {
                value = PyUnicode_FromEncodedObject(value,
                                                    conversion_mode_encoding,
                                                    conversion_mode_errors);
@@ -1262,7 +1262,7 @@ U_set(void *ptr, PyObject *value, Py_ssize_t length)
        /* It's easier to calculate in characters than in bytes */
        length /= sizeof(wchar_t);
 
-       if (PyBytes_Check(value)) {
+       if (PyString_Check(value)) {
                value = PyUnicode_FromEncodedObject(value,
                                                    conversion_mode_encoding,
                                                    conversion_mode_errors);
@@ -1301,21 +1301,21 @@ s_get(void *ptr, Py_ssize_t size)
        PyObject *result;
        size_t slen;
 
-       result = PyBytes_FromString((char *)ptr);
+       result = PyString_FromString((char *)ptr);
        if (!result)
                return NULL;
        /* chop off at the first NUL character, if any.
         * On error, result will be deallocated and set to NULL.
         */
-       slen = strlen(PyBytes_AS_STRING(result));
+       slen = strlen(PyString_AS_STRING(result));
        size = min(size, (Py_ssize_t)slen);
        if (result->ob_refcnt == 1) {
                /* shorten the result */
-               _PyBytes_Resize(&result, size);
+               _PyString_Resize(&result, size);
                return result;
        } else
                /* cannot shorten the result */
-               return PyBytes_FromStringAndSize(ptr, size);
+               return PyString_FromStringAndSize(ptr, size);
 }
 
 static PyObject *
@@ -1324,7 +1324,7 @@ s_set(void *ptr, PyObject *value, Py_ssize_t length)
        char *data;
        Py_ssize_t size;
 
-       data = PyBytes_AsString(value);
+       data = PyString_AsString(value);
        if (!data)
                return NULL;
        size = strlen(data);
@@ -1356,8 +1356,8 @@ z_set(void *ptr, PyObject *value, Py_ssize_t size)
                Py_INCREF(value);
                return value;
        }
-       if (PyBytes_Check(value)) {
-               *(char **)ptr = PyBytes_AS_STRING(value);
+       if (PyString_Check(value)) {
+               *(char **)ptr = PyString_AS_STRING(value);
                Py_INCREF(value);
                return value;
        } else if (PyUnicode_Check(value)) {
@@ -1366,7 +1366,7 @@ z_set(void *ptr, PyObject *value, Py_ssize_t size)
                                                          conversion_mode_errors);
                if (str == NULL)
                        return NULL;
-               *(char **)ptr = PyBytes_AS_STRING(str);
+               *(char **)ptr = PyString_AS_STRING(str);
                return str;
        } else if (PyInt_Check(value) || PyLong_Check(value)) {
 #if SIZEOF_VOID_P == SIZEOF_LONG_LONG
@@ -1395,7 +1395,7 @@ z_get(void *ptr, Py_ssize_t size)
                        return NULL;
                }
 #endif
-               return PyBytes_FromString(*(char **)ptr);
+               return PyString_FromString(*(char **)ptr);
        } else {
                Py_INCREF(Py_None);
                return Py_None;
@@ -1411,7 +1411,7 @@ Z_set(void *ptr, PyObject *value, Py_ssize_t size)
                Py_INCREF(value);
                return value;
        }
-       if (PyBytes_Check(value)) {
+       if (PyString_Check(value)) {
                value = PyUnicode_FromEncodedObject(value,
                                                    conversion_mode_encoding,
                                                    conversion_mode_errors);
@@ -1502,7 +1502,7 @@ BSTR_set(void *ptr, PyObject *value, Py_ssize_t size)
        /* convert value into a PyUnicodeObject or NULL */
        if (Py_None == value) {
                value = NULL;
-       } else if (PyBytes_Check(value)) {
+       } else if (PyString_Check(value)) {
                value = PyUnicode_FromEncodedObject(value,
                                                    conversion_mode_encoding,
                                                    conversion_mode_errors);
index 6b618ac535f8a6868409bdc6f2279efb081b2bb0..6831473b06f5a30d37ed3b8783e7c1601c38a521 100644 (file)
@@ -472,7 +472,7 @@ init_curses_panel(void)
     PyDict_SetItemString(d, "error", PyCursesError);
 
     /* Make the version available */
-    v = PyBytes_FromString(PyCursesVersion);
+    v = PyString_FromString(PyCursesVersion);
     PyDict_SetItemString(d, "version", v);
     PyDict_SetItemString(d, "__version__", v);
     Py_DECREF(v);
index 964a260bb2a89e6e0dd0dd0e13ea560c9d1c5fd5..137c580731dae9bcc0207f112f160d61979041af 100644 (file)
@@ -198,9 +198,9 @@ PyCurses_ConvertToChtype(PyObject *obj, chtype *ch)
 {
   if (PyInt_Check(obj)) {
     *ch = (chtype) PyInt_AsLong(obj);
-  } else if(PyBytes_Check(obj) 
-           && (PyBytes_Size(obj) == 1)) {
-    *ch = (chtype) *PyBytes_AsString(obj);
+  } else if(PyString_Check(obj) 
+           && (PyString_Size(obj) == 1)) {
+    *ch = (chtype) *PyString_AsString(obj);
   } else {
     return 0;
   }
@@ -886,9 +886,9 @@ PyCursesWindow_GetKey(PyCursesWindowObject *self, PyObject *args)
     return Py_BuildValue("c", rtn);
   else
 #if defined(__NetBSD__)
-    return PyBytes_FromString(unctrl(rtn));
+    return PyString_FromString(unctrl(rtn));
 #else
-    return PyBytes_FromString((char *)keyname(rtn));
+    return PyString_FromString((char *)keyname(rtn));
 #endif
 }
 
@@ -943,7 +943,7 @@ PyCursesWindow_GetStr(PyCursesWindowObject *self, PyObject *args)
   }
   if (rtn2 == ERR)
     rtn[0] = 0;
-  return PyBytes_FromString(rtn);
+  return PyString_FromString(rtn);
 }
 
 static PyObject *
@@ -1095,7 +1095,7 @@ PyCursesWindow_InStr(PyCursesWindowObject *self, PyObject *args)
   }
   if (rtn2 == ERR)
     rtn[0] = 0;
-  return PyBytes_FromString(rtn);
+  return PyString_FromString(rtn);
 }
 
 static PyObject *
@@ -1757,7 +1757,7 @@ PyCurses_EraseChar(PyObject *self)
 
   ch = erasechar();
 
-  return PyBytes_FromStringAndSize(&ch, 1);
+  return PyString_FromStringAndSize(&ch, 1);
 }
 
 static PyObject *
@@ -2114,7 +2114,7 @@ PyCurses_KeyName(PyObject *self, PyObject *args)
   }
   knp = keyname(ch);
 
-  return PyBytes_FromString((knp == NULL) ? "" : (char *)knp);
+  return PyString_FromString((knp == NULL) ? "" : (char *)knp);
 }
 #endif
 
@@ -2125,7 +2125,7 @@ PyCurses_KillChar(PyObject *self)
 
   ch = killchar();  
 
-  return PyBytes_FromStringAndSize(&ch, 1);  
+  return PyString_FromStringAndSize(&ch, 1);  
 }  
 
 static PyObject *
@@ -2496,7 +2496,7 @@ PyCurses_tigetstr(PyObject *self, PyObject *args)
                Py_INCREF(Py_None);
                return Py_None;
        }
-       return PyBytes_FromString( capname );
+       return PyString_FromString( capname );
 }
 
 static PyObject *
@@ -2520,7 +2520,7 @@ PyCurses_tparm(PyObject *self, PyObject *args)
                return NULL;
        }
 
-       return PyBytes_FromString(result);
+       return PyString_FromString(result);
 }
 
 static PyObject *
@@ -2547,14 +2547,14 @@ PyCurses_UnCtrl(PyObject *self, PyObject *args)
 
   if (PyInt_Check(temp))
     ch = (chtype) PyInt_AsLong(temp);
-  else if (PyBytes_Check(temp))
-    ch = (chtype) *PyBytes_AsString(temp);
+  else if (PyString_Check(temp))
+    ch = (chtype) *PyString_AsString(temp);
   else {
     PyErr_SetString(PyExc_TypeError, "argument must be a ch or an int");
     return NULL;
   }
 
-  return PyBytes_FromString(unctrl(ch));
+  return PyString_FromString(unctrl(ch));
 }
 
 static PyObject *
@@ -2569,8 +2569,8 @@ PyCurses_UngetCh(PyObject *self, PyObject *args)
 
   if (PyInt_Check(temp))
     ch = (int) PyInt_AsLong(temp);
-  else if (PyBytes_Check(temp))
-    ch = (int) *PyBytes_AsString(temp);
+  else if (PyString_Check(temp))
+    ch = (int) *PyString_AsString(temp);
   else {
     PyErr_SetString(PyExc_TypeError, "argument must be a ch or an int");
     return NULL;
@@ -2753,7 +2753,7 @@ init_curses(void)
        PyDict_SetItemString(d, "error", PyCursesError);
 
        /* Make the version available */
-       v = PyBytes_FromString(PyCursesVersion);
+       v = PyString_FromString(PyCursesVersion);
        PyDict_SetItemString(d, "version", v);
        PyDict_SetItemString(d, "__version__", v);
        Py_DECREF(v);
index e368b317a09c0749460a80c43d9623edb22a2cdf..684081c7c926db489778003b5975cbfff3fcb32c 100644 (file)
@@ -103,7 +103,7 @@ typedef int Py_ssize_t;
 #define PyDict_CheckExact PyDict_Check
 #if (PY_VERSION_HEX < 0x02020000)
 #define PyList_CheckExact PyList_Check
-#define PyBytes_CheckExact PyBytes_Check
+#define PyString_CheckExact PyString_Check
 #if (PY_VERSION_HEX >= 0x01060000)
 #define Py_USING_UNICODE /* always enabled for 2.0 and 2.1 */
 #endif
@@ -173,7 +173,7 @@ list_join(PyObject* list)
     switch (PyList_GET_SIZE(list)) {
     case 0:
         Py_DECREF(list);
-        return PyBytes_FromString("");
+        return PyString_FromString("");
     case 1:
         result = PyList_GET_ITEM(list, 0);
         Py_INCREF(result);
@@ -748,9 +748,9 @@ checkpath(PyObject* tag)
         return 0;
     }
 #endif
-    if (PyBytes_Check(tag)) {
-        char *p = PyBytes_AS_STRING(tag);
-        for (i = 0; i < PyBytes_GET_SIZE(tag); i++) {
+    if (PyString_Check(tag)) {
+        char *p = PyString_AS_STRING(tag);
+        for (i = 0; i < PyString_GET_SIZE(tag); i++) {
             if (p[i] == '{')
                 check = 0;
             else if (p[i] == '}')
@@ -818,7 +818,7 @@ element_findtext(ElementObject* self, PyObject* args)
         if (Element_CheckExact(item) && !PyObject_Compare(item->tag, tag)) {
             PyObject* text = element_get_text(item);
             if (text == Py_None)
-                return PyBytes_FromString("");
+                return PyString_FromString("");
             Py_XINCREF(text);
             return text;
         }
@@ -1154,12 +1154,12 @@ element_repr(ElementObject* self)
     PyObject* repr;
     char buffer[100];
     
-    repr = PyBytes_FromString("<Element ");
+    repr = PyString_FromString("<Element ");
 
-    PyBytes_ConcatAndDel(&repr, PyObject_Repr(self->tag));
+    PyString_ConcatAndDel(&repr, PyObject_Repr(self->tag));
 
     sprintf(buffer, " at %p>", self);
-    PyBytes_ConcatAndDel(&repr, PyBytes_FromString(buffer));
+    PyString_ConcatAndDel(&repr, PyString_FromString(buffer));
 
     return repr;
 }
@@ -1617,14 +1617,14 @@ treebuilder_handle_data(TreeBuilderObject* self, PyObject* data)
         Py_INCREF(data); self->data = data;
     } else {
         /* more than one item; use a list to collect items */
-        if (PyBytes_CheckExact(self->data) && Py_REFCNT(self->data) == 1 &&
-            PyBytes_CheckExact(data) && PyBytes_GET_SIZE(data) == 1) {
+        if (PyString_CheckExact(self->data) && Py_REFCNT(self->data) == 1 &&
+            PyString_CheckExact(data) && PyString_GET_SIZE(data) == 1) {
             /* expat often generates single character data sections; handle
                the most common case by resizing the existing string... */
-            Py_ssize_t size = PyBytes_GET_SIZE(self->data);
-            if (_PyBytes_Resize(&self->data, size + 1) < 0)
+            Py_ssize_t size = PyString_GET_SIZE(self->data);
+            if (_PyString_Resize(&self->data, size + 1) < 0)
                 return NULL;
-            PyBytes_AS_STRING(self->data)[size] = PyBytes_AS_STRING(data)[0];
+            PyString_AS_STRING(self->data)[size] = PyString_AS_STRING(data)[0];
         } else if (PyList_CheckExact(self->data)) {
             if (PyList_Append(self->data, data) < 0)
                 return NULL;
@@ -1896,7 +1896,7 @@ makestring(const char* string, int size)
         return PyUnicode_DecodeUTF8(string, size, "strict");
 #endif
 
-    return PyBytes_FromStringAndSize(string, size);
+    return PyString_FromStringAndSize(string, size);
 }
 
 LOCAL(PyObject*)
@@ -1910,7 +1910,7 @@ makeuniversal(XMLParserObject* self, const char* string)
     PyObject* value;
 
     /* look the 'raw' name up in the names dictionary */
-    key = PyBytes_FromStringAndSize(string, size);
+    key = PyString_FromStringAndSize(string, size);
     if (!key)
         return NULL;
 
@@ -1932,8 +1932,8 @@ makeuniversal(XMLParserObject* self, const char* string)
                 break;
         if (i != size) {
             /* convert to universal name */
-            tag = PyBytes_FromStringAndSize(NULL, size+1);
-            p = PyBytes_AS_STRING(tag);
+            tag = PyString_FromStringAndSize(NULL, size+1);
+            p = PyString_AS_STRING(tag);
             p[0] = '{';
             memcpy(p+1, string, size);
             size++;
@@ -1947,7 +1947,7 @@ makeuniversal(XMLParserObject* self, const char* string)
 #if defined(Py_USING_UNICODE)
         /* inline makestring, to avoid duplicating the source string if
            it's not an utf-8 string */
-        p = PyBytes_AS_STRING(tag);
+        p = PyString_AS_STRING(tag);
         if (checkstring(p, size)) {
             value = PyUnicode_DecodeUTF8(p, size, "strict");
             Py_DECREF(tag);
@@ -2004,7 +2004,7 @@ expat_default_handler(XMLParserObject* self, const XML_Char* data_in,
     } else {
         PyErr_Format(
             PyExc_SyntaxError, "undefined entity &%s;: line %ld, column %ld",
-            PyBytes_AS_STRING(key),
+            PyString_AS_STRING(key),
             EXPAT(GetErrorLineNumber)(self->parser),
             EXPAT(GetErrorColumnNumber)(self->parser)
             );
@@ -2435,13 +2435,13 @@ xmlparser_parse(XMLParserObject* self, PyObject* args)
             return NULL;
         }
 
-        if (!PyBytes_CheckExact(buffer) || PyBytes_GET_SIZE(buffer) == 0) {
+        if (!PyString_CheckExact(buffer) || PyString_GET_SIZE(buffer) == 0) {
             Py_DECREF(buffer);
             break;
         }
 
         res = expat_parse(
-            self, PyBytes_AS_STRING(buffer), PyBytes_GET_SIZE(buffer), 0
+            self, PyString_AS_STRING(buffer), PyString_GET_SIZE(buffer), 0
             );
 
         Py_DECREF(buffer);
@@ -2503,7 +2503,7 @@ xmlparser_setevents(XMLParserObject* self, PyObject* args)
 
     if (event_set == Py_None) {
         /* default is "end" only */
-        target->end_event_obj = PyBytes_FromString("end");
+        target->end_event_obj = PyString_FromString("end");
         Py_RETURN_NONE;
     }
 
@@ -2513,9 +2513,9 @@ xmlparser_setevents(XMLParserObject* self, PyObject* args)
     for (i = 0; i < PyTuple_GET_SIZE(event_set); i++) {
         PyObject* item = PyTuple_GET_ITEM(event_set, i);
         char* event;
-        if (!PyBytes_Check(item))
+        if (!PyString_Check(item))
             goto error;
-        event = PyBytes_AS_STRING(item);
+        event = PyString_AS_STRING(item);
         if (strcmp(event, "start") == 0) {
             Py_INCREF(item);
             target->start_event_obj = item;
@@ -2587,7 +2587,7 @@ xmlparser_getattr(XMLParserObject* self, char* name)
         char buffer[100];
         sprintf(buffer, "Expat %d.%d.%d", XML_MAJOR_VERSION,
                 XML_MINOR_VERSION, XML_MICRO_VERSION);
-        return PyBytes_FromString(buffer);
+        return PyString_FromString(buffer);
     } else {
         PyErr_SetString(PyExc_AttributeError, name);
         return NULL;
index aa5b59fb3f2ab686a08cde6da5925cef3760d5e5..1cb697bb3906d7055d8c4679126a7b9956a48169 100644 (file)
@@ -392,14 +392,14 @@ fileio_readall(PyFileIOObject *self)
        Py_ssize_t total = 0;
        int n;
 
-       result = PyBytes_FromStringAndSize(NULL, DEFAULT_BUFFER_SIZE);
+       result = PyString_FromStringAndSize(NULL, DEFAULT_BUFFER_SIZE);
        if (result == NULL)
                return NULL;
 
        while (1) {
                Py_ssize_t newsize = total + DEFAULT_BUFFER_SIZE;
-               if (PyBytes_GET_SIZE(result) < newsize) {
-                       if (_PyBytes_Resize(&result, newsize) < 0) {
+               if (PyString_GET_SIZE(result) < newsize) {
+                       if (_PyString_Resize(&result, newsize) < 0) {
                                if (total == 0) {
                                        Py_DECREF(result);
                                        return NULL;
@@ -411,7 +411,7 @@ fileio_readall(PyFileIOObject *self)
                Py_BEGIN_ALLOW_THREADS
                errno = 0;
                n = read(self->fd,
-                        PyBytes_AS_STRING(result) + total,
+                        PyString_AS_STRING(result) + total,
                         newsize - total);
                Py_END_ALLOW_THREADS
                if (n == 0)
@@ -430,8 +430,8 @@ fileio_readall(PyFileIOObject *self)
                total += n;
        }
 
-       if (PyBytes_GET_SIZE(result) > total) {
-               if (_PyBytes_Resize(&result, total) < 0) {
+       if (PyString_GET_SIZE(result) > total) {
+               if (_PyString_Resize(&result, total) < 0) {
                        /* This should never happen, but just in case */
                        Py_DECREF(result);
                        return NULL;
@@ -460,10 +460,10 @@ fileio_read(PyFileIOObject *self, PyObject *args)
                return fileio_readall(self);
        }
 
-       bytes = PyBytes_FromStringAndSize(NULL, size);
+       bytes = PyString_FromStringAndSize(NULL, size);
        if (bytes == NULL)
                return NULL;
-       ptr = PyBytes_AS_STRING(bytes);
+       ptr = PyString_AS_STRING(bytes);
 
        Py_BEGIN_ALLOW_THREADS
        errno = 0;
@@ -478,7 +478,7 @@ fileio_read(PyFileIOObject *self, PyObject *args)
        }
 
        if (n != size) {
-               if (_PyBytes_Resize(&bytes, n) < 0) {
+               if (_PyString_Resize(&bytes, n) < 0) {
                        Py_DECREF(bytes);
                        return NULL;
                }
@@ -690,9 +690,9 @@ static PyObject *
 fileio_repr(PyFileIOObject *self)
 {
         if (self->fd < 0)
-               return PyBytes_FromFormat("_fileio._FileIO(-1)");
+               return PyString_FromFormat("_fileio._FileIO(-1)");
 
-       return PyBytes_FromFormat("_fileio._FileIO(%d, '%s')",
+       return PyString_FromFormat("_fileio._FileIO(%d, '%s')",
                                   self->fd, mode_string(self));
 }
 
@@ -816,7 +816,7 @@ get_closed(PyFileIOObject *self, void *closure)
 static PyObject *
 get_mode(PyFileIOObject *self, void *closure)
 {
-       return PyBytes_FromString(mode_string(self));
+       return PyString_FromString(mode_string(self));
 }
 
 static PyGetSetDef fileio_getsetlist[] = {
index 7bca2daa22dfc957d96bae4dd42355f7a16b6d42..8e5121f12e9ab81f80af08d69b918fc539d471db 100644 (file)
@@ -103,7 +103,7 @@ EVP_digest(EVPobject *self, PyObject *unused)
     digest_size = EVP_MD_CTX_size(&temp_ctx);
     EVP_DigestFinal(&temp_ctx, digest, NULL);
 
-    retval = PyBytes_FromStringAndSize((const char *)digest, digest_size);
+    retval = PyString_FromStringAndSize((const char *)digest, digest_size);
     EVP_MD_CTX_cleanup(&temp_ctx);
     return retval;
 }
@@ -130,10 +130,10 @@ EVP_hexdigest(EVPobject *self, PyObject *unused)
     /* Create a new string */
     /* NOTE: not thread safe! modifying an already created string object */
     /* (not a problem because we hold the GIL by default) */
-    retval = PyBytes_FromStringAndSize(NULL, digest_size * 2);
+    retval = PyString_FromStringAndSize(NULL, digest_size * 2);
     if (!retval)
            return NULL;
-    hex_digest = PyBytes_AsString(retval);
+    hex_digest = PyString_AsString(retval);
     if (!hex_digest) {
            Py_DECREF(retval);
            return NULL;
@@ -220,8 +220,8 @@ EVP_repr(PyObject *self)
 {
     char buf[100];
     PyOS_snprintf(buf, sizeof(buf), "<%s HASH object @ %p>",
-            PyBytes_AsString(((EVPobject *)self)->name), self);
-    return PyBytes_FromString(buf);
+            PyString_AsString(((EVPobject *)self)->name), self);
+    return PyString_FromString(buf);
 }
 
 #if HASH_OBJ_CONSTRUCTOR
@@ -421,7 +421,7 @@ EVP_new(PyObject *self, PyObject *args, PyObject *kwdict)
 
 /* used in the init function to setup a constructor */
 #define INIT_CONSTRUCTOR_CONSTANTS(NAME)  do { \
-    CONST_ ## NAME ## _name_obj = PyBytes_FromString(#NAME); \
+    CONST_ ## NAME ## _name_obj = PyString_FromString(#NAME); \
     if (EVP_get_digestbyname(#NAME)) { \
         CONST_new_ ## NAME ## _ctx_p = &CONST_new_ ## NAME ## _ctx; \
         EVP_DigestInit(CONST_new_ ## NAME ## _ctx_p, EVP_get_digestbyname(#NAME)); \
index aa5bbb12edee216767bdebde006da8a70953b50a..7a6416155d736606e63b452bceba719ec55af7d1 100644 (file)
@@ -687,6 +687,6 @@ init_heapq(void)
        m = Py_InitModule3("_heapq", heapq_methods, module_doc);
        if (m == NULL)
                return;
-       PyModule_AddObject(m, "__about__", PyBytes_FromString(__about__));
+       PyModule_AddObject(m, "__about__", PyString_FromString(__about__));
 }
 
index 7c8bdd96308f85bc5ec6c30ae5f3ada42bff0e45..4c66e2a6a3c4a59ded78062860c3084d19ad7f7b 100644 (file)
@@ -326,7 +326,7 @@ unpack_string(LogReaderObject *self, PyObject **pvalue)
             return ERR_EOF;
         }
     }
-    *pvalue = PyBytes_FromStringAndSize(buf, len);
+    *pvalue = PyString_FromStringAndSize(buf, len);
     free(buf);
     if (*pvalue == NULL) {
         return ERR_EXCEPTION;
@@ -562,7 +562,7 @@ flush_data(ProfilerObject *self)
                 self->index - written);
         self->index -= written;
         if (written == 0) {
-            char *s = PyBytes_AsString(self->logfilename);
+            char *s = PyString_AsString(self->logfilename);
             PyErr_SetFromErrnoWithFilename(PyExc_IOError, s);
             do_stop(self);
             return -1;
@@ -570,7 +570,7 @@ flush_data(ProfilerObject *self)
     }
     if (written > 0) {
         if (fflush(self->logfp)) {
-            char *s = PyBytes_AsString(self->logfilename);
+            char *s = PyString_AsString(self->logfilename);
             PyErr_SetFromErrnoWithFilename(PyExc_IOError, s);
             do_stop(self);
             return -1;
@@ -792,7 +792,7 @@ get_fileno(ProfilerObject *self, PyCodeObject *fcode)
         self->next_fileno++;
         Py_DECREF(obj);
         if (pack_define_file(self, fileno,
-                             PyBytes_AS_STRING(fcode->co_filename)) < 0)
+                             PyString_AS_STRING(fcode->co_filename)) < 0)
             return -1;
     }
     else {
@@ -810,7 +810,7 @@ get_fileno(ProfilerObject *self, PyCodeObject *fcode)
         PyObject *name = PyDict_GetItem(dict, obj);
         if (name == NULL) {
             if (pack_define_func(self, fileno, fcode->co_firstlineno,
-                                 PyBytes_AS_STRING(fcode->co_name)) < 0) {
+                                 PyString_AS_STRING(fcode->co_name)) < 0) {
                 Py_DECREF(obj);
                 return -1;
             }
@@ -1471,7 +1471,7 @@ write_header(ProfilerObject *self)
     len = PyList_GET_SIZE(temp);
     for (i = 0; i < len; ++i) {
         PyObject *item = PyList_GET_ITEM(temp, i);
-        buffer = PyBytes_AsString(item);
+        buffer = PyString_AsString(item);
         if (buffer == NULL) {
             pack_add_info(self, "sys-path-entry", "<non-string-path-entry>");
             PyErr_Clear();
index 30cdc0f207f260614c1f8059ab2ef24de2e0c177..ea6d66f60cac9e6a58c65228272a72ff69de2ff5 100644 (file)
@@ -70,11 +70,11 @@ ascii_escape_unicode(PyObject *pystr)
     input_unicode = PyUnicode_AS_UNICODE(pystr);
     /* One char input can be up to 6 chars output, estimate 4 of these */
     output_size = 2 + (MIN_EXPANSION * 4) + input_chars;
-    rval = PyBytes_FromStringAndSize(NULL, output_size);
+    rval = PyString_FromStringAndSize(NULL, output_size);
     if (rval == NULL) {
         return NULL;
     }
-    output = PyBytes_AS_STRING(rval);
+    output = PyString_AS_STRING(rval);
     chars = 0;
     output[chars++] = '"';
     for (i = 0; i < input_chars; i++) {
@@ -92,14 +92,14 @@ ascii_escape_unicode(PyObject *pystr)
             if (output_size > 2 + (input_chars * MAX_EXPANSION)) {
                 output_size = 2 + (input_chars * MAX_EXPANSION);
             }
-            if (_PyBytes_Resize(&rval, output_size) == -1) {
+            if (_PyString_Resize(&rval, output_size) == -1) {
                 return NULL;
             }
-            output = PyBytes_AS_STRING(rval);
+            output = PyString_AS_STRING(rval);
         }
     }
     output[chars++] = '"';
-    if (_PyBytes_Resize(&rval, chars) == -1) {
+    if (_PyString_Resize(&rval, chars) == -1) {
         return NULL;
     }
     return rval;
@@ -116,15 +116,15 @@ ascii_escape_str(PyObject *pystr)
     char *output;
     char *input_str;
 
-    input_chars = PyBytes_GET_SIZE(pystr);
-    input_str = PyBytes_AS_STRING(pystr);
+    input_chars = PyString_GET_SIZE(pystr);
+    input_str = PyString_AS_STRING(pystr);
     /* One char input can be up to 6 chars output, estimate 4 of these */
     output_size = 2 + (MIN_EXPANSION * 4) + input_chars;
-    rval = PyBytes_FromStringAndSize(NULL, output_size);
+    rval = PyString_FromStringAndSize(NULL, output_size);
     if (rval == NULL) {
         return NULL;
     }
-    output = PyBytes_AS_STRING(rval);
+    output = PyString_AS_STRING(rval);
     chars = 0;
     output[chars++] = '"';
     for (i = 0; i < input_chars; i++) {
@@ -154,14 +154,14 @@ ascii_escape_str(PyObject *pystr)
             if (output_size > 2 + (input_chars * MIN_EXPANSION)) {
                 output_size = 2 + (input_chars * MIN_EXPANSION);
             }
-            if (_PyBytes_Resize(&rval, output_size) == -1) {
+            if (_PyString_Resize(&rval, output_size) == -1) {
                 return NULL;
             }
-            output = PyBytes_AS_STRING(rval);
+            output = PyString_AS_STRING(rval);
         }
     }
     output[chars++] = '"';
-    if (_PyBytes_Resize(&rval, chars) == -1) {
+    if (_PyString_Resize(&rval, chars) == -1) {
         return NULL;
     }
     return rval;
@@ -215,7 +215,7 @@ join_list_unicode(PyObject *lst)
         ustr = PyUnicode_FromUnicode(&c, 0);
     }
     if (joinstr == NULL) {
-        joinstr = PyBytes_InternFromString("join");
+        joinstr = PyString_InternFromString("join");
     }
     if (joinstr == NULL || ustr == NULL) {
         return NULL;
@@ -227,10 +227,10 @@ static PyObject *
 scanstring_str(PyObject *pystr, Py_ssize_t end, char *encoding, int strict)
 {
     PyObject *rval;
-    Py_ssize_t len = PyBytes_GET_SIZE(pystr);
+    Py_ssize_t len = PyString_GET_SIZE(pystr);
     Py_ssize_t begin = end - 1;
     Py_ssize_t next = begin;
-    char *buf = PyBytes_AS_STRING(pystr);
+    char *buf = PyString_AS_STRING(pystr);
     PyObject *chunks = PyList_New(0);
     if (chunks == NULL) {
         goto bail;
@@ -555,7 +555,7 @@ py_scanstring(PyObject* self, PyObject *args)
     if (encoding == NULL) {
         encoding = DEFAULT_ENCODING;
     }
-    if (PyBytes_Check(pystr)) {
+    if (PyString_Check(pystr)) {
         return scanstring_str(pystr, end, encoding, strict);
     }
     else if (PyUnicode_Check(pystr)) {
@@ -576,7 +576,7 @@ static PyObject *
 py_encode_basestring_ascii(PyObject* self, PyObject *pystr)
 {
     /* METH_O */
-    if (PyBytes_Check(pystr)) {
+    if (PyString_Check(pystr)) {
         return ascii_escape_str(pystr);
     }
     else if (PyUnicode_Check(pystr)) {
index ce84b2756b1d01d7aca75fd3402fdcbb6ad5d0f6..02e9e53b274526fa787eb5149618c306cae73a52 100644 (file)
@@ -119,7 +119,7 @@ fixup_ulcase(void)
         if (isupper(c))
             ul[n++] = c;
     }
-    ulo = PyBytes_FromStringAndSize((const char *)ul, n);
+    ulo = PyString_FromStringAndSize((const char *)ul, n);
     if (!ulo)
         return;
     if (string)
@@ -134,7 +134,7 @@ fixup_ulcase(void)
         if (islower(c))
             ul[n++] = c;
     }
-    ulo = PyBytes_FromStringAndSize((const char *)ul, n);
+    ulo = PyString_FromStringAndSize((const char *)ul, n);
     if (!ulo)
         return;
     if (string)
@@ -149,7 +149,7 @@ fixup_ulcase(void)
         if (isalpha(c))
             ul[n++] = c;
     }
-    ulo = PyBytes_FromStringAndSize((const char *)ul, n);
+    ulo = PyString_FromStringAndSize((const char *)ul, n);
     if (!ulo)
         return;
     if (string)
@@ -175,7 +175,7 @@ PyLocale_setlocale(PyObject* self, PyObject* args)
             PyErr_SetString(Error, "unsupported locale setting");
             return NULL;
         }
-        result_object = PyBytes_FromString(result);
+        result_object = PyString_FromString(result);
         if (!result_object)
             return NULL;
         /* record changes to LC_CTYPE */
@@ -190,7 +190,7 @@ PyLocale_setlocale(PyObject* self, PyObject* args)
             PyErr_SetString(Error, "locale query failed");
             return NULL;
         }
-        result_object = PyBytes_FromString(result);
+        result_object = PyString_FromString(result);
     }
     return result_object;
 }
@@ -216,7 +216,7 @@ PyLocale_localeconv(PyObject* self)
        involved herein */
 
 #define RESULT_STRING(s)\
-    x = PyBytes_FromString(l->s);\
+    x = PyString_FromString(l->s);\
     if (!x) goto failed;\
     PyDict_SetItemString(result, #s, x);\
     Py_XDECREF(x)
@@ -284,9 +284,9 @@ PyLocale_strcoll(PyObject* self, PyObject* args)
     if (!PyArg_UnpackTuple(args, "strcoll", 2, 2, &os1, &os2))
         return NULL;
     /* If both arguments are byte strings, use strcoll.  */
-    if (PyBytes_Check(os1) && PyBytes_Check(os2))
-        return PyInt_FromLong(strcoll(PyBytes_AS_STRING(os1),
-                                      PyBytes_AS_STRING(os2)));
+    if (PyString_Check(os1) && PyString_Check(os2))
+        return PyInt_FromLong(strcoll(PyString_AS_STRING(os1),
+                                      PyString_AS_STRING(os2)));
     /* If neither argument is unicode, it's an error.  */
     if (!PyUnicode_Check(os1) && !PyUnicode_Check(os2)) {
         PyErr_SetString(PyExc_ValueError, "strcoll arguments must be strings");
@@ -368,7 +368,7 @@ PyLocale_strxfrm(PyObject* self, PyObject* args)
             return PyErr_NoMemory();
         strxfrm(buf, s, n2);
     }
-    result = PyBytes_FromString(buf);
+    result = PyString_FromString(buf);
     PyMem_Free(buf);
     return result;
 }
@@ -563,13 +563,13 @@ PyLocale_nl_langinfo(PyObject* self, PyObject* args)
         return NULL;
     /* Check whether this is a supported constant. GNU libc sometimes
        returns numeric values in the char* return value, which would
-       crash PyBytes_FromString.  */
+       crash PyString_FromString.  */
     for (i = 0; langinfo_constants[i].name; i++)
         if (langinfo_constants[i].value == item) {
             /* Check NULL as a workaround for GNU libc's returning NULL
                instead of an empty string for nl_langinfo(ERA).  */
             const char *result = nl_langinfo(item);
-            return PyBytes_FromString(result != NULL ? result : "");
+            return PyString_FromString(result != NULL ? result : "");
         }
     PyErr_SetString(PyExc_ValueError, "unsupported langinfo constant");
     return NULL;
@@ -588,7 +588,7 @@ PyIntl_gettext(PyObject* self, PyObject *args)
        char *in;
        if (!PyArg_ParseTuple(args, "z", &in))
                return 0;
-       return PyBytes_FromString(gettext(in));
+       return PyString_FromString(gettext(in));
 }
 
 PyDoc_STRVAR(dgettext__doc__,
@@ -601,7 +601,7 @@ PyIntl_dgettext(PyObject* self, PyObject *args)
        char *domain, *in;
        if (!PyArg_ParseTuple(args, "zz", &domain, &in))
                return 0;
-       return PyBytes_FromString(dgettext(domain, in));
+       return PyString_FromString(dgettext(domain, in));
 }
 
 PyDoc_STRVAR(dcgettext__doc__,
@@ -615,7 +615,7 @@ PyIntl_dcgettext(PyObject *self, PyObject *args)
        int category;
        if (!PyArg_ParseTuple(args, "zzi", &domain, &msgid, &category))
                return 0;
-       return PyBytes_FromString(dcgettext(domain,msgid,category));
+       return PyString_FromString(dcgettext(domain,msgid,category));
 }
 
 PyDoc_STRVAR(textdomain__doc__,
@@ -633,7 +633,7 @@ PyIntl_textdomain(PyObject* self, PyObject* args)
                PyErr_SetFromErrno(PyExc_OSError);
                return NULL;
        }
-       return PyBytes_FromString(domain);
+       return PyString_FromString(domain);
 }
 
 PyDoc_STRVAR(bindtextdomain__doc__,
@@ -651,7 +651,7 @@ PyIntl_bindtextdomain(PyObject* self,PyObject*args)
                PyErr_SetFromErrno(PyExc_OSError);
                return NULL;
        }
-       return PyBytes_FromString(dirname);
+       return PyString_FromString(dirname);
 }
 
 #ifdef HAVE_BIND_TEXTDOMAIN_CODESET
@@ -667,7 +667,7 @@ PyIntl_bind_textdomain_codeset(PyObject* self,PyObject*args)
                return NULL;
        codeset = bind_textdomain_codeset(domain, codeset);
        if (codeset)
-               return PyBytes_FromString(codeset);
+               return PyString_FromString(codeset);
        Py_RETURN_NONE;
 }
 #endif
@@ -760,7 +760,7 @@ init_locale(void)
     Error = PyErr_NewException("locale.Error", NULL, NULL);
     PyDict_SetItemString(d, "Error", Error);
 
-    x = PyBytes_FromString(locale__doc__);
+    x = PyString_FromString(locale__doc__);
     PyDict_SetItemString(d, "__doc__", x);
     Py_XDECREF(x);
 
index 2b80a003826abef8bf0014f85bce8024126bb42d..5d18c3370dfb035d5968ff2b74508c279d16cd62 100644 (file)
@@ -179,8 +179,8 @@ normalizeUserObj(PyObject *obj)
                /* built-in function: look up the module name */
                PyObject *mod = fn->m_module;
                char *modname;
-               if (mod && PyBytes_Check(mod)) {
-                       modname = PyBytes_AS_STRING(mod);
+               if (mod && PyString_Check(mod)) {
+                       modname = PyString_AS_STRING(mod);
                }
                else if (mod && PyModule_Check(mod)) {
                        modname = PyModule_GetName(mod);
@@ -193,11 +193,11 @@ normalizeUserObj(PyObject *obj)
                        modname = "__builtin__";
                }
                if (strcmp(modname, "__builtin__") != 0)
-                       return PyBytes_FromFormat("<%s.%s>",
+                       return PyString_FromFormat("<%s.%s>",
                                                   modname,
                                                   fn->m_ml->ml_name);
                else
-                       return PyBytes_FromFormat("<%s>",
+                       return PyString_FromFormat("<%s>",
                                                   fn->m_ml->ml_name);
        }
        else {
@@ -205,7 +205,7 @@ normalizeUserObj(PyObject *obj)
                        repr(getattr(type(__self__), __name__))
                */
                PyObject *self = fn->m_self;
-               PyObject *name = PyBytes_FromString(fn->m_ml->ml_name);
+               PyObject *name = PyString_FromString(fn->m_ml->ml_name);
                if (name != NULL) {
                        PyObject *mo = _PyType_Lookup(Py_TYPE(self), name);
                        Py_XINCREF(mo);
@@ -218,7 +218,7 @@ normalizeUserObj(PyObject *obj)
                        }
                }
                PyErr_Clear();
-               return PyBytes_FromFormat("<built-in method %s>",
+               return PyString_FromFormat("<built-in method %s>",
                                           fn->m_ml->ml_name);
        }
 }
index 3362a5cd9aa93e51d77d3c9014c3b77f4171adb8..85118fc78e49994c973d6d0ea3c37fd36b6c2efe 100644 (file)
@@ -241,12 +241,12 @@ PyObject* pysqlite_cache_display(pysqlite_Cache* self, PyObject* args)
         if (!fmt_args) {
             return NULL;
         }
-        template = PyBytes_FromString("%s <- %s ->%s\n");
+        template = PyString_FromString("%s <- %s ->%s\n");
         if (!template) {
             Py_DECREF(fmt_args);
             return NULL;
         }
-        display_str = PyBytes_Format(template, fmt_args);
+        display_str = PyString_Format(template, fmt_args);
         Py_DECREF(template);
         Py_DECREF(fmt_args);
         if (!display_str) {
index 927c983f7d0986db6bfa641a439a0498b23bede3..8269e0b1fb21ad885518ed521f4265fce7632af1 100644 (file)
@@ -84,8 +84,8 @@ int pysqlite_connection_init(pysqlite_Connection* self, PyObject* args, PyObject
     Py_INCREF(&PyUnicode_Type);
     self->text_factory = (PyObject*)&PyUnicode_Type;
 
-    if (PyBytes_Check(database) || PyUnicode_Check(database)) {
-        if (PyBytes_Check(database)) {
+    if (PyString_Check(database) || PyUnicode_Check(database)) {
+        if (PyString_Check(database)) {
             database_utf8 = database;
             Py_INCREF(database_utf8);
         } else {
@@ -96,7 +96,7 @@ int pysqlite_connection_init(pysqlite_Connection* self, PyObject* args, PyObject
         }
 
         Py_BEGIN_ALLOW_THREADS
-        rc = sqlite3_open(PyBytes_AsString(database_utf8), &self->db);
+        rc = sqlite3_open(PyString_AsString(database_utf8), &self->db);
         Py_END_ALLOW_THREADS
 
         Py_DECREF(database_utf8);
@@ -111,7 +111,7 @@ int pysqlite_connection_init(pysqlite_Connection* self, PyObject* args, PyObject
         if (class_attr) {
             class_attr_str = PyObject_Str(class_attr);
             if (class_attr_str) {
-                if (strcmp(PyBytes_AsString(class_attr_str), "<type 'apsw.Connection'>") == 0) {
+                if (strcmp(PyString_AsString(class_attr_str), "<type 'apsw.Connection'>") == 0) {
                     /* In the APSW Connection object, the first entry after
                      * PyObject_HEAD is the sqlite3* we want to get hold of.
                      * Luckily, this is the same layout as we have in our
@@ -134,7 +134,7 @@ int pysqlite_connection_init(pysqlite_Connection* self, PyObject* args, PyObject
     }
 
     if (!isolation_level) {
-        isolation_level = PyBytes_FromString("");
+        isolation_level = PyString_FromString("");
         if (!isolation_level) {
             return -1;
         }
@@ -499,12 +499,12 @@ void _pysqlite_set_result(sqlite3_context* context, PyObject* py_val)
         } else {
             sqlite3_result_blob(context, buffer, buflen, SQLITE_TRANSIENT);
         }
-    } else if (PyBytes_Check(py_val)) {
-        sqlite3_result_text(context, PyBytes_AsString(py_val), -1, SQLITE_TRANSIENT);
+    } else if (PyString_Check(py_val)) {
+        sqlite3_result_text(context, PyString_AsString(py_val), -1, SQLITE_TRANSIENT);
     } else if (PyUnicode_Check(py_val)) {
         stringval = PyUnicode_AsUTF8String(py_val);
         if (stringval) {
-            sqlite3_result_text(context, PyBytes_AsString(stringval), -1, SQLITE_TRANSIENT);
+            sqlite3_result_text(context, PyString_AsString(stringval), -1, SQLITE_TRANSIENT);
             Py_DECREF(stringval);
         }
     } else {
@@ -963,21 +963,21 @@ static int pysqlite_connection_set_isolation_level(pysqlite_Connection* self, Py
         Py_INCREF(isolation_level);
         self->isolation_level = isolation_level;
 
-        begin_statement = PyBytes_FromString("BEGIN ");
+        begin_statement = PyString_FromString("BEGIN ");
         if (!begin_statement) {
             return -1;
         }
-        PyBytes_Concat(&begin_statement, isolation_level);
+        PyString_Concat(&begin_statement, isolation_level);
         if (!begin_statement) {
             return -1;
         }
 
-        self->begin_statement = PyMem_Malloc(PyBytes_Size(begin_statement) + 2);
+        self->begin_statement = PyMem_Malloc(PyString_Size(begin_statement) + 2);
         if (!self->begin_statement) {
             return -1;
         }
 
-        strcpy(self->begin_statement, PyBytes_AsString(begin_statement));
+        strcpy(self->begin_statement, PyString_AsString(begin_statement));
         Py_DECREF(begin_statement);
     }
 
@@ -1152,8 +1152,8 @@ pysqlite_collation_callback(
         goto finally;
     }
 
-    string1 = PyBytes_FromStringAndSize((const char*)text1_data, text1_length);
-    string2 = PyBytes_FromStringAndSize((const char*)text2_data, text2_length);
+    string1 = PyString_FromStringAndSize((const char*)text1_data, text1_length);
+    string2 = PyString_FromStringAndSize((const char*)text2_data, text2_length);
 
     if (!string1 || !string2) {
         goto finally; /* failed to allocate strings */
@@ -1259,7 +1259,7 @@ pysqlite_connection_create_collation(pysqlite_Connection* self, PyObject* args)
         goto finally;
     }
 
-    if (!PyArg_ParseTuple(args, "O!O:create_collation(name, callback)", &PyBytes_Type, &name, &callable)) {
+    if (!PyArg_ParseTuple(args, "O!O:create_collation(name, callback)", &PyString_Type, &name, &callable)) {
         goto finally;
     }
 
@@ -1268,7 +1268,7 @@ pysqlite_connection_create_collation(pysqlite_Connection* self, PyObject* args)
         goto finally;
     }
 
-    chk = PyBytes_AsString(uppercase_name);
+    chk = PyString_AsString(uppercase_name);
     while (*chk) {
         if ((*chk >= '0' && *chk <= '9')
          || (*chk >= 'A' && *chk <= 'Z')
@@ -1293,7 +1293,7 @@ pysqlite_connection_create_collation(pysqlite_Connection* self, PyObject* args)
     }
 
     rc = sqlite3_create_collation(self->db,
-                                  PyBytes_AsString(uppercase_name),
+                                  PyString_AsString(uppercase_name),
                                   SQLITE_UTF8,
                                   (callable != Py_None) ? callable : NULL,
                                   (callable != Py_None) ? pysqlite_collation_callback : NULL);
index c5d0fd061bc129429a8a93d901c902357b84eb13..3b1c632db8c493938ef4bf4d05fa9432a597446d 100644 (file)
@@ -80,7 +80,7 @@ typedef struct
     /* Determines how bytestrings from SQLite are converted to Python objects:
      * - PyUnicode_Type:        Python Unicode objects are constructed from UTF-8 bytestrings
      * - OptimizedUnicode:      Like before, but for ASCII data, only PyStrings are created.
-     * - PyBytes_Type:         PyStrings are created as-is.
+     * - PyString_Type:         PyStrings are created as-is.
      * - Any custom callable:   Any object returned from the callable called with the bytestring
      *                          as single parameter.
      */
index 23d1e069cb1b47a8f6af46c06ef7633bdea2e37e..0d7d59a92f630449a81005c401a9cd656ced2634 100644 (file)
@@ -178,7 +178,7 @@ int pysqlite_build_row_cast_map(pysqlite_Cursor* self)
                     if (*pos == '[') {
                         type_start = pos + 1;
                     } else if (*pos == ']' && type_start != (const char*)-1) {
-                        key = PyBytes_FromStringAndSize(type_start, pos - type_start);
+                        key = PyString_FromStringAndSize(type_start, pos - type_start);
                         if (!key) {
                             /* creating a string failed, but it is too complicated
                              * to propagate the error here, we just assume there is
@@ -203,7 +203,7 @@ int pysqlite_build_row_cast_map(pysqlite_Cursor* self)
                      * 'NUMBER(10)' to be treated as 'NUMBER', for example.
                      * In other words, it will work as people expect it to work.*/
                     if (*pos == ' ' || *pos == '(' || *pos == 0) {
-                        py_decltype = PyBytes_FromStringAndSize(decltype, pos - decltype);
+                        py_decltype = PyString_FromStringAndSize(decltype, pos - decltype);
                         if (!py_decltype) {
                             return -1;
                         }
@@ -248,7 +248,7 @@ PyObject* _pysqlite_build_column_name(const char* colname)
             if ((*pos == '[') && (pos > colname) && (*(pos-1) == ' ')) {
                 pos--;
             }
-            return PyBytes_FromStringAndSize(colname, pos - colname);
+            return PyString_FromStringAndSize(colname, pos - colname);
         }
     }
 }
@@ -273,7 +273,7 @@ PyObject* pysqlite_unicode_from_string(const char* val_str, int optimize)
     }
 
     if (is_ascii) {
-        return PyBytes_FromString(val_str);
+        return PyString_FromString(val_str);
     } else {
         return PyUnicode_DecodeUTF8(val_str, strlen(val_str), NULL);
     }
@@ -327,7 +327,7 @@ PyObject* _pysqlite_fetch_one_row(pysqlite_Cursor* self)
                 Py_INCREF(Py_None);
                 converted = Py_None;
             } else {
-                item = PyBytes_FromStringAndSize(val_str, nbytes);
+                item = PyString_FromStringAndSize(val_str, nbytes);
                 if (!item) {
                     return NULL;
                 }
@@ -370,8 +370,8 @@ PyObject* _pysqlite_fetch_one_row(pysqlite_Cursor* self)
                                      colname , val_str);
                         PyErr_SetString(pysqlite_OperationalError, buf);
                     }
-                } else if (self->connection->text_factory == (PyObject*)&PyBytes_Type) {
-                    converted = PyBytes_FromString(val_str);
+                } else if (self->connection->text_factory == (PyObject*)&PyString_Type) {
+                    converted = PyString_FromString(val_str);
                 } else {
                     converted = PyObject_CallFunction(self->connection->text_factory, "s", val_str);
                 }
@@ -442,7 +442,7 @@ PyObject* _pysqlite_query_execute(pysqlite_Cursor* self, int multiple, PyObject*
             return NULL;
         }
 
-        if (!PyBytes_Check(operation) && !PyUnicode_Check(operation)) {
+        if (!PyString_Check(operation) && !PyUnicode_Check(operation)) {
             PyErr_SetString(PyExc_ValueError, "operation parameter must be str or unicode");
             return NULL;
         }
@@ -464,7 +464,7 @@ PyObject* _pysqlite_query_execute(pysqlite_Cursor* self, int multiple, PyObject*
             return NULL;
         }
 
-        if (!PyBytes_Check(operation) && !PyUnicode_Check(operation)) {
+        if (!PyString_Check(operation) && !PyUnicode_Check(operation)) {
             PyErr_SetString(PyExc_ValueError, "operation parameter must be str or unicode");
             return NULL;
         }
@@ -499,15 +499,15 @@ PyObject* _pysqlite_query_execute(pysqlite_Cursor* self, int multiple, PyObject*
         rc = pysqlite_statement_reset(self->statement);
     }
 
-    if (PyBytes_Check(operation)) {
-        operation_cstr = PyBytes_AsString(operation);
+    if (PyString_Check(operation)) {
+        operation_cstr = PyString_AsString(operation);
     } else {
         operation_bytestr = PyUnicode_AsUTF8String(operation);
         if (!operation_bytestr) {
             goto error;
         }
 
-        operation_cstr = PyBytes_AsString(operation_bytestr);
+        operation_cstr = PyString_AsString(operation_bytestr);
     }
 
     /* reset description and rowcount */
@@ -764,15 +764,15 @@ PyObject* pysqlite_cursor_executescript(pysqlite_Cursor* self, PyObject* args)
         return NULL;
     }
 
-    if (PyBytes_Check(script_obj)) {
-        script_cstr = PyBytes_AsString(script_obj);
+    if (PyString_Check(script_obj)) {
+        script_cstr = PyString_AsString(script_obj);
     } else if (PyUnicode_Check(script_obj)) {
         script_str = PyUnicode_AsUTF8String(script_obj);
         if (!script_str) {
             return NULL;
         }
 
-        script_cstr = PyBytes_AsString(script_str);
+        script_cstr = PyString_AsString(script_str);
     } else {
         PyErr_SetString(PyExc_ValueError, "script argument must be unicode or string.");
         return NULL;
index f77452c701017ca3fe6eaacb2eeea090ec8534e4..af7eace6851b83560d49c3e2d06285bb09b81989 100644 (file)
@@ -137,7 +137,7 @@ static PyObject* module_register_adapter(PyObject* self, PyObject* args, PyObjec
     /* a basic type is adapted; there's a performance optimization if that's not the case
      * (99 % of all usages) */
     if (type == &PyInt_Type || type == &PyLong_Type || type == &PyFloat_Type
-            || type == &PyBytes_Type || type == &PyUnicode_Type || type == &PyBuffer_Type) {
+            || type == &PyString_Type || type == &PyUnicode_Type || type == &PyBuffer_Type) {
         pysqlite_BaseTypeAdapted = 1;
     }
 
@@ -367,13 +367,13 @@ PyMODINIT_FUNC init_sqlite3(void)
         Py_DECREF(tmp_obj);
     }
 
-    if (!(tmp_obj = PyBytes_FromString(PYSQLITE_VERSION))) {
+    if (!(tmp_obj = PyString_FromString(PYSQLITE_VERSION))) {
         goto error;
     }
     PyDict_SetItemString(dict, "version", tmp_obj);
     Py_DECREF(tmp_obj);
 
-    if (!(tmp_obj = PyBytes_FromString(sqlite3_libversion()))) {
+    if (!(tmp_obj = PyString_FromString(sqlite3_libversion()))) {
         goto error;
     }
     PyDict_SetItemString(dict, "sqlite_version", tmp_obj);
index 8815116eac8ab320fd4f6e0a0ca2a66e9736739e..34192673a63b2a677a9772aba158d1f31db0bbed 100644 (file)
@@ -86,13 +86,13 @@ PyObject* pysqlite_row_subscript(pysqlite_Row* self, PyObject* idx)
         item = PyTuple_GetItem(self->data, _idx);
         Py_XINCREF(item);
         return item;
-    } else if (PyBytes_Check(idx)) {
-        key = PyBytes_AsString(idx);
+    } else if (PyString_Check(idx)) {
+        key = PyString_AsString(idx);
 
         nitems = PyTuple_Size(self->description);
 
         for (i = 0; i < nitems; i++) {
-            compare_key = PyBytes_AsString(PyTuple_GET_ITEM(PyTuple_GET_ITEM(self->description, i), 0));
+            compare_key = PyString_AsString(PyTuple_GET_ITEM(PyTuple_GET_ITEM(self->description, i), 0));
             if (!compare_key) {
                 return NULL;
             }
index b9245f732362c99bc0d866218ee9a60380e0b2c9..0e7766804d9a2f8465b8f7626a6e8aa480c10987 100644 (file)
@@ -60,7 +60,7 @@ int pysqlite_statement_create(pysqlite_Statement* self, pysqlite_Connection* con
     self->st = NULL;
     self->in_use = 0;
 
-    if (PyBytes_Check(sql)) {
+    if (PyString_Check(sql)) {
         sql_str = sql;
         Py_INCREF(sql_str);
     } else if (PyUnicode_Check(sql)) {
@@ -77,7 +77,7 @@ int pysqlite_statement_create(pysqlite_Statement* self, pysqlite_Connection* con
     self->in_weakreflist = NULL;
     self->sql = sql_str;
 
-    sql_cstr = PyBytes_AsString(sql_str);
+    sql_cstr = PyString_AsString(sql_str);
 
     rc = sqlite3_prepare(connection->db,
                          sql_cstr,
@@ -119,7 +119,7 @@ int pysqlite_statement_bind_parameter(pysqlite_Statement* self, int pos, PyObjec
         paramtype = TYPE_LONG;
     } else if (PyFloat_CheckExact(parameter)) {
         paramtype = TYPE_FLOAT;
-    } else if (PyBytes_CheckExact(parameter)) {
+    } else if (PyString_CheckExact(parameter)) {
         paramtype = TYPE_STRING;
     } else if (PyUnicode_CheckExact(parameter)) {
         paramtype = TYPE_UNICODE;
@@ -131,7 +131,7 @@ int pysqlite_statement_bind_parameter(pysqlite_Statement* self, int pos, PyObjec
         paramtype = TYPE_LONG;
     } else if (PyFloat_Check(parameter)) {
         paramtype = TYPE_FLOAT;
-    } else if (PyBytes_Check(parameter)) {
+    } else if (PyString_Check(parameter)) {
         paramtype = TYPE_STRING;
     } else if (PyUnicode_Check(parameter)) {
         paramtype = TYPE_UNICODE;
@@ -140,7 +140,7 @@ int pysqlite_statement_bind_parameter(pysqlite_Statement* self, int pos, PyObjec
     }
 
     if (paramtype == TYPE_STRING && !allow_8bit_chars) {
-        string = PyBytes_AS_STRING(parameter);
+        string = PyString_AS_STRING(parameter);
         for (c = string; *c != 0; c++) {
             if (*c & 0x80) {
                 PyErr_SetString(pysqlite_ProgrammingError, "You must not use 8-bit bytestrings unless you use a text_factory that can interpret 8-bit bytestrings (like text_factory = str). It is highly recommended that you instead just switch your application to Unicode strings.");
@@ -164,12 +164,12 @@ int pysqlite_statement_bind_parameter(pysqlite_Statement* self, int pos, PyObjec
             rc = sqlite3_bind_double(self->st, pos, PyFloat_AsDouble(parameter));
             break;
         case TYPE_STRING:
-            string = PyBytes_AS_STRING(parameter);
+            string = PyString_AS_STRING(parameter);
             rc = sqlite3_bind_text(self->st, pos, string, -1, SQLITE_TRANSIENT);
             break;
         case TYPE_UNICODE:
             stringval = PyUnicode_AsUTF8String(parameter);
-            string = PyBytes_AsString(stringval);
+            string = PyString_AsString(stringval);
             rc = sqlite3_bind_text(self->st, pos, string, -1, SQLITE_TRANSIENT);
             Py_DECREF(stringval);
             break;
@@ -197,7 +197,7 @@ static int _need_adapt(PyObject* obj)
     }
 
     if (PyInt_CheckExact(obj) || PyLong_CheckExact(obj) 
-            || PyFloat_CheckExact(obj) || PyBytes_CheckExact(obj)
+            || PyFloat_CheckExact(obj) || PyString_CheckExact(obj)
             || PyUnicode_CheckExact(obj) || PyBuffer_Check(obj)) {
         return 0;
     } else {
@@ -326,7 +326,7 @@ int pysqlite_statement_recompile(pysqlite_Statement* self, PyObject* params)
     char* sql_cstr;
     sqlite3_stmt* new_st;
 
-    sql_cstr = PyBytes_AsString(self->sql);
+    sql_cstr = PyString_AsString(self->sql);
 
     rc = sqlite3_prepare(self->db,
                          sql_cstr,
index 342f9a04be9e395908c53a824be5d81f90f59b9a..808fb57528a5fa085c95d930f443c5299f00c559 100644 (file)
@@ -1715,7 +1715,7 @@ getstring(PyObject* string, Py_ssize_t* p_length, int* p_charsize)
     size = PyObject_Length(string);
 #endif
 
-    if (PyBytes_Check(string) || bytes == size)
+    if (PyString_Check(string) || bytes == size)
         charsize = 1;
 #if defined(HAVE_UNICODE)
     else if (bytes == (Py_ssize_t) (size * sizeof(Py_UNICODE)))
@@ -1949,7 +1949,7 @@ call(char* module, char* function, PyObject* args)
 
     if (!args)
         return NULL;
-    name = PyBytes_FromString(module);
+    name = PyString_FromString(module);
     if (!name)
         return NULL;
     mod = PyImport_Import(name);
@@ -3416,7 +3416,7 @@ PyMODINIT_FUNC init_sre(void)
         Py_DECREF(x);
     }
 
-    x = PyBytes_FromString(copyright);
+    x = PyString_FromString(copyright);
     if (x) {
         PyDict_SetItemString(d, "copyright", x);
         Py_DECREF(x);
index 91f16e6e1127c3bb58042ebdefb023ebe96e77cc..3f167b32caf7fc32c247d8bf1648be8060489f59 100644 (file)
@@ -491,13 +491,13 @@ PyDoc_STRVAR(ssl_doc,
 static PyObject *
 PySSL_server(PySSLObject *self)
 {
-       return PyBytes_FromString(self->server);
+       return PyString_FromString(self->server);
 }
 
 static PyObject *
 PySSL_issuer(PySSLObject *self)
 {
-       return PyBytes_FromString(self->issuer);
+       return PyString_FromString(self->issuer);
 }
 
 static PyObject *
@@ -515,7 +515,7 @@ _create_tuple_for_attribute (ASN1_OBJECT *name, ASN1_STRING *value) {
                _setSSLError(NULL, 0, __FILE__, __LINE__);
                goto fail;
        }
-       name_obj = PyBytes_FromStringAndSize(namebuf, buflen);
+       name_obj = PyString_FromStringAndSize(namebuf, buflen);
        if (name_obj == NULL)
                goto fail;
        
@@ -603,8 +603,8 @@ _create_tuple_for_X509_NAME (X509_NAME *xname)
                 /*
                 fprintf(stderr, "RDN level %d, attribute %s: %s\n",
                         entry->set,
-                        PyBytes_AS_STRING(PyTuple_GET_ITEM(attr, 0)),
-                        PyBytes_AS_STRING(PyTuple_GET_ITEM(attr, 1)));                        
+                        PyString_AS_STRING(PyTuple_GET_ITEM(attr, 0)),
+                        PyString_AS_STRING(PyTuple_GET_ITEM(attr, 1)));                        
                 */
                if (attr == NULL)
                        goto fail1;
@@ -711,7 +711,7 @@ _get_peer_alt_names (X509 *certificate) {
                                        goto fail;
                                }
 
-                               v = PyBytes_FromString("DirName");
+                               v = PyString_FromString("DirName");
                                if (v == NULL) {
                                        Py_DECREF(t);
                                        goto fail;
@@ -742,13 +742,13 @@ _get_peer_alt_names (X509 *certificate) {
                                t = PyTuple_New(2);
                                if (t == NULL)
                                        goto fail;
-                               v = PyBytes_FromStringAndSize(buf, (vptr - buf));
+                               v = PyString_FromStringAndSize(buf, (vptr - buf));
                                if (v == NULL) {
                                        Py_DECREF(t);
                                        goto fail;
                                }
                                PyTuple_SET_ITEM(t, 0, v);
-                               v = PyBytes_FromStringAndSize((vptr + 1), (len - (vptr - buf + 1)));
+                               v = PyString_FromStringAndSize((vptr + 1), (len - (vptr - buf + 1)));
                                if (v == NULL) {
                                        Py_DECREF(t);
                                        goto fail;
@@ -849,7 +849,7 @@ _decode_certificate (X509 *certificate, int verbose) {
                        _setSSLError(NULL, 0, __FILE__, __LINE__);
                        goto fail1;
                }
-               sn_obj = PyBytes_FromStringAndSize(buf, len);
+               sn_obj = PyString_FromStringAndSize(buf, len);
                if (sn_obj == NULL)
                        goto fail1;
                if (PyDict_SetItemString(retval, "serialNumber", sn_obj) < 0) {
@@ -866,7 +866,7 @@ _decode_certificate (X509 *certificate, int verbose) {
                        _setSSLError(NULL, 0, __FILE__, __LINE__);
                        goto fail1;
                }
-               pnotBefore = PyBytes_FromStringAndSize(buf, len);
+               pnotBefore = PyString_FromStringAndSize(buf, len);
                if (pnotBefore == NULL)
                        goto fail1;
                if (PyDict_SetItemString(retval, "notBefore", pnotBefore) < 0) {
@@ -884,7 +884,7 @@ _decode_certificate (X509 *certificate, int verbose) {
                _setSSLError(NULL, 0, __FILE__, __LINE__);
                goto fail1;
        }
-       pnotAfter = PyBytes_FromStringAndSize(buf, len);
+       pnotAfter = PyString_FromStringAndSize(buf, len);
        if (pnotAfter == NULL)
                goto fail1;
        if (PyDict_SetItemString(retval, "notAfter", pnotAfter) < 0) {
@@ -981,7 +981,7 @@ PySSL_peercert(PySSLObject *self, PyObject *args)
                        PySSL_SetError(self, len, __FILE__, __LINE__);
                        return NULL;
                }
-               retval = PyBytes_FromStringAndSize((const char *) bytes_buf, len);
+               retval = PyString_FromStringAndSize((const char *) bytes_buf, len);
                OPENSSL_free(bytes_buf);
                return retval;
 
@@ -1028,7 +1028,7 @@ static PyObject *PySSL_cipher (PySSLObject *self) {
        if (cipher_name == NULL) {
                PyTuple_SET_ITEM(retval, 0, Py_None);
        } else {
-               v = PyBytes_FromString(cipher_name);
+               v = PyString_FromString(cipher_name);
                if (v == NULL)
                        goto fail0;
                PyTuple_SET_ITEM(retval, 0, v);
@@ -1037,7 +1037,7 @@ static PyObject *PySSL_cipher (PySSLObject *self) {
        if (cipher_protocol == NULL) {
                PyTuple_SET_ITEM(retval, 1, Py_None);
        } else {
-               v = PyBytes_FromString(cipher_protocol);
+               v = PyString_FromString(cipher_protocol);
                if (v == NULL)
                        goto fail0;
                PyTuple_SET_ITEM(retval, 1, v);
@@ -1211,7 +1211,7 @@ static PyObject *PySSL_SSLread(PySSLObject *self, PyObject *args)
        if (!PyArg_ParseTuple(args, "|i:read", &len))
                return NULL;
 
-       if (!(buf = PyBytes_FromStringAndSize((char *) 0, len)))
+       if (!(buf = PyString_FromStringAndSize((char *) 0, len)))
                return NULL;
 
        /* first check if there are bytes ready to be read */
@@ -1233,14 +1233,14 @@ static PyObject *PySSL_SSLread(PySSLObject *self, PyObject *args)
                        return NULL;
                } else if (sockstate == SOCKET_HAS_BEEN_CLOSED) {
                        /* should contain a zero-length string */
-                       _PyBytes_Resize(&buf, 0);
+                       _PyString_Resize(&buf, 0);
                        return buf;
                }
        }
        do {
                err = 0;
                PySSL_BEGIN_ALLOW_THREADS
-               count = SSL_read(self->ssl, PyBytes_AsString(buf), len);
+               count = SSL_read(self->ssl, PyString_AsString(buf), len);
                err = SSL_get_error(self->ssl, count);
                PySSL_END_ALLOW_THREADS
                if(PyErr_CheckSignals()) {
@@ -1257,7 +1257,7 @@ static PyObject *PySSL_SSLread(PySSLObject *self, PyObject *args)
                           (SSL_get_shutdown(self->ssl) ==
                            SSL_RECEIVED_SHUTDOWN))
                {
-                       _PyBytes_Resize(&buf, 0);
+                       _PyString_Resize(&buf, 0);
                        return buf;
                } else {
                        sockstate = SOCKET_OPERATION_OK;
@@ -1276,7 +1276,7 @@ static PyObject *PySSL_SSLread(PySSLObject *self, PyObject *args)
                return PySSL_SetError(self, count, __FILE__, __LINE__);
        }
        if (count != len)
-               _PyBytes_Resize(&buf, count);
+               _PyString_Resize(&buf, count);
        return buf;
 }
 
@@ -1362,11 +1362,11 @@ PySSL_RAND_egd(PyObject *self, PyObject *arg)
 {
     int bytes;
 
-    if (!PyBytes_Check(arg))
+    if (!PyString_Check(arg))
        return PyErr_Format(PyExc_TypeError,
                            "RAND_egd() expected string, found %s",
                            Py_TYPE(arg)->tp_name);
-    bytes = RAND_egd(PyBytes_AS_STRING(arg));
+    bytes = RAND_egd(PyString_AS_STRING(arg));
     if (bytes == -1) {
        PyErr_SetString(PySSLErrorObject,
                        "EGD connection failed or EGD did not return "
index b0351f1c69ca7fe9ad55af5c088ef06ae4932b03..e5fe211f298f34d9b03577275aa50585ddb60a88 100644 (file)
@@ -413,7 +413,7 @@ _range_error(const formatdef *f, int is_unsigned)
                if (msg == NULL)
                        return -1;
                rval = PyErr_WarnEx(PyExc_DeprecationWarning,
-                                   PyBytes_AS_STRING(msg), 2);
+                                   PyString_AS_STRING(msg), 2);
                Py_DECREF(msg);
                if (rval == 0)
                        return 0;
@@ -446,7 +446,7 @@ _range_error(const formatdef *f, int is_unsigned)
 static PyObject *
 nu_char(const char *p, const formatdef *f)
 {
-       return PyBytes_FromStringAndSize(p, 1);
+       return PyString_FromStringAndSize(p, 1);
 }
 
 static PyObject *
@@ -610,12 +610,12 @@ np_ubyte(char *p, PyObject *v, const formatdef *f)
 static int
 np_char(char *p, PyObject *v, const formatdef *f)
 {
-       if (!PyBytes_Check(v) || PyBytes_Size(v) != 1) {
+       if (!PyString_Check(v) || PyString_Size(v) != 1) {
                PyErr_SetString(StructError,
                                "char format require string of length 1");
                return -1;
        }
-       *p = *PyBytes_AsString(v);
+       *p = *PyString_AsString(v);
        return 0;
 }
 
@@ -1335,7 +1335,7 @@ prepare_s(PyStructObject *self)
        char c;
        Py_ssize_t size, len, num, itemsize, x;
 
-       fmt = PyBytes_AS_STRING(self->s_format);
+       fmt = PyString_AS_STRING(self->s_format);
 
        f = whichtable((char **)&fmt);
 
@@ -1503,12 +1503,12 @@ s_unpack_internal(PyStructObject *soself, char *startfrom) {
                const formatdef *e = code->fmtdef;
                const char *res = startfrom + code->offset;
                if (e->format == 's') {
-                       v = PyBytes_FromStringAndSize(res, code->size);
+                       v = PyString_FromStringAndSize(res, code->size);
                } else if (e->format == 'p') {
                        Py_ssize_t n = *(unsigned char*)res;
                        if (n >= code->size)
                                n = code->size - 1;
-                       v = PyBytes_FromStringAndSize(res + 1, n);
+                       v = PyString_FromStringAndSize(res + 1, n);
                } else {
                        v = e->unpack(res, e);
                }
@@ -1542,9 +1542,9 @@ s_unpack(PyObject *self, PyObject *inputstr)
        assert(soself->s_codes != NULL);
        if (inputstr == NULL)
                goto fail;
-       if (PyBytes_Check(inputstr) &&
-               PyBytes_GET_SIZE(inputstr) == soself->s_size) {
-                       return s_unpack_internal(soself, PyBytes_AS_STRING(inputstr));
+       if (PyString_Check(inputstr) &&
+               PyString_GET_SIZE(inputstr) == soself->s_size) {
+                       return s_unpack_internal(soself, PyString_AS_STRING(inputstr));
        }
        args = PyTuple_Pack(1, inputstr);
        if (args == NULL)
@@ -1637,27 +1637,27 @@ s_pack_internal(PyStructObject *soself, PyObject *args, int offset, char* buf)
                const formatdef *e = code->fmtdef;
                char *res = buf + code->offset;
                if (e->format == 's') {
-                       if (!PyBytes_Check(v)) {
+                       if (!PyString_Check(v)) {
                                PyErr_SetString(StructError,
                                                "argument for 's' must be a string");
                                return -1;
                        }
-                       n = PyBytes_GET_SIZE(v);
+                       n = PyString_GET_SIZE(v);
                        if (n > code->size)
                                n = code->size;
                        if (n > 0)
-                               memcpy(res, PyBytes_AS_STRING(v), n);
+                               memcpy(res, PyString_AS_STRING(v), n);
                } else if (e->format == 'p') {
-                       if (!PyBytes_Check(v)) {
+                       if (!PyString_Check(v)) {
                                PyErr_SetString(StructError,
                                                "argument for 'p' must be a string");
                                return -1;
                        }
-                       n = PyBytes_GET_SIZE(v);
+                       n = PyString_GET_SIZE(v);
                        if (n > (code->size - 1))
                                n = code->size - 1;
                        if (n > 0)
-                               memcpy(res + 1, PyBytes_AS_STRING(v), n);
+                               memcpy(res + 1, PyString_AS_STRING(v), n);
                        if (n > 255)
                                n = 255;
                        *res = Py_SAFE_DOWNCAST(n, Py_ssize_t, unsigned char);
@@ -1700,12 +1700,12 @@ s_pack(PyObject *self, PyObject *args)
        }
 
        /* Allocate a new string */
-       result = PyBytes_FromStringAndSize((char *)NULL, soself->s_size);
+       result = PyString_FromStringAndSize((char *)NULL, soself->s_size);
        if (result == NULL)
                return NULL;
 
        /* Call the guts */
-       if ( s_pack_internal(soself, args, 0, PyBytes_AS_STRING(result)) != 0 ) {
+       if ( s_pack_internal(soself, args, 0, PyString_AS_STRING(result)) != 0 ) {
                Py_DECREF(result);
                return NULL;
        }
@@ -2061,7 +2061,7 @@ init_struct(void)
 {
        PyObject *ver, *m;
 
-       ver = PyBytes_FromString("0.2");
+       ver = PyString_FromString("0.2");
        if (ver == NULL)
                return;
 
index 15bd899352911da718a9a919d1f47c8b74316785..4a00fb1975bfbf0125dcf7b1082932871f23b0ee 100644 (file)
@@ -691,7 +691,7 @@ test_thread_state(PyObject *self, PyObject *args)
 }
 #endif
 
-/* Some tests of PyBytes_FromFormat().  This needs more tests. */
+/* Some tests of PyString_FromFormat().  This needs more tests. */
 static PyObject *
 test_string_from_format(PyObject *self, PyObject *args)
 {
@@ -699,10 +699,10 @@ test_string_from_format(PyObject *self, PyObject *args)
        char *msg;
 
 #define CHECK_1_FORMAT(FORMAT, TYPE)                   \
-       result = PyBytes_FromFormat(FORMAT, (TYPE)1);   \
+       result = PyString_FromFormat(FORMAT, (TYPE)1);  \
        if (result == NULL)                             \
                return NULL;                            \
-       if (strcmp(PyBytes_AsString(result), "1")) {    \
+       if (strcmp(PyString_AsString(result), "1")) {   \
                msg = FORMAT " failed at 1";            \
                goto Fail;                              \
        }                                               \
index eb671289b57a7eef558c01b787341ded52a8aca9..4308773419cfd01634528f936ee31a32d016d969 100644 (file)
@@ -335,8 +335,8 @@ WaitForMainloop(TkappObject* self)
 static char *
 AsString(PyObject *value, PyObject *tmp)
 {
-       if (PyBytes_Check(value))
-               return PyBytes_AsString(value);
+       if (PyString_Check(value))
+               return PyString_AsString(value);
 #ifdef Py_USING_UNICODE
        else if (PyUnicode_Check(value)) {
                PyObject *v = PyUnicode_AsUTF8String(value);
@@ -347,7 +347,7 @@ AsString(PyObject *value, PyObject *tmp)
                        return NULL;
                }
                Py_DECREF(v);
-               return PyBytes_AsString(v);
+               return PyString_AsString(v);
        }
 #endif
        else {
@@ -359,7 +359,7 @@ AsString(PyObject *value, PyObject *tmp)
                        return NULL;
                }
                Py_DECREF(v);
-               return PyBytes_AsString(v);
+               return PyString_AsString(v);
        }
 }
 
@@ -462,13 +462,13 @@ Split(char *list)
                 * Could be a quoted string containing funnies, e.g. {"}.
                 * Return the string itself.
                 */
-               return PyBytes_FromString(list);
+               return PyString_FromString(list);
        }
 
        if (argc == 0)
-               v = PyBytes_FromString("");
+               v = PyString_FromString("");
        else if (argc == 1)
-               v = PyBytes_FromString(argv[0]);
+               v = PyString_FromString(argv[0]);
        else if ((v = PyTuple_New(argc)) != NULL) {
                int i;
                PyObject *w;
@@ -530,10 +530,10 @@ SplitObj(PyObject *arg)
                        return result;
                /* Fall through, returning arg. */
        }
-       else if (PyBytes_Check(arg)) {
+       else if (PyString_Check(arg)) {
                int argc;
                char **argv;
-               char *list = PyBytes_AsString(arg);
+               char *list = PyString_AsString(arg);
 
                if (Tcl_SplitList((Tcl_Interp *)NULL, list, &argc, &argv) != TCL_OK) {
                        Py_INCREF(arg);
@@ -541,7 +541,7 @@ SplitObj(PyObject *arg)
                }
                Tcl_Free(FREECAST argv);
                if (argc > 1)
-                       return Split(PyBytes_AsString(arg));
+                       return Split(PyString_AsString(arg));
                /* Fall through, returning arg. */
        }
        Py_INCREF(arg);
@@ -747,12 +747,12 @@ PyTclObject_dealloc(PyTclObject *self)
 static PyObject *
 PyTclObject_str(PyTclObject *self)
 {
-       if (self->string && PyBytes_Check(self->string)) {
+       if (self->string && PyString_Check(self->string)) {
                Py_INCREF(self->string);
                return self->string;
        }
        /* XXX Could cache value if it is an ASCII string. */
-       return PyBytes_FromString(Tcl_GetString(self->value));
+       return PyString_FromString(Tcl_GetString(self->value));
 }
 
 static char*
@@ -778,16 +778,16 @@ PyTclObject_string(PyTclObject *self, void *ignored)
 #ifdef Py_USING_UNICODE
                if (i == len)
                        /* It is an ASCII string. */
-                       self->string = PyBytes_FromStringAndSize(s, len);
+                       self->string = PyString_FromStringAndSize(s, len);
                else {
                        self->string = PyUnicode_DecodeUTF8(s, len, "strict");
                        if (!self->string) {
                                PyErr_Clear();
-                               self->string = PyBytes_FromStringAndSize(s, len);
+                               self->string = PyString_FromStringAndSize(s, len);
                        }
                }
 #else
-               self->string = PyBytes_FromStringAndSize(s, len);
+               self->string = PyString_FromStringAndSize(s, len);
 #endif
                if (!self->string)
                        return NULL;
@@ -820,7 +820,7 @@ PyTclObject_repr(PyTclObject *self)
        char buf[50];
        PyOS_snprintf(buf, 50, "<%s object at %p>",
                      self->value->typePtr->name, self->value);
-       return PyBytes_FromString(buf);
+       return PyString_FromString(buf);
 }
 
 static int
@@ -839,7 +839,7 @@ PyDoc_STRVAR(get_typename__doc__, "name of the Tcl type");
 static PyObject*
 get_typename(PyTclObject* obj, void* ignored)
 {
-       return PyBytes_FromString(obj->value->typePtr->name);
+       return PyString_FromString(obj->value->typePtr->name);
 }
 
 
@@ -908,9 +908,9 @@ AsObj(PyObject *value)
 {
        Tcl_Obj *result;
 
-       if (PyBytes_Check(value))
-               return Tcl_NewStringObj(PyBytes_AS_STRING(value),
-                                       PyBytes_GET_SIZE(value));
+       if (PyString_Check(value))
+               return Tcl_NewStringObj(PyString_AS_STRING(value),
+                                       PyString_GET_SIZE(value));
        else if (PyBool_Check(value))
                return Tcl_NewBooleanObj(PyObject_IsTrue(value));
        else if (PyInt_Check(value))
@@ -999,17 +999,17 @@ FromObj(PyObject* tkapp, Tcl_Obj *value)
                }
 
                if (i == value->length)
-                       result = PyBytes_FromStringAndSize(s, len);
+                       result = PyString_FromStringAndSize(s, len);
                else {
                        /* Convert UTF-8 to Unicode string */
                        result = PyUnicode_DecodeUTF8(s, len, "strict");
                        if (result == NULL) {
                                PyErr_Clear();
-                               result = PyBytes_FromStringAndSize(s, len);
+                               result = PyString_FromStringAndSize(s, len);
                        }
                }
 #else
-               result = PyBytes_FromStringAndSize(value->bytes, value->length);
+               result = PyString_FromStringAndSize(value->bytes, value->length);
 #endif
                return result;
        }
@@ -1023,7 +1023,7 @@ FromObj(PyObject* tkapp, Tcl_Obj *value)
        if (value->typePtr == app->ByteArrayType) {
                int size;
                char *data = (char*)Tcl_GetByteArrayFromObj(value, &size);
-               return PyBytes_FromStringAndSize(data, size);
+               return PyString_FromStringAndSize(data, size);
        }
 
        if (value->typePtr == app->DoubleType) {
@@ -1092,7 +1092,7 @@ FromObj(PyObject* tkapp, Tcl_Obj *value)
                int size;
                char *c;
                c = Tcl_GetStringFromObj(value, &size);
-               return PyBytes_FromStringAndSize(c, size);
+               return PyString_FromStringAndSize(c, size);
 #endif
        }
 
@@ -1204,19 +1204,19 @@ Tkapp_CallResult(TkappObject *self)
                }
 
                if (*p == '\0')
-                       res = PyBytes_FromStringAndSize(s, (int)(p-s));
+                       res = PyString_FromStringAndSize(s, (int)(p-s));
                else {
                        /* Convert UTF-8 to Unicode string */
                        p = strchr(p, '\0');
                        res = PyUnicode_DecodeUTF8(s, (int)(p-s), "strict");
                        if (res == NULL) {
                                PyErr_Clear();
-                               res = PyBytes_FromStringAndSize(s, (int)(p-s));
+                               res = PyString_FromStringAndSize(s, (int)(p-s));
                        }
                }
 #else
                p = strchr(p, '\0');
-               res = PyBytes_FromStringAndSize(s, (int)(p-s));
+               res = PyString_FromStringAndSize(s, (int)(p-s));
 #endif
        }
        return res;
@@ -1370,7 +1370,7 @@ Tkapp_GlobalCall(PyObject *self, PyObject *args)
                if (err == TCL_ERROR)
                        res = Tkinter_Error(self);
                else
-                       res = PyBytes_FromString(Tkapp_Result(self));
+                       res = PyString_FromString(Tkapp_Result(self));
                LEAVE_OVERLAP_TCL
                ckfree(cmd);
        }
@@ -1396,7 +1396,7 @@ Tkapp_Eval(PyObject *self, PyObject *args)
        if (err == TCL_ERROR)
                res = Tkinter_Error(self);
        else
-               res = PyBytes_FromString(Tkapp_Result(self));
+               res = PyString_FromString(Tkapp_Result(self));
        LEAVE_OVERLAP_TCL
        return res;
 }
@@ -1419,7 +1419,7 @@ Tkapp_GlobalEval(PyObject *self, PyObject *args)
        if (err == TCL_ERROR)
                res = Tkinter_Error(self);
        else
-               res = PyBytes_FromString(Tkapp_Result(self));
+               res = PyString_FromString(Tkapp_Result(self));
        LEAVE_OVERLAP_TCL
        return res;
 }
@@ -1443,7 +1443,7 @@ Tkapp_EvalFile(PyObject *self, PyObject *args)
                res = Tkinter_Error(self);
 
        else
-               res = PyBytes_FromString(Tkapp_Result(self));
+               res = PyString_FromString(Tkapp_Result(self));
        LEAVE_OVERLAP_TCL
        return res;
 }
@@ -1466,7 +1466,7 @@ Tkapp_Record(PyObject *self, PyObject *args)
        if (err == TCL_ERROR)
                res = Tkinter_Error(self);
        else
-               res = PyBytes_FromString(Tkapp_Result(self));
+               res = PyString_FromString(Tkapp_Result(self));
        LEAVE_OVERLAP_TCL
        return res;
 }
@@ -1511,8 +1511,8 @@ static int
 varname_converter(PyObject *in, void *_out)
 {
        char **out = (char**)_out;
-       if (PyBytes_Check(in)) {
-               *out = PyBytes_AsString(in);
+       if (PyString_Check(in)) {
+               *out = PyString_AsString(in);
                return 1;
        }
        if (PyTclObject_Check(in)) {
@@ -1676,7 +1676,7 @@ GetVar(PyObject *self, PyObject *args, int flags)
                        res = FromObj(self, tres);
                }
                else {
-                       res = PyBytes_FromString(Tcl_GetString(tres));
+                       res = PyString_FromString(Tcl_GetString(tres));
                }
        }
        LEAVE_OVERLAP_TCL
@@ -1920,7 +1920,7 @@ Tkapp_SplitList(PyObject *self, PyObject *args)
                goto finally;
 
        for (i = 0; i < argc; i++) {
-               PyObject *s = PyBytes_FromString(argv[i]);
+               PyObject *s = PyString_FromString(argv[i]);
                if (!s || PyTuple_SetItem(v, i, s)) {
                        Py_DECREF(v);
                        v = NULL;
@@ -1961,7 +1961,7 @@ Tkapp_Merge(PyObject *self, PyObject *args)
        PyObject *res = NULL;
 
        if (s) {
-               res = PyBytes_FromString(s);
+               res = PyString_FromString(s);
                ckfree(s);
        }
 
@@ -2011,7 +2011,7 @@ PythonCmd(ClientData clientData, Tcl_Interp *interp, int argc, char *argv[])
                return PythonCmd_Error(interp);
 
        for (i = 0; i < (argc - 1); i++) {
-               PyObject *s = PyBytes_FromString(argv[i + 1]);
+               PyObject *s = PyString_FromString(argv[i + 1]);
                if (!s || PyTuple_SetItem(arg, i, s)) {
                        Py_DECREF(arg);
                        return PythonCmd_Error(interp);
@@ -2406,7 +2406,7 @@ Tktt_Repr(PyObject *self)
 
        PyOS_snprintf(buf, sizeof(buf), "<tktimertoken at %p%s>", v,
                        v->func == NULL ? ", handler deleted" : "");
-       return PyBytes_FromString(buf);
+       return PyString_FromString(buf);
 }
 
 static PyObject *
@@ -3087,7 +3087,7 @@ ins_long(PyObject *d, char *name, long val)
 static void
 ins_string(PyObject *d, char *name, char *val)
 {
-       PyObject *v = PyBytes_FromString(val);
+       PyObject *v = PyString_FromString(val);
        if (v) {
                PyDict_SetItemString(d, name, v);
                Py_DECREF(v);
index 60140aea3142305791c5591e00ec15996fd27f3b..7f48fffed4b1ab487677d814a39121b6e85340f7 100644 (file)
@@ -84,7 +84,7 @@ param2python(int resource, int param, ALvalue value, ALparamInfo *pinfo)
                        Py_INCREF(Py_None);
                        return Py_None;
                }
-               return PyBytes_FromString((char *) value.ptr);
+               return PyString_FromString((char *) value.ptr);
        default:
                PyErr_SetString(ErrorObject, "unknown element type");
                return NULL;
@@ -149,12 +149,12 @@ python2param(int resource, ALpv *param, PyObject *value, ALparamInfo *pinfo)
                        PyErr_SetString(ErrorObject, "unknown element type");
                        return -1;
                }
-               if (!PyBytes_Check(value)) {
+               if (!PyString_Check(value)) {
                        PyErr_BadArgument();
                        return -1;
                }
-               param->value.ptr = PyBytes_AS_STRING(value);
-               param->sizeIn = PyBytes_GET_SIZE(value)+1; /*account for NUL*/
+               param->value.ptr = PyString_AS_STRING(value);
+               param->sizeIn = PyString_GET_SIZE(value)+1; /*account for NUL*/
                break;
        case AL_SET_VAL:
        case AL_VECTOR_VAL:
@@ -765,12 +765,12 @@ alp_ReadFrames(alpobject *self, PyObject *args)
                return NULL;
        }
        size *= ch;
-       v = PyBytes_FromStringAndSize((char *) NULL, size * framecount);
+       v = PyString_FromStringAndSize((char *) NULL, size * framecount);
        if (v == NULL)
                return NULL;
 
        Py_BEGIN_ALLOW_THREADS
-       alReadFrames(self->port, (void *) PyBytes_AS_STRING(v), framecount);
+       alReadFrames(self->port, (void *) PyString_AS_STRING(v), framecount);
        Py_END_ALLOW_THREADS
 
        return v;
@@ -1068,12 +1068,12 @@ alp_readsamps(alpobject *self, PyObject *args)
        width = ALgetwidth(c);
 #endif /* AL_405 */
        ALfreeconfig(c);
-       v = PyBytes_FromStringAndSize((char *)NULL, width * count);
+       v = PyString_FromStringAndSize((char *)NULL, width * count);
        if (v == NULL)
                return NULL;
 
        Py_BEGIN_ALLOW_THREADS
-       ret = ALreadsamps(self->port, (void *) PyBytes_AsString(v), count);
+       ret = ALreadsamps(self->port, (void *) PyString_AsString(v), count);
        Py_END_ALLOW_THREADS
        if (ret == -1) {
                Py_DECREF(v);
@@ -1498,7 +1498,7 @@ al_GetParams(PyObject *self, PyObject *args)
                        Py_INCREF(item);
                        break;
                case AL_STRING_VAL:
-                       item = PyBytes_FromString(pvs[i].value.ptr);
+                       item = PyString_FromString(pvs[i].value.ptr);
                        PyMem_DEL(pvs[i].value.ptr);
                        break;
                case AL_MATRIX_VAL:
@@ -1725,7 +1725,7 @@ al_GetParamInfo(PyObject *self, PyObject *args)
        PyDict_SetItemString(v, "elementType", item);
        Py_DECREF(item);
 
-       item = PyBytes_FromString(pinfo.name);
+       item = PyString_FromString(pinfo.name);
        PyDict_SetItemString(v, "name", item);
        Py_DECREF(item);
 
@@ -1920,7 +1920,7 @@ al_getname(PyObject *self, PyObject *args)
                return NULL;
        if ((name = ALgetname(device, descriptor)) == NULL)
                return NULL;
-       return PyBytes_FromString(name);
+       return PyString_FromString(name);
 }
 
 static PyObject *
index 32d34c745298845b567701fe035ef319541037ba..89ed27a0b7480b465622a4300337797bcc42b0f8 100644 (file)
@@ -104,7 +104,7 @@ in bounds; that's the responsibility of the caller.
 static PyObject *
 c_getitem(arrayobject *ap, Py_ssize_t i)
 {
-       return PyBytes_FromStringAndSize(&((char *)ap->ob_item)[i], 1);
+       return PyString_FromStringAndSize(&((char *)ap->ob_item)[i], 1);
 }
 
 static int
@@ -1414,7 +1414,7 @@ values,as if it had been read from a file using the fromfile() method).");
 static PyObject *
 array_tostring(arrayobject *self, PyObject *unused)
 {
-       return PyBytes_FromStringAndSize(self->ob_item,
+       return PyString_FromStringAndSize(self->ob_item,
                                    Py_SIZE(self) * self->ob_descr->itemsize);
 }
 
@@ -1494,7 +1494,7 @@ static PyObject *
 array_get_typecode(arrayobject *a, void *closure)
 {
        char tc = a->ob_descr->typecode;
-       return PyBytes_FromStringAndSize(&tc, 1);
+       return PyString_FromStringAndSize(&tc, 1);
 }
 
 static PyObject *
@@ -1578,7 +1578,7 @@ array_repr(arrayobject *a)
        typecode = a->ob_descr->typecode;
        if (len == 0) {
                PyOS_snprintf(buf, sizeof(buf), "array('%c')", typecode);
-               return PyBytes_FromString(buf);
+               return PyString_FromString(buf);
        }
                
        if (typecode == 'c')
@@ -1593,9 +1593,9 @@ array_repr(arrayobject *a)
        Py_XDECREF(v);
 
        PyOS_snprintf(buf, sizeof(buf), "array('%c', ", typecode);
-       s = PyBytes_FromString(buf);
-       PyBytes_ConcatAndDel(&s, t);
-       PyBytes_ConcatAndDel(&s, PyBytes_FromString(")"));
+       s = PyString_FromString(buf);
+       PyString_ConcatAndDel(&s, t);
+       PyString_ConcatAndDel(&s, PyString_FromString(")"));
        return s;
 }
 
@@ -1881,7 +1881,7 @@ array_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
                return NULL;
 
        if (!(initial == NULL || PyList_Check(initial)
-             || PyBytes_Check(initial) || PyTuple_Check(initial)
+             || PyString_Check(initial) || PyTuple_Check(initial)
              || (c == 'u' && PyUnicode_Check(initial)))) {
                it = PyObject_GetIter(initial);
                if (it == NULL)
@@ -1924,7 +1924,7 @@ array_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
                                        }
                                        Py_DECREF(v);
                                }
-                       } else if (initial != NULL && PyBytes_Check(initial)) {
+                       } else if (initial != NULL && PyString_Check(initial)) {
                                PyObject *t_initial, *v;
                                t_initial = PyTuple_Pack(1, initial);
                                if (t_initial == NULL) {
index 9eb684b5ee263b14c338f482b780da50f8fed014..ce009758dee4e64787c03aa3a3a52ecbfb98461e 100644 (file)
@@ -474,7 +474,7 @@ audioop_findfit(PyObject *self, PyObject *args)
 
        /* Passing a short** for an 's' argument is correct only
           if the string contents is aligned for interpretation
-          as short[]. Due to the definition of PyBytesObject,
+          as short[]. Due to the definition of PyStringObject,
           this is currently (Python 2.6) the case. */
         if ( !PyArg_ParseTuple(args, "s#s#:findfit",
                               (char**)&cp1, &len1, (char**)&cp2, &len2) )
@@ -759,10 +759,10 @@ audioop_mul(PyObject *self, PyObject *args)
                 return 0;
         }
     
-        rv = PyBytes_FromStringAndSize(NULL, len);
+        rv = PyString_FromStringAndSize(NULL, len);
         if ( rv == 0 )
                 return 0;
-        ncp = (signed char *)PyBytes_AsString(rv);
+        ncp = (signed char *)PyString_AsString(rv);
     
     
         for ( i=0; i < len; i += size ) {
@@ -801,10 +801,10 @@ audioop_tomono(PyObject *self, PyObject *args)
                 return 0;
         }
     
-        rv = PyBytes_FromStringAndSize(NULL, len/2);
+        rv = PyString_FromStringAndSize(NULL, len/2);
         if ( rv == 0 )
                 return 0;
-        ncp = (signed char *)PyBytes_AsString(rv);
+        ncp = (signed char *)PyString_AsString(rv);
     
     
         for ( i=0; i < len; i += size*2 ) {
@@ -846,10 +846,10 @@ audioop_tostereo(PyObject *self, PyObject *args)
                 return 0;
         }
     
-        rv = PyBytes_FromStringAndSize(NULL, len*2);
+        rv = PyString_FromStringAndSize(NULL, len*2);
         if ( rv == 0 )
                 return 0;
-        ncp = (signed char *)PyBytes_AsString(rv);
+        ncp = (signed char *)PyString_AsString(rv);
     
     
         for ( i=0; i < len; i += size ) {
@@ -903,10 +903,10 @@ audioop_add(PyObject *self, PyObject *args)
                 return 0;
         }
 
-        rv = PyBytes_FromStringAndSize(NULL, len1);
+        rv = PyString_FromStringAndSize(NULL, len1);
         if ( rv == 0 )
                 return 0;
-        ncp = (signed char *)PyBytes_AsString(rv);
+        ncp = (signed char *)PyString_AsString(rv);
 
         for ( i=0; i < len1; i += size ) {
                 if ( size == 1 )      val1 = (int)*CHARP(cp1, i);
@@ -949,10 +949,10 @@ audioop_bias(PyObject *self, PyObject *args)
                 return 0;
         }
     
-        rv = PyBytes_FromStringAndSize(NULL, len);
+        rv = PyString_FromStringAndSize(NULL, len);
         if ( rv == 0 )
                 return 0;
-        ncp = (signed char *)PyBytes_AsString(rv);
+        ncp = (signed char *)PyString_AsString(rv);
     
     
         for ( i=0; i < len; i += size ) {
@@ -985,10 +985,10 @@ audioop_reverse(PyObject *self, PyObject *args)
                 return 0;
         }
     
-        rv = PyBytes_FromStringAndSize(NULL, len);
+        rv = PyString_FromStringAndSize(NULL, len);
         if ( rv == 0 )
                 return 0;
-        ncp = (unsigned char *)PyBytes_AsString(rv);
+        ncp = (unsigned char *)PyString_AsString(rv);
     
         for ( i=0; i < len; i += size ) {
                 if ( size == 1 )      val = ((int)*CHARP(cp, i)) << 8;
@@ -1023,10 +1023,10 @@ audioop_lin2lin(PyObject *self, PyObject *args)
                 return 0;
         }
     
-        rv = PyBytes_FromStringAndSize(NULL, (len/size)*size2);
+        rv = PyString_FromStringAndSize(NULL, (len/size)*size2);
         if ( rv == 0 )
                 return 0;
-        ncp = (unsigned char *)PyBytes_AsString(rv);
+        ncp = (unsigned char *)PyString_AsString(rv);
     
         for ( i=0, j=0; i < len; i += size, j += size2 ) {
                 if ( size == 1 )      val = ((int)*CHARP(cp, i)) << 8;
@@ -1157,7 +1157,7 @@ audioop_ratecv(PyObject *self, PyObject *args)
                     nbytes / bytes_per_frame != ceiling)
                         str = NULL;
                 else
-                        str = PyBytes_FromStringAndSize(NULL, nbytes);
+                        str = PyString_FromStringAndSize(NULL, nbytes);
 
                 if (str == NULL) {
                         PyErr_SetString(PyExc_MemoryError,
@@ -1165,7 +1165,7 @@ audioop_ratecv(PyObject *self, PyObject *args)
                         goto exit;
                 }
         }
-        ncp = PyBytes_AsString(str);
+        ncp = PyString_AsString(str);
 
         for (;;) {
                 while (d < 0) {
@@ -1182,13 +1182,13 @@ audioop_ratecv(PyObject *self, PyObject *args)
                                         goto exit;
                                 /* We have checked before that the length
                                  * of the string fits into int. */
-                                len = (int)(ncp - PyBytes_AsString(str));
+                                len = (int)(ncp - PyString_AsString(str));
                                 if (len == 0) {
                                         /*don't want to resize to zero length*/
-                                        rv = PyBytes_FromStringAndSize("", 0);
+                                        rv = PyString_FromStringAndSize("", 0);
                                         Py_DECREF(str);
                                         str = rv;
-                                } else if (_PyBytes_Resize(&str, len) < 0)
+                                } else if (_PyString_Resize(&str, len) < 0)
                                         goto exit;
                                 rv = Py_BuildValue("(O(iO))", str, d, samps);
                                 Py_DECREF(samps);
@@ -1255,10 +1255,10 @@ audioop_lin2ulaw(PyObject *self, PyObject *args)
                 return 0;
         }
     
-        rv = PyBytes_FromStringAndSize(NULL, len/size);
+        rv = PyString_FromStringAndSize(NULL, len/size);
         if ( rv == 0 )
                 return 0;
-        ncp = (unsigned char *)PyBytes_AsString(rv);
+        ncp = (unsigned char *)PyString_AsString(rv);
     
         for ( i=0; i < len; i += size ) {
                 if ( size == 1 )      val = ((int)*CHARP(cp, i)) << 8;
@@ -1289,10 +1289,10 @@ audioop_ulaw2lin(PyObject *self, PyObject *args)
                 return 0;
         }
     
-        rv = PyBytes_FromStringAndSize(NULL, len*size);
+        rv = PyString_FromStringAndSize(NULL, len*size);
         if ( rv == 0 )
                 return 0;
-        ncp = (signed char *)PyBytes_AsString(rv);
+        ncp = (signed char *)PyString_AsString(rv);
     
         for ( i=0; i < len*size; i += size ) {
                 cval = *cp++;
@@ -1323,10 +1323,10 @@ audioop_lin2alaw(PyObject *self, PyObject *args)
                 return 0;
         }
     
-        rv = PyBytes_FromStringAndSize(NULL, len/size);
+        rv = PyString_FromStringAndSize(NULL, len/size);
         if ( rv == 0 )
                 return 0;
-        ncp = (unsigned char *)PyBytes_AsString(rv);
+        ncp = (unsigned char *)PyString_AsString(rv);
     
         for ( i=0; i < len; i += size ) {
                 if ( size == 1 )      val = ((int)*CHARP(cp, i)) << 8;
@@ -1357,10 +1357,10 @@ audioop_alaw2lin(PyObject *self, PyObject *args)
                 return 0;
         }
     
-        rv = PyBytes_FromStringAndSize(NULL, len*size);
+        rv = PyString_FromStringAndSize(NULL, len*size);
         if ( rv == 0 )
                 return 0;
-        ncp = (signed char *)PyBytes_AsString(rv);
+        ncp = (signed char *)PyString_AsString(rv);
     
         for ( i=0; i < len*size; i += size ) {
                 cval = *cp++;
@@ -1393,10 +1393,10 @@ audioop_lin2adpcm(PyObject *self, PyObject *args)
                 return 0;
         }
     
-        str = PyBytes_FromStringAndSize(NULL, len/(size*2));
+        str = PyString_FromStringAndSize(NULL, len/(size*2));
         if ( str == 0 )
                 return 0;
-        ncp = (signed char *)PyBytes_AsString(str);
+        ncp = (signed char *)PyString_AsString(str);
 
         /* Decode state, should have (value, step) */
         if ( state == Py_None ) {
@@ -1509,10 +1509,10 @@ audioop_adpcm2lin(PyObject *self, PyObject *args)
         } else if ( !PyArg_ParseTuple(state, "ii", &valpred, &index) )
                 return 0;
     
-        str = PyBytes_FromStringAndSize(NULL, len*size*2);
+        str = PyString_FromStringAndSize(NULL, len*size*2);
         if ( str == 0 )
                 return 0;
-        ncp = (signed char *)PyBytes_AsString(str);
+        ncp = (signed char *)PyString_AsString(str);
 
         step = stepsizeTable[index];
         bufferstep = 0;
index f9df6252ba49df0f62323fb96e7b7270fba3b552..c1fc675cf1d616cefab1fdee5c782bbee980cdf7 100644 (file)
@@ -141,7 +141,7 @@ static char table_a2b_base64[] = {
 #define BASE64_PAD '='
 
 /* Max binary chunk size; limited only by available memory */
-#define BASE64_MAXBIN (INT_MAX/2 - sizeof(PyBytesObject) - 3)
+#define BASE64_MAXBIN (INT_MAX/2 - sizeof(PyStringObject) - 3)
 
 static unsigned char table_b2a_base64[] =
 "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
@@ -203,9 +203,9 @@ binascii_a2b_uu(PyObject *self, PyObject *args)
        ascii_len--;
 
        /* Allocate the buffer */
-       if ( (rv=PyBytes_FromStringAndSize(NULL, bin_len)) == NULL )
+       if ( (rv=PyString_FromStringAndSize(NULL, bin_len)) == NULL )
                return NULL;
-       bin_data = (unsigned char *)PyBytes_AsString(rv);
+       bin_data = (unsigned char *)PyString_AsString(rv);
 
        for( ; bin_len > 0 ; ascii_len--, ascii_data++ ) {
                /* XXX is it really best to add NULs if there's no more data */
@@ -280,9 +280,9 @@ binascii_b2a_uu(PyObject *self, PyObject *args)
        }
 
        /* We're lazy and allocate to much (fixed up later) */
-       if ( (rv=PyBytes_FromStringAndSize(NULL, bin_len*2+2)) == NULL )
+       if ( (rv=PyString_FromStringAndSize(NULL, bin_len*2+2)) == NULL )
                return NULL;
-       ascii_data = (unsigned char *)PyBytes_AsString(rv);
+       ascii_data = (unsigned char *)PyString_AsString(rv);
 
        /* Store the length */
        *ascii_data++ = ' ' + (bin_len & 077);
@@ -304,8 +304,8 @@ binascii_b2a_uu(PyObject *self, PyObject *args)
        }
        *ascii_data++ = '\n';   /* Append a courtesy newline */
 
-       _PyBytes_Resize(&rv, (ascii_data -
-                              (unsigned char *)PyBytes_AsString(rv)));
+       _PyString_Resize(&rv, (ascii_data -
+                              (unsigned char *)PyString_AsString(rv)));
        return rv;
 }
 
@@ -354,9 +354,9 @@ binascii_a2b_base64(PyObject *self, PyObject *args)
        bin_len = ((ascii_len+3)/4)*3; /* Upper bound, corrected later */
 
        /* Allocate the buffer */
-       if ( (rv=PyBytes_FromStringAndSize(NULL, bin_len)) == NULL )
+       if ( (rv=PyString_FromStringAndSize(NULL, bin_len)) == NULL )
                return NULL;
-       bin_data = (unsigned char *)PyBytes_AsString(rv);
+       bin_data = (unsigned char *)PyString_AsString(rv);
        bin_len = 0;
 
        for( ; ascii_len > 0; ascii_len--, ascii_data++) {
@@ -415,13 +415,13 @@ binascii_a2b_base64(PyObject *self, PyObject *args)
 
        /* And set string size correctly. If the result string is empty
        ** (because the input was all invalid) return the shared empty
-       ** string instead; _PyBytes_Resize() won't do this for us.
+       ** string instead; _PyString_Resize() won't do this for us.
        */
        if (bin_len > 0)
-               _PyBytes_Resize(&rv, bin_len);
+               _PyString_Resize(&rv, bin_len);
        else {
                Py_DECREF(rv);
-               rv = PyBytes_FromString("");
+               rv = PyString_FromString("");
        }
        return rv;
 }
@@ -448,9 +448,9 @@ binascii_b2a_base64(PyObject *self, PyObject *args)
        /* We're lazy and allocate too much (fixed up later).
           "+3" leaves room for up to two pad characters and a trailing
           newline.  Note that 'b' gets encoded as 'Yg==\n' (1 in, 5 out). */
-       if ( (rv=PyBytes_FromStringAndSize(NULL, bin_len*2 + 3)) == NULL )
+       if ( (rv=PyString_FromStringAndSize(NULL, bin_len*2 + 3)) == NULL )
                return NULL;
-       ascii_data = (unsigned char *)PyBytes_AsString(rv);
+       ascii_data = (unsigned char *)PyString_AsString(rv);
 
        for( ; bin_len > 0 ; bin_len--, bin_data++ ) {
                /* Shift the data into our buffer */
@@ -474,8 +474,8 @@ binascii_b2a_base64(PyObject *self, PyObject *args)
        }
        *ascii_data++ = '\n';   /* Append a courtesy newline */
 
-       _PyBytes_Resize(&rv, (ascii_data -
-                              (unsigned char *)PyBytes_AsString(rv)));
+       _PyString_Resize(&rv, (ascii_data -
+                              (unsigned char *)PyString_AsString(rv)));
        return rv;
 }
 
@@ -498,9 +498,9 @@ binascii_a2b_hqx(PyObject *self, PyObject *args)
        /* Allocate a string that is too big (fixed later) 
           Add two to the initial length to prevent interning which
           would preclude subsequent resizing.  */
-       if ( (rv=PyBytes_FromStringAndSize(NULL, len+2)) == NULL )
+       if ( (rv=PyString_FromStringAndSize(NULL, len+2)) == NULL )
                return NULL;
-       bin_data = (unsigned char *)PyBytes_AsString(rv);
+       bin_data = (unsigned char *)PyString_AsString(rv);
 
        for( ; len > 0 ; len--, ascii_data++ ) {
                /* Get the byte and look it up */
@@ -534,8 +534,8 @@ binascii_a2b_hqx(PyObject *self, PyObject *args)
                Py_DECREF(rv);
                return NULL;
        }
-       _PyBytes_Resize(
-               &rv, (bin_data - (unsigned char *)PyBytes_AsString(rv)));
+       _PyString_Resize(
+               &rv, (bin_data - (unsigned char *)PyString_AsString(rv)));
        if (rv) {
                PyObject *rrv = Py_BuildValue("Oi", rv, done);
                Py_DECREF(rv);
@@ -559,9 +559,9 @@ binascii_rlecode_hqx(PyObject *self, PyObject *args)
                return NULL;
 
        /* Worst case: output is twice as big as input (fixed later) */
-       if ( (rv=PyBytes_FromStringAndSize(NULL, len*2+2)) == NULL )
+       if ( (rv=PyString_FromStringAndSize(NULL, len*2+2)) == NULL )
                return NULL;
-       out_data = (unsigned char *)PyBytes_AsString(rv);
+       out_data = (unsigned char *)PyString_AsString(rv);
 
        for( in=0; in<len; in++) {
                ch = in_data[in];
@@ -587,8 +587,8 @@ binascii_rlecode_hqx(PyObject *self, PyObject *args)
                        }
                }
        }
-       _PyBytes_Resize(&rv, (out_data -
-                              (unsigned char *)PyBytes_AsString(rv)));
+       _PyString_Resize(&rv, (out_data -
+                              (unsigned char *)PyString_AsString(rv)));
        return rv;
 }
 
@@ -608,9 +608,9 @@ binascii_b2a_hqx(PyObject *self, PyObject *args)
                return NULL;
 
        /* Allocate a buffer that is at least large enough */
-       if ( (rv=PyBytes_FromStringAndSize(NULL, len*2+2)) == NULL )
+       if ( (rv=PyString_FromStringAndSize(NULL, len*2+2)) == NULL )
                return NULL;
-       ascii_data = (unsigned char *)PyBytes_AsString(rv);
+       ascii_data = (unsigned char *)PyString_AsString(rv);
 
        for( ; len > 0 ; len--, bin_data++ ) {
                /* Shift into our buffer, and output any 6bits ready */
@@ -627,8 +627,8 @@ binascii_b2a_hqx(PyObject *self, PyObject *args)
                leftchar <<= (6-leftbits);
                *ascii_data++ = table_b2a_hqx[leftchar & 0x3f];
        }
-       _PyBytes_Resize(&rv, (ascii_data -
-                              (unsigned char *)PyBytes_AsString(rv)));
+       _PyString_Resize(&rv, (ascii_data -
+                              (unsigned char *)PyString_AsString(rv)));
        return rv;
 }
 
@@ -647,14 +647,14 @@ binascii_rledecode_hqx(PyObject *self, PyObject *args)
 
        /* Empty string is a special case */
        if ( in_len == 0 )
-               return PyBytes_FromString("");
+               return PyString_FromString("");
 
        /* Allocate a buffer of reasonable size. Resized when needed */
        out_len = in_len*2;
-       if ( (rv=PyBytes_FromStringAndSize(NULL, out_len)) == NULL )
+       if ( (rv=PyString_FromStringAndSize(NULL, out_len)) == NULL )
                return NULL;
        out_len_left = out_len;
-       out_data = (unsigned char *)PyBytes_AsString(rv);
+       out_data = (unsigned char *)PyString_AsString(rv);
 
        /*
        ** We need two macros here to get/put bytes and handle
@@ -673,9 +673,9 @@ binascii_rledecode_hqx(PyObject *self, PyObject *args)
 #define OUTBYTE(b) \
        do { \
                 if ( --out_len_left < 0 ) { \
-                         _PyBytes_Resize(&rv, 2*out_len); \
+                         _PyString_Resize(&rv, 2*out_len); \
                          if ( rv == NULL ) return NULL; \
-                         out_data = (unsigned char *)PyBytes_AsString(rv) \
+                         out_data = (unsigned char *)PyString_AsString(rv) \
                                                                 + out_len; \
                          out_len_left = out_len-1; \
                          out_len = out_len * 2; \
@@ -723,8 +723,8 @@ binascii_rledecode_hqx(PyObject *self, PyObject *args)
                        OUTBYTE(in_byte);
                }
        }
-       _PyBytes_Resize(&rv, (out_data -
-                              (unsigned char *)PyBytes_AsString(rv)));
+       _PyString_Resize(&rv, (out_data -
+                              (unsigned char *)PyString_AsString(rv)));
        return rv;
 }
 
@@ -923,10 +923,10 @@ binascii_hexlify(PyObject *self, PyObject *args)
        if (!PyArg_ParseTuple(args, "s#:b2a_hex", &argbuf, &arglen))
                return NULL;
 
-       retval = PyBytes_FromStringAndSize(NULL, arglen*2);
+       retval = PyString_FromStringAndSize(NULL, arglen*2);
        if (!retval)
                return NULL;
-       retbuf = PyBytes_AsString(retval);
+       retbuf = PyString_AsString(retval);
        if (!retbuf)
                goto finally;
 
@@ -989,10 +989,10 @@ binascii_unhexlify(PyObject *self, PyObject *args)
                return NULL;
        }
 
-       retval = PyBytes_FromStringAndSize(NULL, (arglen/2));
+       retval = PyString_FromStringAndSize(NULL, (arglen/2));
        if (!retval)
                return NULL;
-       retbuf = PyBytes_AsString(retval);
+       retbuf = PyString_AsString(retval);
        if (!retbuf)
                goto finally;
 
@@ -1106,7 +1106,7 @@ binascii_a2b_qp(PyObject *self, PyObject *args, PyObject *kwargs)
                        out++;
                }
        }
-       if ((rv = PyBytes_FromStringAndSize((char *)odata, out)) == NULL) {
+       if ((rv = PyString_FromStringAndSize((char *)odata, out)) == NULL) {
                PyMem_Free(odata);
                return NULL;
        }
@@ -1306,7 +1306,7 @@ binascii_b2a_qp (PyObject *self, PyObject *args, PyObject *kwargs)
                        }
                }
        }
-       if ((rv = PyBytes_FromStringAndSize((char *)odata, out)) == NULL) {
+       if ((rv = PyString_FromStringAndSize((char *)odata, out)) == NULL) {
                PyMem_Free(odata);
                return NULL;
        }
@@ -1354,7 +1354,7 @@ initbinascii(void)
                return;
 
        d = PyModule_GetDict(m);
-       x = PyBytes_FromString(doc_binascii);
+       x = PyString_FromString(doc_binascii);
        PyDict_SetItemString(d, "__doc__", x);
        Py_XDECREF(x);
 
index aca591e266ea2f23b888a1beb41a12ea207cb78d..09728821e32f80e56bfe5129865b78da1310ce01 100644 (file)
@@ -312,7 +312,7 @@ bsddb_subscript(bsddbobject *dp, PyObject *key)
                return NULL;
        }
 
-       result = PyBytes_FromStringAndSize(data, (int)drec.size);
+       result = PyString_FromStringAndSize(data, (int)drec.size);
        if (data != buf) free(data);
        return result;
 }
@@ -424,7 +424,7 @@ bsddb_keys(bsddbobject *dp)
                if (dp->di_type == DB_RECNO)
                        item = PyInt_FromLong(*((int*)data));
                else
-                       item = PyBytes_FromStringAndSize(data,
+                       item = PyString_FromStringAndSize(data,
                                                          (int)krec.size);
                if (data != buf) free(data);
                if (item == NULL) {
index ee24b5d7af15b008ff7fb09b475b121f9ae90db3..bbabe101e58364b4d3a225aa1bc5f6f3c056f06c 100644 (file)
@@ -34,7 +34,7 @@ typedef fpos_t Py_off_t;
 #error "Large file support, but neither off_t nor fpos_t is large enough."
 #endif
 
-#define BUF(v) PyBytes_AS_STRING((PyBytesObject *)v)
+#define BUF(v) PyString_AS_STRING((PyStringObject *)v)
 
 #define MODE_CLOSED   0
 #define MODE_READ     1
@@ -241,7 +241,7 @@ Util_GetLine(BZ2FileObject *f, int n)
        int univ_newline = f->f_univ_newline;
 
        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;
 
@@ -307,7 +307,7 @@ Util_GetLine(BZ2FileObject *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;
@@ -315,7 +315,7 @@ Util_GetLine(BZ2FileObject *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;
 }
 
@@ -438,10 +438,10 @@ Util_ReadAhead(BZ2FileObject *f, int bufsize)
 
 /* This is a hacked version of Python's
  * fileobject.c:readahead_get_line_skip(). */
-static PyBytesObject *
+static PyStringObject *
 Util_ReadAheadGetLineSkip(BZ2FileObject *f, int skip, int bufsize)
 {
-       PyBytesObject* s;
+       PyStringObject* s;
        char *bufptr;
        char *buf;
        int len;
@@ -452,17 +452,17 @@ Util_ReadAheadGetLineSkip(BZ2FileObject *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 = 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)
                        Util_DropReadAhead(f);
@@ -476,7 +476,7 @@ Util_ReadAheadGetLineSkip(BZ2FileObject *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;
@@ -509,7 +509,7 @@ BZ2File_read(BZ2FileObject *self, PyObject *args)
                case MODE_READ:
                        break;
                case MODE_READ_EOF:
-                       ret = PyBytes_FromString("");
+                       ret = PyString_FromString("");
                        goto cleanup;
                case MODE_CLOSED:
                        PyErr_SetString(PyExc_ValueError,
@@ -531,7 +531,7 @@ BZ2File_read(BZ2FileObject *self, PyObject *args)
                                "more than a Python string can hold");
                goto cleanup;
        }
-       ret = PyBytes_FromStringAndSize((char *)NULL, buffersize);
+       ret = PyString_FromStringAndSize((char *)NULL, buffersize);
        if (ret == NULL)
                goto cleanup;
        bytesread = 0;
@@ -557,14 +557,14 @@ BZ2File_read(BZ2FileObject *self, PyObject *args)
                }
                if (bytesrequested < 0) {
                        buffersize = Util_NewBufferSize(buffersize);
-                       if (_PyBytes_Resize(&ret, buffersize) < 0)
+                       if (_PyString_Resize(&ret, buffersize) < 0)
                                goto cleanup;
                } else {
                        break;
                }
        }
        if (bytesread != buffersize)
-               _PyBytes_Resize(&ret, bytesread);
+               _PyString_Resize(&ret, bytesread);
 
 cleanup:
        RELEASE_LOCK(self);
@@ -594,7 +594,7 @@ BZ2File_readline(BZ2FileObject *self, PyObject *args)
                case MODE_READ:
                        break;
                case MODE_READ_EOF:
-                       ret = PyBytes_FromString("");
+                       ret = PyString_FromString("");
                        goto cleanup;
                case MODE_CLOSED:
                        PyErr_SetString(PyExc_ValueError,
@@ -607,7 +607,7 @@ BZ2File_readline(BZ2FileObject *self, PyObject *args)
        }
 
        if (sizehint == 0)
-               ret = PyBytes_FromString("");
+               ret = PyString_FromString("");
        else
                ret = Util_GetLine(self, (sizehint < 0) ? 0 : sizehint);
 
@@ -701,17 +701,17 @@ BZ2File_readlines(BZ2FileObject *self, 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 */
-                               _PyBytes_Resize(&big_buffer, buffersize);
-                               buffer = PyBytes_AS_STRING(big_buffer);
+                               _PyString_Resize(&big_buffer, buffersize);
+                               buffer = PyString_AS_STRING(big_buffer);
                        }
                        continue;                       
                }
@@ -720,7 +720,7 @@ BZ2File_readlines(BZ2FileObject *self, PyObject *args)
                while (p != NULL) {
                        /* 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);
@@ -743,7 +743,7 @@ BZ2File_readlines(BZ2FileObject *self, 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) {
@@ -753,7 +753,7 @@ BZ2File_readlines(BZ2FileObject *self, PyObject *args)
                                Py_DECREF(line);
                                goto error;
                        }
-                       PyBytes_Concat(&line, rest);
+                       PyString_Concat(&line, rest);
                        Py_DECREF(rest);
                        if (line == NULL)
                                goto error;
@@ -915,7 +915,7 @@ BZ2File_writelines(BZ2FileObject *self, 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;
                                Py_ssize_t len;
                                if (PyObject_AsCharBuffer(v, &buffer, &len)) {
@@ -926,7 +926,7 @@ BZ2File_writelines(BZ2FileObject *self, PyObject *seq)
                                                        "strings");
                                        goto error;
                                }
-                               line = PyBytes_FromStringAndSize(buffer,
+                               line = PyString_FromStringAndSize(buffer,
                                                                  len);
                                if (line == NULL)
                                        goto error;
@@ -942,9 +942,9 @@ BZ2File_writelines(BZ2FileObject *self, PyObject *seq)
                Py_BEGIN_ALLOW_THREADS
                for (i = 0; i < j; i++) {
                        line = PyList_GET_ITEM(list, i);
-                       len = PyBytes_GET_SIZE(line);
+                       len = PyString_GET_SIZE(line);
                        BZ2_bzWrite (&bzerror, self->fp,
-                                    PyBytes_AS_STRING(line), len);
+                                    PyString_AS_STRING(line), len);
                        if (bzerror != BZ_OK) {
                                Py_BLOCK_THREADS
                                Util_CatchBZ2Error(bzerror);
@@ -1224,13 +1224,13 @@ BZ2File_get_newlines(BZ2FileObject *self, 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:
@@ -1448,7 +1448,7 @@ BZ2File_getiter(BZ2FileObject *self)
 static PyObject *
 BZ2File_iternext(BZ2FileObject *self)
 {
-       PyBytesObject* ret;
+       PyStringObject* ret;
        ACQUIRE_LOCK(self);
        if (self->mode == MODE_CLOSED) {
                PyErr_SetString(PyExc_ValueError,
@@ -1457,7 +1457,7 @@ BZ2File_iternext(BZ2FileObject *self)
        }
        ret = Util_ReadAheadGetLineSkip(self, 0, READAHEAD_BUFSIZE);
        RELEASE_LOCK(self);
-       if (ret == NULL || PyBytes_GET_SIZE(ret) == 0) {
+       if (ret == NULL || PyString_GET_SIZE(ret) == 0) {
                Py_XDECREF(ret);
                return NULL;
        }
@@ -1559,7 +1559,7 @@ BZ2Comp_compress(BZ2CompObject *self, PyObject *args)
                return NULL;
 
        if (datasize == 0)
-               return PyBytes_FromString("");
+               return PyString_FromString("");
 
        ACQUIRE_LOCK(self);
        if (!self->running) {
@@ -1568,7 +1568,7 @@ BZ2Comp_compress(BZ2CompObject *self, PyObject *args)
                goto error;
        }
 
-       ret = PyBytes_FromStringAndSize(NULL, bufsize);
+       ret = PyString_FromStringAndSize(NULL, bufsize);
        if (!ret)
                goto error;
 
@@ -1591,7 +1591,7 @@ BZ2Comp_compress(BZ2CompObject *self, PyObject *args)
                        break; /* no more input data */
                if (bzs->avail_out == 0) {
                        bufsize = Util_NewBufferSize(bufsize);
-                       if (_PyBytes_Resize(&ret, bufsize) < 0) {
+                       if (_PyString_Resize(&ret, bufsize) < 0) {
                                BZ2_bzCompressEnd(bzs);
                                goto error;
                        }
@@ -1601,7 +1601,7 @@ BZ2Comp_compress(BZ2CompObject *self, PyObject *args)
                }
        }
 
-       _PyBytes_Resize(&ret, (Py_ssize_t)(BZS_TOTAL_OUT(bzs) - totalout));
+       _PyString_Resize(&ret, (Py_ssize_t)(BZS_TOTAL_OUT(bzs) - totalout));
 
        RELEASE_LOCK(self);
        return ret;
@@ -1636,7 +1636,7 @@ BZ2Comp_flush(BZ2CompObject *self)
        }
        self->running = 0;
 
-       ret = PyBytes_FromStringAndSize(NULL, bufsize);
+       ret = PyString_FromStringAndSize(NULL, bufsize);
        if (!ret)
                goto error;
 
@@ -1657,7 +1657,7 @@ BZ2Comp_flush(BZ2CompObject *self)
                }
                if (bzs->avail_out == 0) {
                        bufsize = Util_NewBufferSize(bufsize);
-                       if (_PyBytes_Resize(&ret, bufsize) < 0)
+                       if (_PyString_Resize(&ret, bufsize) < 0)
                                goto error;
                        bzs->next_out = BUF(ret);
                        bzs->next_out = BUF(ret) + (BZS_TOTAL_OUT(bzs)
@@ -1667,7 +1667,7 @@ BZ2Comp_flush(BZ2CompObject *self)
        }
 
        if (bzs->avail_out != 0)
-               _PyBytes_Resize(&ret, (Py_ssize_t)(BZS_TOTAL_OUT(bzs) - totalout));
+               _PyString_Resize(&ret, (Py_ssize_t)(BZS_TOTAL_OUT(bzs) - totalout));
 
        RELEASE_LOCK(self);
        return ret;
@@ -1849,7 +1849,7 @@ BZ2Decomp_decompress(BZ2DecompObject *self, PyObject *args)
                goto error;
        }
 
-       ret = PyBytes_FromStringAndSize(NULL, bufsize);
+       ret = PyString_FromStringAndSize(NULL, bufsize);
        if (!ret)
                goto error;
 
@@ -1868,7 +1868,7 @@ BZ2Decomp_decompress(BZ2DecompObject *self, PyObject *args)
                        if (bzs->avail_in != 0) {
                                Py_DECREF(self->unused_data);
                                self->unused_data =
-                                   PyBytes_FromStringAndSize(bzs->next_in,
+                                   PyString_FromStringAndSize(bzs->next_in,
                                                               bzs->avail_in);
                        }
                        self->running = 0;
@@ -1882,7 +1882,7 @@ BZ2Decomp_decompress(BZ2DecompObject *self, PyObject *args)
                        break; /* no more input data */
                if (bzs->avail_out == 0) {
                        bufsize = Util_NewBufferSize(bufsize);
-                       if (_PyBytes_Resize(&ret, bufsize) < 0) {
+                       if (_PyString_Resize(&ret, bufsize) < 0) {
                                BZ2_bzDecompressEnd(bzs);
                                goto error;
                        }
@@ -1894,7 +1894,7 @@ BZ2Decomp_decompress(BZ2DecompObject *self, PyObject *args)
        }
 
        if (bzs->avail_out != 0)
-               _PyBytes_Resize(&ret, (Py_ssize_t)(BZS_TOTAL_OUT(bzs) - totalout));
+               _PyString_Resize(&ret, (Py_ssize_t)(BZS_TOTAL_OUT(bzs) - totalout));
 
        RELEASE_LOCK(self);
        return ret;
@@ -1930,7 +1930,7 @@ BZ2Decomp_init(BZ2DecompObject *self, PyObject *args, PyObject *kwargs)
        }
 #endif
 
-       self->unused_data = PyBytes_FromString("");
+       self->unused_data = PyString_FromString("");
        if (!self->unused_data)
                goto error;
 
@@ -2063,7 +2063,7 @@ bz2_compress(PyObject *self, PyObject *args, PyObject *kwargs)
         * data in one shot. We will check it later anyway. */
        bufsize = datasize + (datasize/100+1) + 600;
 
-       ret = PyBytes_FromStringAndSize(NULL, bufsize);
+       ret = PyString_FromStringAndSize(NULL, bufsize);
        if (!ret)
                return NULL;
 
@@ -2095,7 +2095,7 @@ bz2_compress(PyObject *self, PyObject *args, PyObject *kwargs)
                }
                if (bzs->avail_out == 0) {
                        bufsize = Util_NewBufferSize(bufsize);
-                       if (_PyBytes_Resize(&ret, bufsize) < 0) {
+                       if (_PyString_Resize(&ret, bufsize) < 0) {
                                BZ2_bzCompressEnd(bzs);
                                Py_DECREF(ret);
                                return NULL;
@@ -2106,7 +2106,7 @@ bz2_compress(PyObject *self, PyObject *args, PyObject *kwargs)
        }
 
        if (bzs->avail_out != 0)
-               _PyBytes_Resize(&ret, (Py_ssize_t)BZS_TOTAL_OUT(bzs));
+               _PyString_Resize(&ret, (Py_ssize_t)BZS_TOTAL_OUT(bzs));
        BZ2_bzCompressEnd(bzs);
 
        return ret;
@@ -2134,9 +2134,9 @@ bz2_decompress(PyObject *self, PyObject *args)
                return NULL;
 
        if (datasize == 0)
-               return PyBytes_FromString("");
+               return PyString_FromString("");
 
-       ret = PyBytes_FromStringAndSize(NULL, bufsize);
+       ret = PyString_FromStringAndSize(NULL, bufsize);
        if (!ret)
                return NULL;
 
@@ -2175,7 +2175,7 @@ bz2_decompress(PyObject *self, PyObject *args)
                }
                if (bzs->avail_out == 0) {
                        bufsize = Util_NewBufferSize(bufsize);
-                       if (_PyBytes_Resize(&ret, bufsize) < 0) {
+                       if (_PyString_Resize(&ret, bufsize) < 0) {
                                BZ2_bzDecompressEnd(bzs);
                                Py_DECREF(ret);
                                return NULL;
@@ -2186,7 +2186,7 @@ bz2_decompress(PyObject *self, PyObject *args)
        }
 
        if (bzs->avail_out != 0)
-               _PyBytes_Resize(&ret, (Py_ssize_t)BZS_TOTAL_OUT(bzs));
+               _PyString_Resize(&ret, (Py_ssize_t)BZS_TOTAL_OUT(bzs));
        BZ2_bzDecompressEnd(bzs);
 
        return ret;
@@ -2223,7 +2223,7 @@ initbz2(void)
        if (m == NULL)
                return;
 
-       PyModule_AddObject(m, "__author__", PyBytes_FromString(__author__));
+       PyModule_AddObject(m, "__author__", PyString_FromString(__author__));
 
        Py_INCREF(&BZ2File_Type);
        PyModule_AddObject(m, "BZ2File", (PyObject *)&BZ2File_Type);
index 4413272be5dd0c58037a890909a1117bf6ed81bb..f13008783e82b5c23d368759c26180fa26e7b43a 100644 (file)
@@ -393,13 +393,13 @@ cPickle_ErrFormat(PyObject *ErrType, char *stringformat, char *format, ...)
        if (format) args = Py_VaBuildValue(format, va);
        va_end(va);
        if (format && ! args) return NULL;
-       if (stringformat && !(retval=PyBytes_FromString(stringformat)))
+       if (stringformat && !(retval=PyString_FromString(stringformat)))
                return NULL;
 
        if (retval) {
                if (args) {
                        PyObject *v;
-                       v=PyBytes_Format(retval, args);
+                       v=PyString_Format(retval, args);
                        Py_DECREF(retval);
                        Py_DECREF(args);
                        if (! v) return NULL;
@@ -477,7 +477,7 @@ write_other(Picklerobject *self, const char *s, Py_ssize_t  _n)
        n = (int)_n;
        if (s == NULL) {
                if (!( self->buf_size ))  return 0;
-               py_str = PyBytes_FromStringAndSize(self->write_buf,
+               py_str = PyString_FromStringAndSize(self->write_buf,
                                                    self->buf_size);
                if (!py_str)
                        return -1;
@@ -490,7 +490,7 @@ write_other(Picklerobject *self, const char *s, Py_ssize_t  _n)
 
                if (n > WRITE_BUF_SIZE) {
                        if (!( py_str =
-                              PyBytes_FromStringAndSize(s, n)))
+                              PyString_FromStringAndSize(s, n)))
                                return -1;
                }
                else {
@@ -655,7 +655,7 @@ read_other(Unpicklerobject *self, char **s, Py_ssize_t  n)
        Py_XDECREF(self->last_string);
        self->last_string = str;
 
-       if (! (*s = PyBytes_AsString(str))) return -1;
+       if (! (*s = PyString_AsString(str))) return -1;
        return n;
 }
 
@@ -670,13 +670,13 @@ readline_other(Unpicklerobject *self, char **s)
                return -1;
        }
 
-       if ((str_size = PyBytes_Size(str)) < 0)
+       if ((str_size = PyString_Size(str)) < 0)
                return -1;
 
        Py_XDECREF(self->last_string);
        self->last_string = str;
 
-       if (! (*s = PyBytes_AsString(str)))
+       if (! (*s = PyString_AsString(str)))
                return -1;
 
        return str_size;
@@ -1078,9 +1078,9 @@ save_long(Picklerobject *self, PyObject *args)
                                "to pickle");
                        goto finally;
                }
-               repr = PyBytes_FromStringAndSize(NULL, (int)nbytes);
+               repr = PyString_FromStringAndSize(NULL, (int)nbytes);
                if (repr == NULL) goto finally;
-               pdata = (unsigned char *)PyBytes_AS_STRING(repr);
+               pdata = (unsigned char *)PyString_AS_STRING(repr);
                i = _PyLong_AsByteArray((PyLongObject *)args,
                                pdata, nbytes,
                                1 /* little endian */, 1 /* signed */);
@@ -1121,14 +1121,14 @@ save_long(Picklerobject *self, PyObject *args)
        if (!( repr = PyObject_Repr(args)))
                goto finally;
 
-       if ((size = PyBytes_Size(repr)) < 0)
+       if ((size = PyString_Size(repr)) < 0)
                goto finally;
 
        if (self->write_func(self, &l, 1) < 0)
                goto finally;
 
        if (self->write_func(self,
-                            PyBytes_AS_STRING((PyBytesObject *)repr),
+                            PyString_AS_STRING((PyStringObject *)repr),
                                                size) < 0)
                goto finally;
 
@@ -1177,7 +1177,7 @@ save_string(Picklerobject *self, PyObject *args, int doput)
        int size, len;
        PyObject *repr=0;
 
-       if ((size = PyBytes_Size(args)) < 0)
+       if ((size = PyString_Size(args)) < 0)
                return -1;
 
        if (!self->bin) {
@@ -1188,9 +1188,9 @@ save_string(Picklerobject *self, PyObject *args, int doput)
                if (!( repr = PyObject_Repr(args)))
                        return -1;
 
-               if ((len = PyBytes_Size(repr)) < 0)
+               if ((len = PyString_Size(repr)) < 0)
                        goto err;
-               repr_str = PyBytes_AS_STRING((PyBytesObject *)repr);
+               repr_str = PyString_AS_STRING((PyStringObject *)repr);
 
                if (self->write_func(self, &string, 1) < 0)
                        goto err;
@@ -1207,7 +1207,7 @@ save_string(Picklerobject *self, PyObject *args, int doput)
                int i;
                char c_str[5];
 
-               if ((size = PyBytes_Size(args)) < 0)
+               if ((size = PyString_Size(args)) < 0)
                        return -1;
 
                if (size < 256) {
@@ -1233,8 +1233,8 @@ save_string(Picklerobject *self, PyObject *args, int doput)
                }
                else {
                        if (self->write_func(self,
-                                            PyBytes_AS_STRING(
-                                               (PyBytesObject *)args),
+                                            PyString_AS_STRING(
+                                               (PyStringObject *)args),
                                             size) < 0)
                                return -1;
                }
@@ -1264,13 +1264,13 @@ modified_EncodeRawUnicodeEscape(const Py_UNICODE *s, int size)
 
        static const char *hexdigit = "0123456789ABCDEF";
 
-       repr = PyBytes_FromStringAndSize(NULL, 6 * size);
+       repr = PyString_FromStringAndSize(NULL, 6 * size);
        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++;
                /* Map 16-bit characters to '\uxxxx' */
@@ -1287,7 +1287,7 @@ modified_EncodeRawUnicodeEscape(const Py_UNICODE *s, int size)
                        *p++ = (char) ch;
        }
        *p = '\0';
-       _PyBytes_Resize(&repr, p - q);
+       _PyString_Resize(&repr, p - q);
        return repr;
 }
 
@@ -1310,9 +1310,9 @@ save_unicode(Picklerobject *self, PyObject *args, int doput)
                if (!repr)
                        return -1;
 
-               if ((len = PyBytes_Size(repr)) < 0)
+               if ((len = PyString_Size(repr)) < 0)
                        goto err;
-               repr_str = PyBytes_AS_STRING((PyBytesObject *)repr);
+               repr_str = PyString_AS_STRING((PyStringObject *)repr);
 
                if (self->write_func(self, &string, 1) < 0)
                        goto err;
@@ -1332,7 +1332,7 @@ save_unicode(Picklerobject *self, PyObject *args, int doput)
                if (!( repr = PyUnicode_AsUTF8String(args)))
                        return -1;
 
-               if ((size = PyBytes_Size(repr)) < 0)
+               if ((size = PyString_Size(repr)) < 0)
                        goto err;
                if (size > INT_MAX)
                        return -1;   /* string too large */
@@ -1351,7 +1351,7 @@ save_unicode(Picklerobject *self, PyObject *args, int doput)
                        PDATA_APPEND(self->file, repr, -1);
                }
                else {
-                       if (self->write_func(self, PyBytes_AS_STRING(repr),
+                       if (self->write_func(self, PyString_AS_STRING(repr),
                                             size) < 0)
                                goto err;
                }
@@ -1861,12 +1861,12 @@ save_inst(Picklerobject *self, PyObject *args)
                        goto finally;
 
 
-               if ((module_size = PyBytes_Size(module)) < 0 ||
-                   (name_size = PyBytes_Size(name)) < 0)
+               if ((module_size = PyString_Size(module)) < 0 ||
+                   (name_size = PyString_Size(name)) < 0)
                        goto finally;
 
-               module_str = PyBytes_AS_STRING((PyBytesObject *)module);
-               name_str   = PyBytes_AS_STRING((PyBytesObject *)name);
+               module_str = PyString_AS_STRING((PyStringObject *)module);
+               name_str   = PyString_AS_STRING((PyStringObject *)name);
 
                if (self->write_func(self, &inst, 1) < 0)
                        goto finally;
@@ -1961,12 +1961,12 @@ save_global(Picklerobject *self, PyObject *args, PyObject *name)
        if (!( module = whichmodule(args, global_name)))
                goto finally;
 
-       if ((module_size = PyBytes_Size(module)) < 0 ||
-           (name_size = PyBytes_Size(global_name)) < 0)
+       if ((module_size = PyString_Size(module)) < 0 ||
+           (name_size = PyString_Size(global_name)) < 0)
                goto finally;
 
-       module_str = PyBytes_AS_STRING((PyBytesObject *)module);
-       name_str   = PyBytes_AS_STRING((PyBytesObject *)global_name);
+       module_str = PyString_AS_STRING((PyStringObject *)module);
+       name_str   = PyString_AS_STRING((PyStringObject *)global_name);
 
        /* XXX This can be doing a relative import.  Clearly it shouldn't,
           but I don't know how to stop it. :-( */
@@ -2099,7 +2099,7 @@ save_pers(Picklerobject *self, PyObject *args, PyObject *f)
 
        if (pid != Py_None) {
                if (!self->bin) {
-                       if (!PyBytes_Check(pid)) {
+                       if (!PyString_Check(pid)) {
                                PyErr_SetString(PicklingError,
                                                "persistent id must be string");
                                goto finally;
@@ -2108,12 +2108,12 @@ save_pers(Picklerobject *self, PyObject *args, PyObject *f)
                        if (self->write_func(self, &persid, 1) < 0)
                                goto finally;
 
-                       if ((size = PyBytes_Size(pid)) < 0)
+                       if ((size = PyString_Size(pid)) < 0)
                                goto finally;
 
                        if (self->write_func(self,
-                                            PyBytes_AS_STRING(
-                                               (PyBytesObject *)pid),
+                                            PyString_AS_STRING(
+                                               (PyStringObject *)pid),
                                             size) < 0)
                                goto finally;
 
@@ -2194,8 +2194,8 @@ save_reduce(Picklerobject *self, PyObject *args, PyObject *ob)
                        use_newobj = 0;
                }
                else {
-                       use_newobj = PyBytes_Check(temp) &&
-                                    strcmp(PyBytes_AS_STRING(temp),
+                       use_newobj = PyString_Check(temp) &&
+                                    strcmp(PyString_AS_STRING(temp),
                                            "__newobj__") == 0;
                        Py_DECREF(temp);
                }
@@ -2362,14 +2362,14 @@ save(Picklerobject *self, PyObject *args, int pers_save)
                break;
 
         case 's':
-               if ((type == &PyBytes_Type) && (PyBytes_GET_SIZE(args) < 2)) {
+               if ((type == &PyString_Type) && (PyString_GET_SIZE(args) < 2)) {
                        res = save_string(self, args, 0);
                        goto finally;
                }
 
 #ifdef Py_USING_UNICODE
         case 'u':
-               if ((type == &PyUnicode_Type) && (PyBytes_GET_SIZE(args) < 2)) {
+               if ((type == &PyUnicode_Type) && (PyString_GET_SIZE(args) < 2)) {
                        res = save_unicode(self, args, 0);
                        goto finally;
                }
@@ -2391,7 +2391,7 @@ save(Picklerobject *self, PyObject *args, int pers_save)
 
        switch (type->tp_name[0]) {
         case 's':
-               if (type == &PyBytes_Type) {
+               if (type == &PyString_Type) {
                        res = save_string(self, args, 1);
                        goto finally;
                }
@@ -2526,7 +2526,7 @@ save(Picklerobject *self, PyObject *args, int pers_save)
        if (t == NULL)
                goto finally;
 
-       if (PyBytes_Check(t)) {
+       if (PyString_Check(t)) {
                res = save_global(self, args, t);
                goto finally;
        }
@@ -2640,8 +2640,8 @@ Pickle_getvalue(Picklerobject *self, PyObject *args)
        for (rsize = 0, i = l; --i >= 0; ) {
                k = data->data[i];
 
-               if (PyBytes_Check(k))
-                       rsize += PyBytes_GET_SIZE(k);
+               if (PyString_Check(k))
+                       rsize += PyString_GET_SIZE(k);
 
                else if (PyInt_Check(k)) { /* put */
                        ik = PyInt_AS_LONG((PyIntObject*)k);
@@ -2676,17 +2676,17 @@ Pickle_getvalue(Picklerobject *self, PyObject *args)
        }
 
        /* Now generate the result */
-       r = PyBytes_FromStringAndSize(NULL, rsize);
+       r = PyString_FromStringAndSize(NULL, rsize);
        if (r == NULL) goto err;
-       s = PyBytes_AS_STRING((PyBytesObject *)r);
+       s = PyString_AS_STRING((PyStringObject *)r);
 
        for (i = 0; i < l; i++) {
                k = data->data[i];
 
-               if (PyBytes_Check(k)) {
-                       ssize = PyBytes_GET_SIZE(k);
+               if (PyString_Check(k)) {
+                       ssize = PyString_GET_SIZE(k);
                        if (ssize) {
-                               p=PyBytes_AS_STRING((PyBytesObject *)k);
+                               p=PyString_AS_STRING((PyStringObject *)k);
                                while (--ssize >= 0)
                                        *s++ = *p++;
                        }
@@ -3410,7 +3410,7 @@ load_string(Unpicklerobject *self)
                goto insecure;
        /********************************************/
 
-       str = PyBytes_DecodeEscape(p, len, NULL, 0, NULL);
+       str = PyString_DecodeEscape(p, len, NULL, 0, NULL);
        free(s);
        if (str) {
                PDATA_PUSH(self->stack, str, -1);
@@ -3439,7 +3439,7 @@ load_binstring(Unpicklerobject *self)
        if (self->read_func(self, &s, l) < 0)
                return -1;
 
-       if (!( py_string = PyBytes_FromStringAndSize(s, l)))
+       if (!( py_string = PyString_FromStringAndSize(s, l)))
                return -1;
 
        PDATA_PUSH(self->stack, py_string, -1);
@@ -3461,7 +3461,7 @@ load_short_binstring(Unpicklerobject *self)
 
        if (self->read_func(self, &s, l) < 0) return -1;
 
-       if (!( py_string = PyBytes_FromStringAndSize(s, l)))  return -1;
+       if (!( py_string = PyString_FromStringAndSize(s, l)))  return -1;
 
        PDATA_PUSH(self->stack, py_string, -1);
        return 0;
@@ -3688,12 +3688,12 @@ load_inst(Unpicklerobject *self)
 
        if ((len = self->readline_func(self, &s)) < 0) return -1;
        if (len < 2) return bad_readline();
-       module_name = PyBytes_FromStringAndSize(s, len - 1);
+       module_name = PyString_FromStringAndSize(s, len - 1);
        if (!module_name)  return -1;
 
        if ((len = self->readline_func(self, &s)) >= 0) {
                if (len < 2) return bad_readline();
-               if ((class_name = PyBytes_FromStringAndSize(s, len - 1))) {
+               if ((class_name = PyString_FromStringAndSize(s, len - 1))) {
                        class = find_class(module_name, class_name,
                                           self->find_class);
                        Py_DECREF(class_name);
@@ -3772,7 +3772,7 @@ load_global(Unpicklerobject *self)
 
        if ((len = self->readline_func(self, &s)) < 0) return -1;
        if (len < 2) return bad_readline();
-       module_name = PyBytes_FromStringAndSize(s, len - 1);
+       module_name = PyString_FromStringAndSize(s, len - 1);
        if (!module_name)  return -1;
 
        if ((len = self->readline_func(self, &s)) >= 0) {
@@ -3780,7 +3780,7 @@ load_global(Unpicklerobject *self)
                        Py_DECREF(module_name);
                        return bad_readline();
                }
-               if ((class_name = PyBytes_FromStringAndSize(s, len - 1))) {
+               if ((class_name = PyString_FromStringAndSize(s, len - 1))) {
                        class = find_class(module_name, class_name,
                                           self->find_class);
                        Py_DECREF(class_name);
@@ -3805,7 +3805,7 @@ load_persid(Unpicklerobject *self)
                if ((len = self->readline_func(self, &s)) < 0) return -1;
                if (len < 2) return bad_readline();
 
-               pid = PyBytes_FromStringAndSize(s, len - 1);
+               pid = PyString_FromStringAndSize(s, len - 1);
                if (!pid)  return -1;
 
                if (PyList_Check(self->pers_func)) {
@@ -3938,7 +3938,7 @@ load_get(Unpicklerobject *self)
        if ((len = self->readline_func(self, &s)) < 0) return -1;
        if (len < 2) return bad_readline();
 
-       if (!( py_str = PyBytes_FromStringAndSize(s, len - 1)))  return -1;
+       if (!( py_str = PyString_FromStringAndSize(s, len - 1)))  return -1;
 
        value = PyDict_GetItem(self->memo, py_str);
        if (! value) {
@@ -4064,8 +4064,8 @@ load_extension(Unpicklerobject *self, int nbytes)
         * confirm that pair is really a 2-tuple of strings.
         */
        if (!PyTuple_Check(pair) || PyTuple_Size(pair) != 2 ||
-           !PyBytes_Check(module_name = PyTuple_GET_ITEM(pair, 0)) ||
-           !PyBytes_Check(class_name = PyTuple_GET_ITEM(pair, 1))) {
+           !PyString_Check(module_name = PyTuple_GET_ITEM(pair, 0)) ||
+           !PyString_Check(class_name = PyTuple_GET_ITEM(pair, 1))) {
                Py_DECREF(py_code);
                PyErr_Format(PyExc_ValueError, "_inverted_registry[%ld] "
                             "isn't a 2-tuple of strings", code);
@@ -4098,7 +4098,7 @@ load_put(Unpicklerobject *self)
        if ((l = self->readline_func(self, &s)) < 0) return -1;
        if (l < 2) return bad_readline();
        if (!( len=self->stack->length ))  return stackUnderflow();
-       if (!( py_str = PyBytes_FromStringAndSize(s, l - 1)))  return -1;
+       if (!( py_str = PyString_FromStringAndSize(s, l - 1)))  return -1;
        value=self->stack->data[len-1];
        l=PyDict_SetItem(self->memo, py_str, value);
        Py_DECREF(py_str);
@@ -5568,7 +5568,7 @@ init_stuff(PyObject *module_dict)
 {
        PyObject *copyreg, *t, *r;
 
-#define INIT_STR(S) if (!( S ## _str=PyBytes_InternFromString(#S)))  return -1;
+#define INIT_STR(S) if (!( S ## _str=PyString_InternFromString(#S)))  return -1;
 
        if (PyType_Ready(&Unpicklertype) < 0)
                return -1;
@@ -5736,7 +5736,7 @@ initcPickle(void)
 
        /* Add some symbolic constants to the module */
        d = PyModule_GetDict(m);
-       v = PyBytes_FromString(rev);
+       v = PyString_FromString(rev);
        PyDict_SetItemString(d, "__version__", v);
        Py_XDECREF(v);
 
@@ -5755,7 +5755,7 @@ initcPickle(void)
 
        /* These are purely informational; no code uses them. */
        /* File format version we write. */
-       format_version = PyBytes_FromString("2.0");
+       format_version = PyString_FromString("2.0");
        /* Format versions we can read. */
        compatible_formats = Py_BuildValue("[sssss]",
                "1.0",  /* Original protocol 0 */
index 576a17622d4a886f09682ab094d16ce4448cb14f..139a4a83918651b325745818ce1d290bf2a8e76b 100644 (file)
@@ -119,7 +119,7 @@ PyDoc_STRVAR(IO_getval__doc__,
 static PyObject *
 IO_cgetval(PyObject *self) {
         if (!IO__opencheck(IOOOBJECT(self))) return NULL;
-        return PyBytes_FromStringAndSize(((IOobject*)self)->buf,
+        return PyString_FromStringAndSize(((IOobject*)self)->buf,
                                           ((IOobject*)self)->pos);
 }
 
@@ -137,7 +137,7 @@ IO_getval(IOobject *self, PyObject *args) {
         }
         else
                   s=self->string_size;
-        return PyBytes_FromStringAndSize(self->buf, s);
+        return PyString_FromStringAndSize(self->buf, s);
 }
 
 PyDoc_STRVAR(IO_isatty__doc__, "isatty(): always returns 0");
@@ -177,7 +177,7 @@ IO_read(IOobject *self, PyObject *args) {
 
         if ( (n=IO_cread((PyObject*)self,&output,n)) < 0) return NULL;
 
-        return PyBytes_FromStringAndSize(output, n);
+        return PyString_FromStringAndSize(output, n);
 }
 
 PyDoc_STRVAR(IO_readline__doc__, "readline() -- Read one line");
@@ -215,7 +215,7 @@ IO_readline(IOobject *self, PyObject *args) {
                 n -= m;
                 self->pos -= m;
         }
-        return PyBytes_FromStringAndSize(output, n);
+        return PyString_FromStringAndSize(output, n);
 }
 
 PyDoc_STRVAR(IO_readlines__doc__, "readlines() -- Read all lines");
@@ -238,7 +238,7 @@ IO_readlines(IOobject *self, PyObject *args) {
                         goto err;
                if (n == 0)
                        break;
-               line = PyBytes_FromStringAndSize (output, n);
+               line = PyString_FromStringAndSize (output, n);
                if (!line) 
                         goto err;
                if (PyList_Append (result, line) == -1) {
@@ -315,7 +315,7 @@ IO_iternext(Iobject *self)
        next = IO_readline((IOobject *)self, NULL);
        if (!next)
                return NULL;
-       if (!PyBytes_GET_SIZE(next)) {
+       if (!PyString_GET_SIZE(next)) {
                Py_DECREF(next);
                PyErr_SetNone(PyExc_StopIteration);
                return NULL;
@@ -456,7 +456,7 @@ O_writelines(Oobject *self, PyObject *args) {
        while ((s = PyIter_Next(it)) != NULL) {
                Py_ssize_t n;
                char *c;
-               if (PyBytes_AsStringAndSize(s, &c, &n) == -1) {
+               if (PyString_AsStringAndSize(s, &c, &n) == -1) {
                        Py_DECREF(it);
                        Py_DECREF(s);
                        return NULL;
index 8602d5dfb46f77765277f707546412aacc668cd8..f09b0a4adf7afc58f060844ad13c8ff31ac8fa20 100644 (file)
@@ -239,19 +239,19 @@ CD_readda(cdplayerobject *self, PyObject *args)
        if (!PyArg_ParseTuple(args, "i:readda", &numframes))
                return NULL;
 
-       result = PyBytes_FromStringAndSize(NULL, numframes * sizeof(CDFRAME));
+       result = PyString_FromStringAndSize(NULL, numframes * sizeof(CDFRAME));
        if (result == NULL)
                return NULL;
 
        n = CDreadda(self->ob_cdplayer,
-                      (CDFRAME *) PyBytes_AsString(result), numframes);
+                      (CDFRAME *) PyString_AsString(result), numframes);
        if (n == -1) {
                Py_DECREF(result);
                PyErr_SetFromErrno(CdError);
                return NULL;
        }
        if (n < numframes)
-               _PyBytes_Resize(&result, n * sizeof(CDFRAME));
+               _PyString_Resize(&result, n * sizeof(CDFRAME));
 
        return result;
 }
@@ -468,7 +468,7 @@ CD_callback(void *arg, CDDATATYPES type, void *data)
        PyTuple_SetItem(args, 1, PyInt_FromLong((long) type));
        switch (type) {
        case cd_audio:
-               v = PyBytes_FromStringAndSize(data, CDDA_DATASIZE);
+               v = PyString_FromStringAndSize(data, CDDA_DATASIZE);
                break;
        case cd_pnum:
        case cd_index:
@@ -484,15 +484,15 @@ CD_callback(void *arg, CDDATATYPES type, void *data)
 #undef ptr
                break;
        case cd_catalog:
-               v = PyBytes_FromStringAndSize(NULL, 13);
-               p = PyBytes_AsString(v);
+               v = PyString_FromStringAndSize(NULL, 13);
+               p = PyString_AsString(v);
                for (i = 0; i < 13; i++)
                        *p++ = ((char *) data)[i] + '0';
                break;
        case cd_ident:
 #define ptr ((struct cdident *) data)
-               v = PyBytes_FromStringAndSize(NULL, 12);
-               p = PyBytes_AsString(v);
+               v = PyString_FromStringAndSize(NULL, 12);
+               p = PyString_AsString(v);
                CDsbtoa(p, ptr->country, 2);
                p += 2;
                CDsbtoa(p, ptr->owner, 3);
index 965f7b427b718f193412c223439b2593e787184a..7e7d0ff9f4c6356ffacafaae27901903de37745a 100644 (file)
@@ -119,10 +119,10 @@ PyArg_GetString(PyObject *args, int nargs, int i, string *p_arg)
        PyObject *v;
        if (!PyArg_GetObject(args, nargs, i, &v))
                return 0;
-       if (!PyBytes_Check(v)) {
+       if (!PyString_Check(v)) {
                return PyErr_BadArgument();
        }
-       *p_arg = PyBytes_AsString(v);
+       *p_arg = PyString_AsString(v);
        return 1;
 }
 
index c06319ec5ac5ea9cc726be3e38ceafe1109f7fce..4005bcfe3453e13ca2def6ad1641a8bdf7f0b84e 100644 (file)
@@ -261,7 +261,7 @@ getcodec(PyObject *self, PyObject *encoding)
        const MultibyteCodec *codec;
        const char *enc;
 
-       if (!PyBytes_Check(encoding)) {
+       if (!PyString_Check(encoding)) {
                PyErr_SetString(PyExc_TypeError,
                                "encoding name must be a string.");
                return NULL;
@@ -271,7 +271,7 @@ getcodec(PyObject *self, PyObject *encoding)
        if (cofunc == NULL)
                return NULL;
 
-       enc = PyBytes_AS_STRING(encoding);
+       enc = PyString_AS_STRING(encoding);
        for (codec = codec_list; codec->encoding[0]; codec++)
                if (strcmp(codec->encoding, enc) == 0)
                        break;
index e70ec535165a81c58905c1b65901de8f406cfa45..bbd4c1a04c8d7bedaef0f98e246bc8f0b3d3a4b4 100644 (file)
@@ -85,7 +85,7 @@ internal_error_callback(const char *errors)
        else if (strcmp(errors, "replace") == 0)
                return ERROR_REPLACE;
        else
-               return PyBytes_FromString(errors);
+               return PyString_FromString(errors);
 }
 
 static PyObject *
@@ -93,8 +93,8 @@ call_error_callback(PyObject *errors, PyObject *exc)
 {
        PyObject *args, *cb, *r;
 
-       assert(PyBytes_Check(errors));
-       cb = PyCodec_LookupError(PyBytes_AS_STRING(errors));
+       assert(PyString_Check(errors));
+       cb = PyCodec_LookupError(PyString_AS_STRING(errors));
        if (cb == NULL)
                return NULL;
 
@@ -129,7 +129,7 @@ codecctx_errors_get(MultibyteStatefulCodecContext *self)
                return self->errors;
        }
 
-       return PyBytes_FromString(errors);
+       return PyString_FromString(errors);
 }
 
 static int
@@ -138,12 +138,12 @@ codecctx_errors_set(MultibyteStatefulCodecContext *self, PyObject *value,
 {
        PyObject *cb;
 
-       if (!PyBytes_Check(value)) {
+       if (!PyString_Check(value)) {
                PyErr_SetString(PyExc_TypeError, "errors must be a string");
                return -1;
        }
 
-       cb = internal_error_callback(PyBytes_AS_STRING(value));
+       cb = internal_error_callback(PyString_AS_STRING(value));
        if (cb == NULL)
                return -1;
 
@@ -166,15 +166,15 @@ expand_encodebuffer(MultibyteEncodeBuffer *buf, Py_ssize_t esize)
        Py_ssize_t orgpos, orgsize;
 
        orgpos = (Py_ssize_t)((char *)buf->outbuf -
-                               PyBytes_AS_STRING(buf->outobj));
-       orgsize = PyBytes_GET_SIZE(buf->outobj);
-       if (_PyBytes_Resize(&buf->outobj, orgsize + (
+                               PyString_AS_STRING(buf->outobj));
+       orgsize = PyString_GET_SIZE(buf->outobj);
+       if (_PyString_Resize(&buf->outobj, orgsize + (
            esize < (orgsize >> 1) ? (orgsize >> 1) | 1 : esize)) == -1)
                return -1;
 
-       buf->outbuf = (unsigned char *)PyBytes_AS_STRING(buf->outobj) +orgpos;
-       buf->outbuf_end = (unsigned char *)PyBytes_AS_STRING(buf->outobj)
-               + PyBytes_GET_SIZE(buf->outobj);
+       buf->outbuf = (unsigned char *)PyString_AS_STRING(buf->outobj) +orgpos;
+       buf->outbuf_end = (unsigned char *)PyString_AS_STRING(buf->outobj)
+               + PyString_GET_SIZE(buf->outobj);
 
        return 0;
 }
@@ -322,10 +322,10 @@ multibytecodec_encerror(MultibyteCodec *codec,
                        goto errorexit;
        }
 
-       retstrsize = PyBytes_GET_SIZE(retstr);
+       retstrsize = PyString_GET_SIZE(retstr);
        REQUIRE_ENCODEBUFFER(buf, retstrsize);
 
-       memcpy(buf->outbuf, PyBytes_AS_STRING(retstr), retstrsize);
+       memcpy(buf->outbuf, PyString_AS_STRING(retstr), retstrsize);
        buf->outbuf += retstrsize;
 
        newpos = PyInt_AsSsize_t(PyTuple_GET_ITEM(retobj, 1));
@@ -468,16 +468,16 @@ multibytecodec_encode(MultibyteCodec *codec,
        Py_ssize_t finalsize, r = 0;
 
        if (datalen == 0)
-               return PyBytes_FromString("");
+               return PyString_FromString("");
 
        buf.excobj = NULL;
        buf.inbuf = buf.inbuf_top = *data;
        buf.inbuf_end = buf.inbuf_top + datalen;
-       buf.outobj = PyBytes_FromStringAndSize(NULL, datalen * 2 + 16);
+       buf.outobj = PyString_FromStringAndSize(NULL, datalen * 2 + 16);
        if (buf.outobj == NULL)
                goto errorexit;
-       buf.outbuf = (unsigned char *)PyBytes_AS_STRING(buf.outobj);
-       buf.outbuf_end = buf.outbuf + PyBytes_GET_SIZE(buf.outobj);
+       buf.outbuf = (unsigned char *)PyString_AS_STRING(buf.outobj);
+       buf.outbuf_end = buf.outbuf + PyString_GET_SIZE(buf.outobj);
 
        while (buf.inbuf < buf.inbuf_end) {
                Py_ssize_t inleft, outleft;
@@ -512,10 +512,10 @@ multibytecodec_encode(MultibyteCodec *codec,
                }
 
        finalsize = (Py_ssize_t)((char *)buf.outbuf -
-                                PyBytes_AS_STRING(buf.outobj));
+                                PyString_AS_STRING(buf.outobj));
 
-       if (finalsize != PyBytes_GET_SIZE(buf.outobj))
-               if (_PyBytes_Resize(&buf.outobj, finalsize) == -1)
+       if (finalsize != PyString_GET_SIZE(buf.outobj))
+               if (_PyString_Resize(&buf.outobj, finalsize) == -1)
                        goto errorexit;
 
        Py_XDECREF(buf.excobj);
@@ -1222,35 +1222,35 @@ mbstreamreader_iread(MultibyteStreamReaderObject *self,
                if (cres == NULL)
                        goto errorexit;
 
-               if (!PyBytes_Check(cres)) {
+               if (!PyString_Check(cres)) {
                        PyErr_SetString(PyExc_TypeError,
                                        "stream function returned a "
                                        "non-string object");
                        goto errorexit;
                }
 
-               endoffile = (PyBytes_GET_SIZE(cres) == 0);
+               endoffile = (PyString_GET_SIZE(cres) == 0);
 
                if (self->pendingsize > 0) {
                        PyObject *ctr;
                        char *ctrdata;
 
-                       rsize = PyBytes_GET_SIZE(cres) + self->pendingsize;
-                       ctr = PyBytes_FromStringAndSize(NULL, rsize);
+                       rsize = PyString_GET_SIZE(cres) + self->pendingsize;
+                       ctr = PyString_FromStringAndSize(NULL, rsize);
                        if (ctr == NULL)
                                goto errorexit;
-                       ctrdata = PyBytes_AS_STRING(ctr);
+                       ctrdata = PyString_AS_STRING(ctr);
                        memcpy(ctrdata, self->pending, self->pendingsize);
                        memcpy(ctrdata + self->pendingsize,
-                               PyBytes_AS_STRING(cres),
-                               PyBytes_GET_SIZE(cres));
+                               PyString_AS_STRING(cres),
+                               PyString_GET_SIZE(cres));
                        Py_DECREF(cres);
                        cres = ctr;
                        self->pendingsize = 0;
                }
 
-               rsize = PyBytes_GET_SIZE(cres);
-               if (decoder_prepare_buffer(&buf, PyBytes_AS_STRING(cres),
+               rsize = PyString_GET_SIZE(cres);
+               if (decoder_prepare_buffer(&buf, PyString_AS_STRING(cres),
                                           rsize) != 0)
                        goto errorexit;
 
@@ -1585,7 +1585,7 @@ mbstreamwriter_reset(MultibyteStreamWriterObject *self)
        if (pwrt == NULL)
                return NULL;
 
-       if (PyBytes_Size(pwrt) > 0) {
+       if (PyString_Size(pwrt) > 0) {
                PyObject *wr;
                wr = PyObject_CallMethod(self->stream, "write", "O", pwrt);
                if (wr == NULL) {
index b504eed9313c51e4287bb54c670f9da2f45526e7..d3e0edf3e5b14ea80b74e06ed100e90d9317bd4c 100644 (file)
@@ -111,7 +111,7 @@ cl_CompressImage(PyObject *self, PyObject *args)
                return NULL;
 
   retry:
-       compressedBuffer = PyBytes_FromStringAndSize(NULL, frameBufferSize);
+       compressedBuffer = PyString_FromStringAndSize(NULL, frameBufferSize);
        if (compressedBuffer == NULL)
                return NULL;
 
@@ -120,7 +120,7 @@ cl_CompressImage(PyObject *self, PyObject *args)
        if (clCompressImage(compressionScheme, width, height, originalFormat,
                            compressionRatio, (void *) frameBuffer,
                            &compressedBufferSize,
-                           (void *) PyBytes_AsString(compressedBuffer))
+                           (void *) PyString_AsString(compressedBuffer))
            == FAILURE || error_handler_called) {
                Py_DECREF(compressedBuffer);
                if (!error_handler_called)
@@ -135,7 +135,7 @@ cl_CompressImage(PyObject *self, PyObject *args)
        }
 
        if (compressedBufferSize < frameBufferSize)
-               _PyBytes_Resize(&compressedBuffer, compressedBufferSize);
+               _PyString_Resize(&compressedBuffer, compressedBufferSize);
 
        return compressedBuffer;
 }
@@ -155,14 +155,14 @@ cl_DecompressImage(PyObject *self, PyObject *args)
 
        frameBufferSize = width * height * CL_BytesPerPixel(originalFormat);
 
-       frameBuffer = PyBytes_FromStringAndSize(NULL, frameBufferSize);
+       frameBuffer = PyString_FromStringAndSize(NULL, frameBufferSize);
        if (frameBuffer == NULL)
                return NULL;
 
        error_handler_called = 0;
        if (clDecompressImage(compressionScheme, width, height, originalFormat,
                              compressedBufferSize, compressedBuffer,
-                             (void *) PyBytes_AsString(frameBuffer))
+                             (void *) PyString_AsString(frameBuffer))
            == FAILURE || error_handler_called) {
                Py_DECREF(frameBuffer);
                if (!error_handler_called)
@@ -236,14 +236,14 @@ clm_Compress(PyObject *self, PyObject *args)
        if (error_handler_called)
                return NULL;
 
-       data = PyBytes_FromStringAndSize(NULL, size);
+       data = PyString_FromStringAndSize(NULL, size);
        if (data == NULL)
                return NULL;
 
        error_handler_called = 0;
        if (clCompress(SELF->ob_compressorHdl, numberOfFrames,
                       (void *) frameBuffer, &compressedBufferSize,
-                      (void *) PyBytes_AsString(data)) == FAILURE ||
+                      (void *) PyString_AsString(data)) == FAILURE ||
            error_handler_called) {
                Py_DECREF(data);
                if (!error_handler_called)
@@ -252,7 +252,7 @@ clm_Compress(PyObject *self, PyObject *args)
        }
 
        if (compressedBufferSize < size)
-               if (_PyBytes_Resize(&data, compressedBufferSize))
+               if (_PyString_Resize(&data, compressedBufferSize))
                        return NULL;
 
        if (compressedBufferSize > size) {
@@ -285,14 +285,14 @@ clm_Decompress(PyObject *self, PyObject *args)
        if (error_handler_called)
                return NULL;
 
-       data = PyBytes_FromStringAndSize(NULL, dataSize);
+       data = PyString_FromStringAndSize(NULL, dataSize);
        if (data == NULL)
                return NULL;
 
        error_handler_called = 0;
        if (clDecompress(SELF->ob_compressorHdl, numberOfFrames,
                         compressedDataSize, (void *) compressedData,
-                        (void *) PyBytes_AsString(data)) == FAILURE ||
+                        (void *) PyString_AsString(data)) == FAILURE ||
            error_handler_called) {
                Py_DECREF(data);
                if (!error_handler_called)
@@ -514,7 +514,7 @@ clm_QueryParams(PyObject *self)
                        PyList_SetItem(list, i, Py_None);
                } else
                        PyList_SetItem(list, i,
-                                  PyBytes_FromString((char *) PVbuffer[i]));
+                                  PyString_FromString((char *) PVbuffer[i]));
        }
 
        PyMem_DEL(PVbuffer);
@@ -563,7 +563,7 @@ clm_GetName(PyObject *self, PyObject *args)
                return NULL;
        }
 
-       return PyBytes_FromString(name);
+       return PyString_FromString(name);
 }
 
 static PyObject *
@@ -775,7 +775,7 @@ cl_QueryAlgorithms(PyObject *self, PyObject *args)
                        PyList_SetItem(list, i, Py_None);
                } else
                        PyList_SetItem(list, i,
-                                  PyBytes_FromString((char *) PVbuffer[i]));
+                                  PyString_FromString((char *) PVbuffer[i]));
        }
 
        PyMem_DEL(PVbuffer);
@@ -818,7 +818,7 @@ cl_GetAlgorithmName(PyObject *self, PyObject *args)
                return NULL;
        }
 
-       return PyBytes_FromString(name);
+       return PyString_FromString(name);
 }
 
 static PyObject *
index 49bd6568c7792b8113765c40495c6e5ebfdc8777..3adf0e2aaa30b60b45991b43d910492579c0b19c 100644 (file)
@@ -947,7 +947,7 @@ call_tzname(PyObject *tzinfo, PyObject *tzinfoarg)
        else
                result = PyObject_CallMethod(tzinfo, "tzname", "O", tzinfoarg);
 
-       if (result != NULL && result != Py_None && ! PyBytes_Check(result)) {
+       if (result != NULL && result != Py_None && ! PyString_Check(result)) {
                PyErr_Format(PyExc_TypeError, "tzinfo.tzname() must "
                             "return None or a string, not '%s'",
                             Py_TYPE(result)->tp_name);
@@ -1046,27 +1046,27 @@ append_keyword_tzinfo(PyObject *repr, PyObject *tzinfo)
 {
        PyObject *temp;
 
-       assert(PyBytes_Check(repr));
+       assert(PyString_Check(repr));
        assert(tzinfo);
        if (tzinfo == Py_None)
                return repr;
        /* Get rid of the trailing ')'. */
-       assert(PyBytes_AsString(repr)[PyBytes_Size(repr)-1] == ')');
-       temp = PyBytes_FromStringAndSize(PyBytes_AsString(repr),
-                                         PyBytes_Size(repr) - 1);
+       assert(PyString_AsString(repr)[PyString_Size(repr)-1] == ')');
+       temp = PyString_FromStringAndSize(PyString_AsString(repr),
+                                         PyString_Size(repr) - 1);
        Py_DECREF(repr);
        if (temp == NULL)
                return NULL;
        repr = temp;
 
        /* Append ", tzinfo=". */
-       PyBytes_ConcatAndDel(&repr, PyBytes_FromString(", tzinfo="));
+       PyString_ConcatAndDel(&repr, PyString_FromString(", tzinfo="));
 
        /* Append repr(tzinfo). */
-       PyBytes_ConcatAndDel(&repr, PyObject_Repr(tzinfo));
+       PyString_ConcatAndDel(&repr, PyObject_Repr(tzinfo));
 
        /* Add a closing paren. */
-       PyBytes_ConcatAndDel(&repr, PyBytes_FromString(")"));
+       PyString_ConcatAndDel(&repr, PyString_FromString(")"));
        return repr;
 }
 
@@ -1092,7 +1092,7 @@ format_ctime(PyDateTime_Date *date, int hours, int minutes, int seconds)
                      DayNames[wday], MonthNames[GET_MONTH(date) - 1],
                      GET_DAY(date), hours, minutes, seconds,
                      GET_YEAR(date));
-       return PyBytes_FromString(buffer);
+       return PyString_FromString(buffer);
 }
 
 /* Add an hours & minutes UTC offset string to buf.  buf has no more than
@@ -1143,7 +1143,7 @@ make_freplacement(PyObject *object)
        else
            sprintf(freplacement, "%06d", 0);
 
-       return PyBytes_FromStringAndSize(freplacement, strlen(freplacement));
+       return PyString_FromStringAndSize(freplacement, strlen(freplacement));
 }
 
 /* I sure don't want to reproduce the strftime code from the time module,
@@ -1230,7 +1230,7 @@ wrap_strftime(PyObject *object, const char *format, size_t format_len,
                                /* format utcoffset */
                                char buf[100];
                                PyObject *tzinfo = get_tzinfo_member(object);
-                               zreplacement = PyBytes_FromString("");
+                               zreplacement = PyString_FromString("");
                                if (zreplacement == NULL) goto Done;
                                if (tzinfo != Py_None && tzinfo != NULL) {
                                        assert(tzinfoarg != NULL);
@@ -1241,19 +1241,19 @@ wrap_strftime(PyObject *object, const char *format, size_t format_len,
                                                             tzinfoarg) < 0)
                                                goto Done;
                                        Py_DECREF(zreplacement);
-                                       zreplacement = PyBytes_FromString(buf);
+                                       zreplacement = PyString_FromString(buf);
                                        if (zreplacement == NULL) goto Done;
                                }
                        }
                        assert(zreplacement != NULL);
-                       ptoappend = PyBytes_AS_STRING(zreplacement);
-                       ntoappend = PyBytes_GET_SIZE(zreplacement);
+                       ptoappend = PyString_AS_STRING(zreplacement);
+                       ntoappend = PyString_GET_SIZE(zreplacement);
                }
                else if (ch == 'Z') {
                        /* format tzname */
                        if (Zreplacement == NULL) {
                                PyObject *tzinfo = get_tzinfo_member(object);
-                               Zreplacement = PyBytes_FromString("");
+                               Zreplacement = PyString_FromString("");
                                if (Zreplacement == NULL) goto Done;
                                if (tzinfo != Py_None && tzinfo != NULL) {
                                        PyObject *temp;
@@ -1261,7 +1261,7 @@ wrap_strftime(PyObject *object, const char *format, size_t format_len,
                                        temp = call_tzname(tzinfo, tzinfoarg);
                                        if (temp == NULL) goto Done;
                                        if (temp != Py_None) {
-                                               assert(PyBytes_Check(temp));
+                                               assert(PyString_Check(temp));
                                                /* Since the tzname is getting
                                                 * stuffed into the format, we
                                                 * have to double any % signs
@@ -1275,7 +1275,7 @@ wrap_strftime(PyObject *object, const char *format, size_t format_len,
                                                Py_DECREF(temp);
                                                if (Zreplacement == NULL)
                                                        goto Done;
-                                               if (!PyBytes_Check(Zreplacement)) {
+                                               if (!PyString_Check(Zreplacement)) {
                                                        PyErr_SetString(PyExc_TypeError, "tzname.replace() did not return a string");
                                                        goto Done;
                                                }
@@ -1285,8 +1285,8 @@ wrap_strftime(PyObject *object, const char *format, size_t format_len,
                                }
                        }
                        assert(Zreplacement != NULL);
-                       ptoappend = PyBytes_AS_STRING(Zreplacement);
-                       ntoappend = PyBytes_GET_SIZE(Zreplacement);
+                       ptoappend = PyString_AS_STRING(Zreplacement);
+                       ntoappend = PyString_GET_SIZE(Zreplacement);
                }
                else if (ch == 'f') {
                        /* format microseconds */
@@ -1296,9 +1296,9 @@ wrap_strftime(PyObject *object, const char *format, size_t format_len,
                                        goto Done;
                        }
                        assert(freplacement != NULL);
-                       assert(PyBytes_Check(freplacement));
-                       ptoappend = PyBytes_AS_STRING(freplacement);
-                       ntoappend = PyBytes_GET_SIZE(freplacement);
+                       assert(PyString_Check(freplacement));
+                       ptoappend = PyString_AS_STRING(freplacement);
+                       ntoappend = PyString_GET_SIZE(freplacement);
                }
                else {
                        /* percent followed by neither z nor Z */
@@ -1319,10 +1319,10 @@ wrap_strftime(PyObject *object, const char *format, size_t format_len,
                                PyErr_NoMemory();
                                goto Done;
                        }
-                       if (_PyBytes_Resize(&newfmt, bigger) < 0)
+                       if (_PyString_Resize(&newfmt, bigger) < 0)
                                goto Done;
                        totalnew = bigger;
-                       pnew = PyBytes_AsString(newfmt) + usednew;
+                       pnew = PyString_AsString(newfmt) + usednew;
                }
                memcpy(pnew, ptoappend, ntoappend);
                pnew += ntoappend;
@@ -1330,7 +1330,7 @@ wrap_strftime(PyObject *object, const char *format, size_t format_len,
                assert(usednew <= totalnew);
        }  /* end while() */
 
-       if (_PyBytes_Resize(&newfmt, usednew) < 0)
+       if (_PyString_Resize(&newfmt, usednew) < 0)
                goto Done;
        {
                PyObject *time = PyImport_ImportModuleNoBlock("time");
@@ -2008,18 +2008,18 @@ static PyObject *
 delta_repr(PyDateTime_Delta *self)
 {
        if (GET_TD_MICROSECONDS(self) != 0)
-               return PyBytes_FromFormat("%s(%d, %d, %d)",
+               return PyString_FromFormat("%s(%d, %d, %d)",
                                           Py_TYPE(self)->tp_name,
                                           GET_TD_DAYS(self),
                                           GET_TD_SECONDS(self),
                                           GET_TD_MICROSECONDS(self));
        if (GET_TD_SECONDS(self) != 0)
-               return PyBytes_FromFormat("%s(%d, %d)",
+               return PyString_FromFormat("%s(%d, %d)",
                                           Py_TYPE(self)->tp_name,
                                           GET_TD_DAYS(self),
                                           GET_TD_SECONDS(self));
 
-       return PyBytes_FromFormat("%s(%d)",
+       return PyString_FromFormat("%s(%d)",
                                   Py_TYPE(self)->tp_name,
                                   GET_TD_DAYS(self));
 }
@@ -2063,7 +2063,7 @@ delta_str(PyDateTime_Delta *self)
                pbuf += n;
        }
 
-       return PyBytes_FromStringAndSize(buf, pbuf - buf);
+       return PyString_FromStringAndSize(buf, pbuf - buf);
 
  Fail:
        PyErr_SetString(PyExc_SystemError, "goofy result from PyOS_snprintf");
@@ -2242,15 +2242,15 @@ date_new(PyTypeObject *type, PyObject *args, PyObject *kw)
 
        /* Check for invocation from pickle with __getstate__ state */
        if (PyTuple_GET_SIZE(args) == 1 &&
-           PyBytes_Check(state = PyTuple_GET_ITEM(args, 0)) &&
-           PyBytes_GET_SIZE(state) == _PyDateTime_DATE_DATASIZE &&
-           MONTH_IS_SANE(PyBytes_AS_STRING(state)[2]))
+           PyString_Check(state = PyTuple_GET_ITEM(args, 0)) &&
+           PyString_GET_SIZE(state) == _PyDateTime_DATE_DATASIZE &&
+           MONTH_IS_SANE(PyString_AS_STRING(state)[2]))
        {
                PyDateTime_Date *me;
 
                me = (PyDateTime_Date *) (type->tp_alloc(type, 0));
                if (me != NULL) {
-                       char *pdata = PyBytes_AS_STRING(state);
+                       char *pdata = PyString_AS_STRING(state);
                        memcpy(me->data, pdata, _PyDateTime_DATE_DATASIZE);
                        me->hashcode = -1;
                }
@@ -2448,7 +2448,7 @@ date_repr(PyDateTime_Date *self)
                      type_name,
                      GET_YEAR(self), GET_MONTH(self), GET_DAY(self));
 
-       return PyBytes_FromString(buffer);
+       return PyString_FromString(buffer);
 }
 
 static PyObject *
@@ -2457,7 +2457,7 @@ date_isoformat(PyDateTime_Date *self)
        char buffer[128];
 
        isoformat_date(self, buffer, sizeof(buffer));
-       return PyBytes_FromString(buffer);
+       return PyString_FromString(buffer);
 }
 
 /* str() calls the appropriate isoformat() method. */
@@ -2508,9 +2508,9 @@ date_format(PyDateTime_Date *self, PyObject *args)
                return NULL;
 
        /* Check for str or unicode */
-       if (PyBytes_Check(format)) {
+       if (PyString_Check(format)) {
                 /* If format is zero length, return str(self) */
-               if (PyBytes_GET_SIZE(format) == 0)
+               if (PyString_GET_SIZE(format) == 0)
                        return PyObject_Str((PyObject *)self);
        } else if (PyUnicode_Check(format)) {
                 /* If format is zero length, return str(self) */
@@ -2653,7 +2653,7 @@ date_getstate(PyDateTime_Date *self)
 {
        return Py_BuildValue(
                "(N)",
-               PyBytes_FromStringAndSize((char *)self->data,
+               PyString_FromStringAndSize((char *)self->data,
                                           _PyDateTime_DATE_DATASIZE));
 }
 
@@ -3109,9 +3109,9 @@ time_new(PyTypeObject *type, PyObject *args, PyObject *kw)
        /* Check for invocation from pickle with __getstate__ state */
        if (PyTuple_GET_SIZE(args) >= 1 &&
            PyTuple_GET_SIZE(args) <= 2 &&
-           PyBytes_Check(state = PyTuple_GET_ITEM(args, 0)) &&
-           PyBytes_GET_SIZE(state) == _PyDateTime_TIME_DATASIZE &&
-           ((unsigned char) (PyBytes_AS_STRING(state)[0])) < 24)
+           PyString_Check(state = PyTuple_GET_ITEM(args, 0)) &&
+           PyString_GET_SIZE(state) == _PyDateTime_TIME_DATASIZE &&
+           ((unsigned char) (PyString_AS_STRING(state)[0])) < 24)
        {
                PyDateTime_Time *me;
                char aware;
@@ -3127,7 +3127,7 @@ time_new(PyTypeObject *type, PyObject *args, PyObject *kw)
                aware = (char)(tzinfo != Py_None);
                me = (PyDateTime_Time *) (type->tp_alloc(type, aware));
                if (me != NULL) {
-                       char *pdata = PyBytes_AS_STRING(state);
+                       char *pdata = PyString_AS_STRING(state);
 
                        memcpy(me->data, pdata, _PyDateTime_TIME_DATASIZE);
                        me->hashcode = -1;
@@ -3213,7 +3213,7 @@ time_repr(PyDateTime_Time *self)
        else
                PyOS_snprintf(buffer, sizeof(buffer),
                              "%s(%d, %d)", type_name, h, m);
-       result = PyBytes_FromString(buffer);
+       result = PyString_FromString(buffer);
        if (result != NULL && HASTZINFO(self))
                result = append_keyword_tzinfo(result, self->tzinfo);
        return result;
@@ -3240,7 +3240,7 @@ time_isoformat(PyDateTime_Time *self, PyObject *unused)
               _PyDateTime_TIME_DATASIZE);
 
        isoformat_time(pdatetime, buf, sizeof(buf));
-       result = PyBytes_FromString(buf);
+       result = PyString_FromString(buf);
        if (result == NULL || ! HASTZINFO(self) || self->tzinfo == Py_None)
                return result;
 
@@ -3250,7 +3250,7 @@ time_isoformat(PyDateTime_Time *self, PyObject *unused)
                Py_DECREF(result);
                return NULL;
        }
-       PyBytes_ConcatAndDel(&result, PyBytes_FromString(buf));
+       PyString_ConcatAndDel(&result, PyString_FromString(buf));
        return result;
 }
 
@@ -3364,7 +3364,7 @@ time_hash(PyDateTime_Time *self)
 
                /* Reduce this to a hash of another object. */
                if (offset == 0)
-                       temp = PyBytes_FromStringAndSize((char *)self->data,
+                       temp = PyString_FromStringAndSize((char *)self->data,
                                                _PyDateTime_TIME_DATASIZE);
                else {
                        int hour;
@@ -3452,7 +3452,7 @@ time_getstate(PyDateTime_Time *self)
        PyObject *basestate;
        PyObject *result = NULL;
 
-       basestate =  PyBytes_FromStringAndSize((char *)self->data,
+       basestate =  PyString_FromStringAndSize((char *)self->data,
                                                _PyDateTime_TIME_DATASIZE);
        if (basestate != NULL) {
                if (! HASTZINFO(self) || self->tzinfo == Py_None)
@@ -3639,9 +3639,9 @@ datetime_new(PyTypeObject *type, PyObject *args, PyObject *kw)
        /* Check for invocation from pickle with __getstate__ state */
        if (PyTuple_GET_SIZE(args) >= 1 &&
            PyTuple_GET_SIZE(args) <= 2 &&
-           PyBytes_Check(state = PyTuple_GET_ITEM(args, 0)) &&
-           PyBytes_GET_SIZE(state) == _PyDateTime_DATETIME_DATASIZE &&
-           MONTH_IS_SANE(PyBytes_AS_STRING(state)[2]))
+           PyString_Check(state = PyTuple_GET_ITEM(args, 0)) &&
+           PyString_GET_SIZE(state) == _PyDateTime_DATETIME_DATASIZE &&
+           MONTH_IS_SANE(PyString_AS_STRING(state)[2]))
        {
                PyDateTime_DateTime *me;
                char aware;
@@ -3657,7 +3657,7 @@ datetime_new(PyTypeObject *type, PyObject *args, PyObject *kw)
                aware = (char)(tzinfo != Py_None);
                me = (PyDateTime_DateTime *) (type->tp_alloc(type , aware));
                if (me != NULL) {
-                       char *pdata = PyBytes_AS_STRING(state);
+                       char *pdata = PyString_AS_STRING(state);
 
                        memcpy(me->data, pdata, _PyDateTime_DATETIME_DATASIZE);
                        me->hashcode = -1;
@@ -4166,7 +4166,7 @@ datetime_repr(PyDateTime_DateTime *self)
                              GET_YEAR(self), GET_MONTH(self), GET_DAY(self),
                              DATE_GET_HOUR(self), DATE_GET_MINUTE(self));
        }
-       baserepr = PyBytes_FromString(buffer);
+       baserepr = PyString_FromString(buffer);
        if (baserepr == NULL || ! HASTZINFO(self))
                return baserepr;
        return append_keyword_tzinfo(baserepr, self->tzinfo);
@@ -4194,7 +4194,7 @@ datetime_isoformat(PyDateTime_DateTime *self, PyObject *args, PyObject *kw)
        assert(cp != NULL);
        *cp++ = sep;
        isoformat_time(self, cp, sizeof(buffer) - (cp - buffer));
-       result = PyBytes_FromString(buffer);
+       result = PyString_FromString(buffer);
        if (result == NULL || ! HASTZINFO(self))
                return result;
 
@@ -4204,7 +4204,7 @@ datetime_isoformat(PyDateTime_DateTime *self, PyObject *args, PyObject *kw)
                Py_DECREF(result);
                return NULL;
        }
-       PyBytes_ConcatAndDel(&result, PyBytes_FromString(buffer));
+       PyString_ConcatAndDel(&result, PyString_FromString(buffer));
        return result;
 }
 
@@ -4310,7 +4310,7 @@ datetime_hash(PyDateTime_DateTime *self)
 
                /* Reduce this to a hash of another object. */
                if (n == OFFSET_NAIVE)
-                       temp = PyBytes_FromStringAndSize(
+                       temp = PyString_FromStringAndSize(
                                        (char *)self->data,
                                        _PyDateTime_DATETIME_DATASIZE);
                else {
@@ -4533,7 +4533,7 @@ datetime_getstate(PyDateTime_DateTime *self)
        PyObject *basestate;
        PyObject *result = NULL;
 
-       basestate = PyBytes_FromStringAndSize((char *)self->data,
+       basestate = PyString_FromStringAndSize((char *)self->data,
                                          _PyDateTime_DATETIME_DATASIZE);
        if (basestate != NULL) {
                if (! HASTZINFO(self) || self->tzinfo == Py_None)
index d5b518af11301453acdede50fe00014a20862f23..c91ea471a05e0d3876cafc806df807e22d80bb20 100644 (file)
@@ -104,7 +104,7 @@ dbm_subscript(dbmobject *dp, register PyObject *key)
        drec = dbm_fetch(dp->di_dbm, krec);
        if ( drec.dptr == 0 ) {
                PyErr_SetString(PyExc_KeyError,
-                               PyBytes_AS_STRING((PyBytesObject *)key));
+                               PyString_AS_STRING((PyStringObject *)key));
                return NULL;
        }
        if ( dbm_error(dp->di_dbm) ) {
@@ -112,7 +112,7 @@ dbm_subscript(dbmobject *dp, register PyObject *key)
                PyErr_SetString(DbmError, "");
                return NULL;
        }
-       return PyBytes_FromStringAndSize(drec.dptr, drec.dsize);
+       return PyString_FromStringAndSize(drec.dptr, drec.dsize);
 }
 
 static int
@@ -136,7 +136,7 @@ dbm_ass_sub(dbmobject *dp, PyObject *v, PyObject *w)
                if ( dbm_delete(dp->di_dbm, krec) < 0 ) {
                        dbm_clearerr(dp->di_dbm);
                        PyErr_SetString(PyExc_KeyError,
-                                     PyBytes_AS_STRING((PyBytesObject *)v));
+                                     PyString_AS_STRING((PyStringObject *)v));
                        return -1;
                }
        } else {
@@ -166,7 +166,7 @@ dbm_contains(register dbmobject *dp, PyObject *v)
 {
        datum key, val;
 
-       if (PyBytes_AsStringAndSize(v, (char **)&key.dptr,
+       if (PyString_AsStringAndSize(v, (char **)&key.dptr,
                                     (Py_ssize_t *)&key.dsize)) {
                return -1;
        }
@@ -222,7 +222,7 @@ dbm_keys(register dbmobject *dp, PyObject *unused)
                return NULL;
        for (key = dbm_firstkey(dp->di_dbm); key.dptr;
             key = dbm_nextkey(dp->di_dbm)) {
-               item = PyBytes_FromStringAndSize(key.dptr, key.dsize);
+               item = PyString_FromStringAndSize(key.dptr, key.dsize);
                if (item == NULL) {
                        Py_DECREF(v);
                        return NULL;
@@ -269,7 +269,7 @@ dbm_get(register dbmobject *dp, PyObject *args)
         check_dbmobject_open(dp);
        val = dbm_fetch(dp->di_dbm, key);
        if (val.dptr != NULL)
-               return PyBytes_FromStringAndSize(val.dptr, val.dsize);
+               return PyString_FromStringAndSize(val.dptr, val.dsize);
        else {
                Py_INCREF(defvalue);
                return defvalue;
@@ -292,16 +292,16 @@ dbm_setdefault(register dbmobject *dp, PyObject *args)
         check_dbmobject_open(dp);
        val = dbm_fetch(dp->di_dbm, key);
        if (val.dptr != NULL)
-               return PyBytes_FromStringAndSize(val.dptr, val.dsize);
+               return PyString_FromStringAndSize(val.dptr, val.dsize);
        if (defvalue == NULL) {
-               defvalue = PyBytes_FromStringAndSize(NULL, 0);
+               defvalue = PyString_FromStringAndSize(NULL, 0);
                if (defvalue == NULL)
                        return NULL;
        }
        else
                Py_INCREF(defvalue);
-       val.dptr = PyBytes_AS_STRING(defvalue);
-       val.dsize = PyBytes_GET_SIZE(defvalue);
+       val.dptr = PyString_AS_STRING(defvalue);
+       val.dsize = PyString_GET_SIZE(defvalue);
        if (dbm_store(dp->di_dbm, key, val, DBM_INSERT) < 0) {
                dbm_clearerr(dp->di_dbm);
                PyErr_SetString(DbmError, "cannot add item to database");
@@ -404,7 +404,7 @@ initdbm(void) {
        d = PyModule_GetDict(m);
        if (DbmError == NULL)
                DbmError = PyErr_NewException("dbm.error", NULL, NULL);
-       s = PyBytes_FromString(which_dbm);
+       s = PyString_FromString(which_dbm);
        if (s != NULL) {
                PyDict_SetItemString(d, "library", s);
                Py_DECREF(s);
index e633fe97e620394c621260c4cac2c07b875234cf..ccf1cb1835bbdda1f475f1abff97c1a3efe1d44f 100644 (file)
@@ -58,8 +58,8 @@ dl_sym(dlobject *xp, PyObject *args)
 {
        char *name;
        PyUnivPtr *func;
-       if (PyBytes_Check(args)) {
-               name = PyBytes_AS_STRING(args);
+       if (PyString_Check(args)) {
+               name = PyString_AS_STRING(args);
        } else {
                PyErr_Format(PyExc_TypeError, "expected string, found %.200s",
                             Py_TYPE(args)->tp_name);
@@ -88,14 +88,14 @@ dl_call(dlobject *xp, PyObject *args)
                return NULL;
        }
        name = PyTuple_GetItem(args, 0);
-       if (!PyBytes_Check(name)) {
+       if (!PyString_Check(name)) {
                PyErr_SetString(PyExc_TypeError,
                                "function name must be a string");
                return NULL;
        }
        func = (long (*)(long, long, long, long, long, 
                          long, long, long, long, long)) 
-          dlsym(xp->dl_handle, PyBytes_AsString(name));
+          dlsym(xp->dl_handle, PyString_AsString(name));
        if (func == NULL) {
                PyErr_SetString(PyExc_ValueError, dlerror());
                return NULL;
@@ -109,8 +109,8 @@ dl_call(dlobject *xp, PyObject *args)
                PyObject *v = PyTuple_GetItem(args, i);
                if (PyInt_Check(v))
                        alist[i-1] = PyInt_AsLong(v);
-               else if (PyBytes_Check(v))
-                       alist[i-1] = (long)PyBytes_AsString(v);
+               else if (PyString_Check(v))
+                       alist[i-1] = (long)PyString_AsString(v);
                else if (v == Py_None)
                        alist[i-1] = (long) ((char *)NULL);
                else {
index df2ceffe197f0b2fba8f6fa21437a05dc4773a0e..696d396b07ad8dcae16a9de979e339eee8963e1e 100644 (file)
@@ -21,7 +21,7 @@ static PyMethodDef errno_methods[] = {
 static void
 _inscode(PyObject *d, PyObject *de, char *name, int code)
 {
-       PyObject *u = PyBytes_FromString(name);
+       PyObject *u = PyString_FromString(name);
        PyObject *v = PyInt_FromLong((long) code);
 
        /* Don't bother checking for errors; they'll be caught at the end
index 7658be0a5bc1bf801c0148c93e174c550956af51..0c85f477e9140f3701ae03242fcc3e65ff0c9ead 100644 (file)
@@ -55,7 +55,7 @@ fcntl_fcntl(PyObject *self, PyObject *args)
                        PyErr_SetFromErrno(PyExc_IOError);
                        return NULL;
                }
-               return PyBytes_FromStringAndSize(buf, len);
+               return PyString_FromStringAndSize(buf, len);
        }
 
        PyErr_Clear();
@@ -164,7 +164,7 @@ fcntl_ioctl(PyObject *self, PyObject *args)
                        return PyInt_FromLong(ret);
                }
                else {
-                       return PyBytes_FromStringAndSize(buf, len);
+                       return PyString_FromStringAndSize(buf, len);
                }
        }
 
@@ -185,7 +185,7 @@ fcntl_ioctl(PyObject *self, PyObject *args)
                        PyErr_SetFromErrno(PyExc_IOError);
                        return NULL;
                }
-               return PyBytes_FromStringAndSize(buf, len);
+               return PyString_FromStringAndSize(buf, len);
        }
 
        PyErr_Clear();
index 800aebb8b54d56620bbab2b32ac397a3026ec74b..20e74e93065d06d8713e8365485608fb39b0c8e1 100644 (file)
@@ -324,7 +324,7 @@ generic_getattr(genericobject *g, char *name)
        /* "label" is an exception, getmember only works for char pointers,
           not for char arrays */
        if (strcmp(name, "label") == 0)
-               return PyBytes_FromString(g->ob_generic->label);
+               return PyString_FromString(g->ob_generic->label);
 
        return PyMember_Get((char *)g->ob_generic, generic_memberlist, name);
 }
@@ -343,12 +343,12 @@ generic_setattr(genericobject *g, char *name, PyObject *v)
        /* "label" is an exception: setmember doesn't set strings;
           and FORMS wants you to call a function to set the label */
        if (strcmp(name, "label") == 0) {
-               if (!PyBytes_Check(v)) {
+               if (!PyString_Check(v)) {
                        PyErr_SetString(PyExc_TypeError,
                                        "label attr must be string");
                        return -1;
                }
-               fl_set_object_label(g->ob_generic, PyBytes_AsString(v));
+               fl_set_object_label(g->ob_generic, PyString_AsString(v));
                return 0;
        }
 
@@ -369,7 +369,7 @@ generic_repr(genericobject *g)
        char buf[100];
        PyOS_snprintf(buf, sizeof(buf), "<FORMS_object at %p, objclass=%d>",
                      g, g->ob_generic->objclass);
-       return PyBytes_FromString(buf);
+       return PyString_FromString(buf);
 }
 
 static PyTypeObject GenericObjecttype = {
@@ -530,7 +530,7 @@ call_forms_Rstr (char * (*func)(FL_OBJECT *), FL_OBJECT *obj)
                Py_INCREF(Py_None);
                return Py_None;
        }
-       return PyBytes_FromString (str);
+       return PyString_FromString (str);
 }
 
 /* int func (object) */
@@ -628,7 +628,7 @@ get_browser_line(genericobject *g, PyObject *args)
                Py_INCREF(Py_None);
                return Py_None;
        }
-       return PyBytes_FromString (str);
+       return PyString_FromString (str);
 }
 
 static PyObject *
@@ -1594,7 +1594,7 @@ form_repr(formobject *f)
        char buf[100];
        PyOS_snprintf(buf, sizeof(buf), "<FORMS_form at %p, window=%ld>",
                      f, f->ob_form->window);
-       return PyBytes_FromString(buf);
+       return PyString_FromString(buf);
 }
 
 static PyTypeObject Formtype = {
@@ -2027,7 +2027,7 @@ forms_show_input(PyObject *f, PyObject *args)
                Py_INCREF(Py_None);
                return Py_None;
        }
-       return PyBytes_FromString(str);
+       return PyString_FromString(str);
 }
 
 static PyObject *
@@ -2046,7 +2046,7 @@ forms_file_selector(PyObject *f, PyObject *args)
                Py_INCREF(Py_None);
                return Py_None;
        }
-       return PyBytes_FromString(str);
+       return PyString_FromString(str);
 }
 
 
@@ -2061,7 +2061,7 @@ forms_file_selector_func(PyObject *args, char *(*func)(void))
                Py_INCREF(Py_None);
                return Py_None;
        }
-       return PyBytes_FromString(str);
+       return PyString_FromString(str);
 }
 
 static PyObject *
index 73b8c05d813871bf40982fd0216214cca1de15e8..f3f0dc516c125882efa7e510bff9b5692ad0a13a 100644 (file)
@@ -66,7 +66,7 @@ fh_getfontname(fhobject *self)
                PyErr_SetString(PyExc_RuntimeError, "error in fmgetfontname");
                return NULL;
        }
-       return PyBytes_FromStringAndSize(fontname, len);
+       return PyString_FromStringAndSize(fontname, len);
 }
 
 static PyObject *
@@ -79,7 +79,7 @@ fh_getcomment(fhobject *self)
                PyErr_SetString(PyExc_RuntimeError, "error in fmgetcomment");
                return NULL;
        }
-       return PyBytes_FromStringAndSize(comment, len);
+       return PyString_FromStringAndSize(comment, len);
 }
 
 static PyObject *
@@ -200,7 +200,7 @@ clientproc(char *fontname)
        PyObject *v;
        if (fontlist == NULL)
                return;
-       v = PyBytes_FromString(fontname);
+       v = PyString_FromString(fontname);
        if (v == NULL)
                err = -1;
        else {
@@ -240,7 +240,7 @@ fm_setpath(PyObject *self, PyObject *args)
 static PyObject *
 fm_fontpath(PyObject *self)
 {
-       return PyBytes_FromString(fmfontpath());
+       return PyString_FromString(fmfontpath());
 }
 
 static PyMethodDef fm_methods[] = {
index c3ee96f4d2e974e70679f9d2e82adf181efa28c0..4f8c85ffd9785aef380eecf5916fb0c5be1d4e3e 100644 (file)
@@ -639,8 +639,8 @@ debug_instance(char *msg, PyInstanceObject *inst)
        char *cname;
        /* simple version of instance_repr */
        PyObject *classname = inst->in_class->cl_name;
-       if (classname != NULL && PyBytes_Check(classname))
-               cname = PyBytes_AsString(classname);
+       if (classname != NULL && PyString_Check(classname))
+               cname = PyString_AsString(classname);
        else
                cname = "?";
        PySys_WriteStderr("gc: %.100s <%.100s instance at %p>\n",
@@ -754,7 +754,7 @@ collect(int generation)
        double t1 = 0.0;
 
        if (delstr == NULL) {
-               delstr = PyBytes_InternFromString("__del__");
+               delstr = PyString_InternFromString("__del__");
                if (delstr == NULL)
                        Py_FatalError("gc couldn't allocate \"__del__\"");
        }
@@ -898,7 +898,7 @@ collect(int generation)
 
        if (PyErr_Occurred()) {
                if (gc_str == NULL)
-                       gc_str = PyBytes_FromString("garbage collection");
+                       gc_str = PyString_FromString("garbage collection");
                PyErr_WriteUnraisable(gc_str);
                Py_FatalError("unexpected exception during garbage collection");
        }
index 89d9a3c668a2c47e62e6a753207be73835342fa1..04b3332bb895e3c6383ab2245a93f67d155dffe7 100644 (file)
@@ -128,10 +128,10 @@ dbm_subscript(dbmobject *dp, register PyObject *key)
     drec = gdbm_fetch(dp->di_dbm, krec);
     if (drec.dptr == 0) {
         PyErr_SetString(PyExc_KeyError,
-                        PyBytes_AS_STRING((PyBytesObject *)key));
+                        PyString_AS_STRING((PyStringObject *)key));
         return NULL;
     }
-    v = PyBytes_FromStringAndSize(drec.dptr, drec.dsize);
+    v = PyString_FromStringAndSize(drec.dptr, drec.dsize);
     free(drec.dptr);
     return v;
 }
@@ -155,7 +155,7 @@ dbm_ass_sub(dbmobject *dp, PyObject *v, PyObject *w)
     if (w == NULL) {
         if (gdbm_delete(dp->di_dbm, krec) < 0) {
             PyErr_SetString(PyExc_KeyError,
-                            PyBytes_AS_STRING((PyBytesObject *)v));
+                            PyString_AS_STRING((PyStringObject *)v));
             return -1;
         }
     }
@@ -188,14 +188,14 @@ dbm_contains(register dbmobject *dp, PyObject *arg)
                         "GDBM object has already been closed");
         return -1;
     }
-    if (!PyBytes_Check(arg)) {
+    if (!PyString_Check(arg)) {
         PyErr_Format(PyExc_TypeError,
                      "gdbm key must be string, not %.100s",
                      arg->ob_type->tp_name);
         return -1;
     }
-    key.dptr = PyBytes_AS_STRING(arg);
-    key.dsize = PyBytes_GET_SIZE(arg);
+    key.dptr = PyString_AS_STRING(arg);
+    key.dsize = PyString_GET_SIZE(arg);
     return gdbm_exists(dp->di_dbm, key);
 }
 
@@ -255,7 +255,7 @@ dbm_keys(register dbmobject *dp, PyObject *unused)
 
     key = gdbm_firstkey(dp->di_dbm);
     while (key.dptr) {
-        item = PyBytes_FromStringAndSize(key.dptr, key.dsize);
+        item = PyString_FromStringAndSize(key.dptr, key.dsize);
         if (item == NULL) {
             free(key.dptr);
             Py_DECREF(v);
@@ -306,7 +306,7 @@ dbm_firstkey(register dbmobject *dp, PyObject *unused)
     check_dbmobject_open(dp);
     key = gdbm_firstkey(dp->di_dbm);
     if (key.dptr) {
-        v = PyBytes_FromStringAndSize(key.dptr, key.dsize);
+        v = PyString_FromStringAndSize(key.dptr, key.dsize);
         free(key.dptr);
         return v;
     }
@@ -338,7 +338,7 @@ dbm_nextkey(register dbmobject *dp, PyObject *args)
     check_dbmobject_open(dp);
     nextkey = gdbm_nextkey(dp->di_dbm, key);
     if (nextkey.dptr) {
-        v = PyBytes_FromStringAndSize(nextkey.dptr, nextkey.dsize);
+        v = PyString_FromStringAndSize(nextkey.dptr, nextkey.dsize);
         free(nextkey.dptr);
         return v;
     }
@@ -541,7 +541,7 @@ initgdbm(void) {
     DbmError = PyErr_NewException("gdbm.error", NULL, NULL);
     if (DbmError != NULL) {
         PyDict_SetItemString(d, "error", DbmError);
-        s = PyBytes_FromString(dbmmodule_open_flags);
+        s = PyString_FromString(dbmmodule_open_flags);
         PyDict_SetItemString(d, "open_flags", s);
         Py_DECREF(s);
     }
index 301a59362f1b59f80002c35c832c7121162ac863..01db9fcb289b96f2f11242cc4a6a36d341d98d92 100644 (file)
@@ -593,7 +593,7 @@ gl_lrectwrite(PyObject *self, PyObject *args)
 #if 0
 /* Don't check this, it breaks experiments with pixmode(PM_SIZE, ...) */
        pixcount = (long)(x2+1-x1) * (long)(y2+1-y1);
-       if (!PyBytes_Check(s) || PyBytes_Size(s) != pixcount*sizeof(long)) {
+       if (!PyString_Check(s) || PyString_Size(s) != pixcount*sizeof(long)) {
                PyErr_SetString(PyExc_RuntimeError,
                           "string arg to lrectwrite has wrong size");
                return NULL;
@@ -623,10 +623,10 @@ gl_lrectread(PyObject *self, PyObject *args)
        if (!PyArg_GetShort(args, 4, 3, &y2))
                return NULL;
        pixcount = (long)(x2+1-x1) * (long)(y2+1-y1);
-       parray = PyBytes_FromStringAndSize((char *)NULL, pixcount*sizeof(long));
+       parray = PyString_FromStringAndSize((char *)NULL, pixcount*sizeof(long));
        if (parray == NULL)
                return NULL; /* No memory */
-       lrectread(x1, y1, x2, y2, (unsigned long *) PyBytes_AsString(parray));
+       lrectread(x1, y1, x2, y2, (unsigned long *) PyString_AsString(parray));
        return parray;
 }
 
@@ -642,10 +642,10 @@ gl_readdisplay(PyObject *self, PyObject *args)
        if ( !PyArg_Parse(args, "hhhhl", &x1, &y1, &x2, &y2, &hints) )
          return 0;
        size = (long)(x2+1-x1) * (long)(y2+1-y1);
-       rv = PyBytes_FromStringAndSize((char *)NULL, size*sizeof(long));
+       rv = PyString_FromStringAndSize((char *)NULL, size*sizeof(long));
        if ( rv == NULL )
          return NULL;
-       parray = (unsigned long *)PyBytes_AsString(rv);
+       parray = (unsigned long *)PyString_AsString(rv);
        size_ret = readdisplay(x1, y1, x2, y2, parray, hints);
        if ( size_ret != size ) {
            printf("gl_readdisplay: got %ld pixels, expected %ld\n",
@@ -700,16 +700,16 @@ gl_packrect(PyObject *self, PyObject *args)
        pixcount = width*height;
        packedcount = ((width+packfactor-1)/packfactor) *
                ((height+packfactor-1)/packfactor);
-       if (PyBytes_Size(unpacked) != pixcount*sizeof(long)) {
+       if (PyString_Size(unpacked) != pixcount*sizeof(long)) {
                PyErr_SetString(PyExc_RuntimeError,
                           "string arg to packrect has wrong size");
                return NULL;
        }
-       packed = PyBytes_FromStringAndSize((char *)NULL, packedcount);
+       packed = PyString_FromStringAndSize((char *)NULL, packedcount);
        if (packed == NULL)
                return NULL;
-       parray = (unsigned long *) PyBytes_AsString(unpacked);
-       p = (unsigned char *) PyBytes_AsString(packed);
+       parray = (unsigned long *) PyString_AsString(unpacked);
+       p = (unsigned char *) PyString_AsString(packed);
        for (y = 0; y < height; y += packfactor, parray += packfactor*width) {
                for (x = 0; x < width; x += packfactor) {
                        pixel = parray[x];
@@ -758,16 +758,16 @@ gl_unpackrect(PyObject *self, PyObject *args)
        pixcount = width*height;
        packedcount = ((width+packfactor-1)/packfactor) *
                ((height+packfactor-1)/packfactor);
-       if (PyBytes_Size(packed) != packedcount) {
+       if (PyString_Size(packed) != packedcount) {
                PyErr_SetString(PyExc_RuntimeError,
                           "string arg to unpackrect has wrong size");
                return NULL;
        }
-       unpacked = PyBytes_FromStringAndSize((char *)NULL, pixcount*sizeof(long));
+       unpacked = PyString_FromStringAndSize((char *)NULL, pixcount*sizeof(long));
        if (unpacked == NULL)
                return NULL;
-       parray = (unsigned long *) PyBytes_AsString(unpacked);
-       p = (unsigned char *) PyBytes_AsString(packed);
+       parray = (unsigned long *) PyString_AsString(unpacked);
+       p = (unsigned char *) PyString_AsString(packed);
        if (packfactor == 1 && width*height > 0) {
                /* Just expand bytes to longs */
                register int x = width * height;
@@ -799,7 +799,7 @@ gl_gversion(PyObject *self, PyObject *args)
 {
        char buf[20];
        gversion(buf);
-       return PyBytes_FromString(buf);
+       return PyString_FromString(buf);
 }
 
 
index 74bf0dc7c15444345515470384d1aaf3cde528ee..e5b9f4708c67879bdaf21f5ea5e822940ee68541 100644 (file)
@@ -47,7 +47,7 @@ mkgrent(struct group *p)
         return NULL;
     }
     for (member = p->gr_mem; *member != NULL; member++) {
-        PyObject *x = PyBytes_FromString(*member);
+        PyObject *x = PyString_FromString(*member);
         if (x == NULL || PyList_Append(w, x) != 0) {
             Py_XDECREF(x);
             Py_DECREF(w);
@@ -58,13 +58,13 @@ mkgrent(struct group *p)
     }
 
 #define SET(i,val) PyStructSequence_SET_ITEM(v, i, val)
-    SET(setIndex++, PyBytes_FromString(p->gr_name));
+    SET(setIndex++, PyString_FromString(p->gr_name));
 #ifdef __VMS
     SET(setIndex++, Py_None);
     Py_INCREF(Py_None);
 #else
     if (p->gr_passwd)
-           SET(setIndex++, PyBytes_FromString(p->gr_passwd));
+           SET(setIndex++, PyString_FromString(p->gr_passwd));
     else {
            SET(setIndex++, Py_None);
            Py_INCREF(Py_None);
@@ -113,7 +113,7 @@ grp_getgrnam(PyObject *self, PyObject *pyo_name)
     py_str_name = PyObject_Str(pyo_name);
     if (!py_str_name)
            return NULL;
-    name = PyBytes_AS_STRING(py_str_name);
+    name = PyString_AS_STRING(py_str_name);
     
     if ((p = getgrnam(name)) == NULL) {
        PyErr_Format(PyExc_KeyError, "getgrnam(): name not found: %s", name);
index 105bedcf118afdb0d7d429438c93bfae63c3bba7..f67cd60dd47c1aa1cc4be862312419d4d4380a2a 100644 (file)
@@ -54,7 +54,7 @@ imageop_backward_compatible(void)
                return 1;
        if (bcos == NULL) {
                /* cache string object for future use */
-               bcos = PyBytes_FromString("backward_compatible");
+               bcos = PyString_FromString("backward_compatible");
                if (bcos == NULL)
                        return 1;
        }
@@ -97,11 +97,11 @@ imageop_crop(PyObject *self, PyObject *args)
        xstep = (newx1 < newx2)? 1 : -1;
        ystep = (newy1 < newy2)? 1 : -1;
     
-       rv = PyBytes_FromStringAndSize(NULL,
+       rv = PyString_FromStringAndSize(NULL,
                             (abs(newx2-newx1)+1)*(abs(newy2-newy1)+1)*size);
        if ( rv == 0 )
                return 0;
-       ncp = (char *)PyBytes_AsString(rv);
+       ncp = (char *)PyString_AsString(rv);
        nsp = (short *)ncp;
        nlp = (Py_Int32 *)ncp;
        newy2 += ystep;
@@ -150,10 +150,10 @@ imageop_scale(PyObject *self, PyObject *args)
                return 0;
        }
     
-       rv = PyBytes_FromStringAndSize(NULL, newx*newy*size);
+       rv = PyString_FromStringAndSize(NULL, newx*newy*size);
        if ( rv == 0 )
                return 0;
-       ncp = (char *)PyBytes_AsString(rv);
+       ncp = (char *)PyString_AsString(rv);
        nsp = (short *)ncp;
        nlp = (Py_Int32 *)ncp;
        for( iy = 0; iy < newy; iy++ ) {
@@ -195,10 +195,10 @@ imageop_tovideo(PyObject *self, PyObject *args)
                return 0;
        }
     
-       rv = PyBytes_FromStringAndSize(NULL, len);
+       rv = PyString_FromStringAndSize(NULL, len);
        if ( rv == 0 )
                return 0;
-       ncp = (unsigned char *)PyBytes_AsString(rv);
+       ncp = (unsigned char *)PyString_AsString(rv);
 
        if ( width == 1 ) {
                memcpy(ncp, cp, maxx);          /* Copy first line */
@@ -245,10 +245,10 @@ imageop_grey2mono(PyObject *self, PyObject *args)
                return 0;
        }
     
-       rv = PyBytes_FromStringAndSize(NULL, (len+7)/8);
+       rv = PyString_FromStringAndSize(NULL, (len+7)/8);
        if ( rv == 0 )
                return 0;
-       ncp = (unsigned char *)PyBytes_AsString(rv);
+       ncp = (unsigned char *)PyString_AsString(rv);
 
        bit = 0x80;
        ovalue = 0;
@@ -286,10 +286,10 @@ imageop_grey2grey4(PyObject *self, PyObject *args)
                return 0;
        }
     
-       rv = PyBytes_FromStringAndSize(NULL, (len+1)/2);
+       rv = PyString_FromStringAndSize(NULL, (len+1)/2);
        if ( rv == 0 )
                return 0;
-       ncp = (unsigned char *)PyBytes_AsString(rv);
+       ncp = (unsigned char *)PyString_AsString(rv);
        pos = 0;
        ovalue = 0;
        for ( i=0; i < len; i++ ) {
@@ -325,10 +325,10 @@ imageop_grey2grey2(PyObject *self, PyObject *args)
                return 0;
        }
     
-       rv = PyBytes_FromStringAndSize(NULL, (len+3)/4);
+       rv = PyString_FromStringAndSize(NULL, (len+3)/4);
        if ( rv == 0 )
                return 0;
-       ncp = (unsigned char *)PyBytes_AsString(rv);
+       ncp = (unsigned char *)PyString_AsString(rv);
        pos = 0;
        ovalue = 0;
        for ( i=0; i < len; i++ ) {
@@ -363,10 +363,10 @@ imageop_dither2mono(PyObject *self, PyObject *args)
                return 0;
        }
     
-       rv = PyBytes_FromStringAndSize(NULL, (len+7)/8);
+       rv = PyString_FromStringAndSize(NULL, (len+7)/8);
        if ( rv == 0 )
                return 0;
-       ncp = (unsigned char *)PyBytes_AsString(rv);
+       ncp = (unsigned char *)PyString_AsString(rv);
 
        bit = 0x80;
        ovalue = 0;
@@ -409,10 +409,10 @@ imageop_dither2grey2(PyObject *self, PyObject *args)
                return 0;
        }
     
-       rv = PyBytes_FromStringAndSize(NULL, (len+3)/4);
+       rv = PyString_FromStringAndSize(NULL, (len+3)/4);
        if ( rv == 0 )
                return 0;
-       ncp = (unsigned char *)PyBytes_AsString(rv);
+       ncp = (unsigned char *)PyString_AsString(rv);
        pos = 1;
        ovalue = 0;
        for ( i=0; i < len; i++ ) {
@@ -449,10 +449,10 @@ imageop_mono2grey(PyObject *self, PyObject *args)
                return 0;
        }
     
-       rv = PyBytes_FromStringAndSize(NULL, nlen);
+       rv = PyString_FromStringAndSize(NULL, nlen);
        if ( rv == 0 )
                return 0;
-       ncp = (unsigned char *)PyBytes_AsString(rv);
+       ncp = (unsigned char *)PyString_AsString(rv);
 
        bit = 0x80;
        for ( i=0; i < nlen; i++ ) {
@@ -486,10 +486,10 @@ imageop_grey22grey(PyObject *self, PyObject *args)
                return 0;
        }
     
-       rv = PyBytes_FromStringAndSize(NULL, nlen);
+       rv = PyString_FromStringAndSize(NULL, nlen);
        if ( rv == 0 )
                return 0;
-       ncp = (unsigned char *)PyBytes_AsString(rv);
+       ncp = (unsigned char *)PyString_AsString(rv);
 
        pos = 0;
        for ( i=0; i < nlen; i++ ) {
@@ -522,10 +522,10 @@ imageop_grey42grey(PyObject *self, PyObject *args)
                return 0;
        }
     
-       rv = PyBytes_FromStringAndSize(NULL, nlen);
+       rv = PyString_FromStringAndSize(NULL, nlen);
        if ( rv == 0 )
                return 0;
-       ncp = (unsigned char *)PyBytes_AsString(rv);
+       ncp = (unsigned char *)PyString_AsString(rv);
 
        pos = 0;
        for ( i=0; i < nlen; i++ ) {
@@ -559,10 +559,10 @@ imageop_rgb2rgb8(PyObject *self, PyObject *args)
                return 0;
        }
     
-       rv = PyBytes_FromStringAndSize(NULL, nlen);
+       rv = PyString_FromStringAndSize(NULL, nlen);
        if ( rv == 0 )
                return 0;
-       ncp = (unsigned char *)PyBytes_AsString(rv);
+       ncp = (unsigned char *)PyString_AsString(rv);
 
        for ( i=0; i < nlen; i++ ) {
                /* Bits in source: aaaaaaaa BBbbbbbb GGGggggg RRRrrrrr */
@@ -603,10 +603,10 @@ imageop_rgb82rgb(PyObject *self, PyObject *args)
                return 0;
        }
     
-       rv = PyBytes_FromStringAndSize(NULL, nlen*4);
+       rv = PyString_FromStringAndSize(NULL, nlen*4);
        if ( rv == 0 )
                return 0;
-       ncp = (unsigned char *)PyBytes_AsString(rv);
+       ncp = (unsigned char *)PyString_AsString(rv);
 
        for ( i=0; i < nlen; i++ ) {
                /* Bits in source: RRRBBGGG
@@ -653,10 +653,10 @@ imageop_rgb2grey(PyObject *self, PyObject *args)
                return 0;
        }
     
-       rv = PyBytes_FromStringAndSize(NULL, nlen);
+       rv = PyString_FromStringAndSize(NULL, nlen);
        if ( rv == 0 )
                return 0;
-       ncp = (unsigned char *)PyBytes_AsString(rv);
+       ncp = (unsigned char *)PyString_AsString(rv);
 
        for ( i=0; i < nlen; i++ ) {
                if (backward_compatible) {
@@ -698,10 +698,10 @@ imageop_grey2rgb(PyObject *self, PyObject *args)
                return 0;
        }
     
-       rv = PyBytes_FromStringAndSize(NULL, nlen*4);
+       rv = PyString_FromStringAndSize(NULL, nlen*4);
        if ( rv == 0 )
                return 0;
-       ncp = (unsigned char *)PyBytes_AsString(rv);
+       ncp = (unsigned char *)PyString_AsString(rv);
 
        for ( i=0; i < nlen; i++ ) {
                value = *cp++;
index 5a8adf2f916e1c2eff2be2d20aea9bec3af1c5ca..baa6eadb4a7b69b295163a99018970191b5704ab 100644 (file)
@@ -130,12 +130,12 @@ imgfile_read(PyObject *self, PyObject *args)
        }
 
        if ( zsize == 3 ) zsize = 4;
-       rv = PyBytes_FromStringAndSize((char *)NULL, xsize*ysize*zsize);
+       rv = PyString_FromStringAndSize((char *)NULL, xsize*ysize*zsize);
        if ( rv == NULL ) {
                iclose(image);
                return NULL;
        }
-       cdatap = PyBytes_AsString(rv);
+       cdatap = PyString_AsString(rv);
        idatap = (long *)cdatap;
 
        if (top_to_bottom) {
@@ -319,7 +319,7 @@ imgfile_readscaled(PyObject *self, PyObject *args)
        }
 
        if ( zsize == 3 ) zsize = 4;
-       rv = PyBytes_FromStringAndSize(NULL, xwtd*ywtd*zsize);
+       rv = PyString_FromStringAndSize(NULL, xwtd*ywtd*zsize);
        if ( rv == NULL ) {
                iclose(image);
                return NULL;
@@ -328,7 +328,7 @@ imgfile_readscaled(PyObject *self, PyObject *args)
        xfac = (float)xsize/(float)xwtd;
        yfac = (float)ysize/(float)ywtd;
        PyFPE_END_PROTECT(yfac)
-       cdatap = PyBytes_AsString(rv);
+       cdatap = PyString_AsString(rv);
        idatap = (long *)cdatap;
 
        if ( extended ) {
index f466b914e491626f3967149fe2461939ac779fa9..261e8f1b6f8866108efcb8a5c97edba2fd946d5d 100644 (file)
@@ -2904,12 +2904,12 @@ count_repr(countobject *lz)
        PyObject *result;
 
         if (lz->cnt != PY_SSIZE_T_MAX)
-               return PyBytes_FromFormat("count(%zd)", lz->cnt);
+               return PyString_FromFormat("count(%zd)", lz->cnt);
 
        cnt_repr = PyObject_Repr(lz->long_cnt);
        if (cnt_repr == NULL)
                return NULL;
-       result = PyBytes_FromFormat("count(%s)", PyBytes_AS_STRING(cnt_repr));
+       result = PyString_FromFormat("count(%s)", PyString_AS_STRING(cnt_repr));
        Py_DECREF(cnt_repr);
        return result;
 }
@@ -3221,11 +3221,11 @@ repeat_repr(repeatobject *ro)
                return NULL;
 
        if (ro->cnt == -1)
-               result = PyBytes_FromFormat("repeat(%s)",
-                       PyBytes_AS_STRING(objrepr));
+               result = PyString_FromFormat("repeat(%s)",
+                       PyString_AS_STRING(objrepr));
        else
-               result = PyBytes_FromFormat("repeat(%s, %zd)",
-                       PyBytes_AS_STRING(objrepr), ro->cnt);
+               result = PyString_FromFormat("repeat(%s, %zd)",
+                       PyString_AS_STRING(objrepr), ro->cnt);
        Py_DECREF(objrepr);
        return result;
 }      
index bde6e4992dfdf875e4c286f90eb4a28153de525d..80077c6f1e89a95a3fd9f7da4f47b639dcf5a638 100644 (file)
@@ -162,17 +162,17 @@ lad_read(lad_t *self, PyObject *args)
        
     if (!PyArg_ParseTuple(args, "i:read", &size))
         return NULL;
-    rv = PyBytes_FromStringAndSize(NULL, size);
+    rv = PyString_FromStringAndSize(NULL, size);
     if (rv == NULL)
         return NULL;
-    cp = PyBytes_AS_STRING(rv);
+    cp = PyString_AS_STRING(rv);
     if ((count = read(self->x_fd, cp, size)) < 0) {
         PyErr_SetFromErrno(LinuxAudioError);
         Py_DECREF(rv);
         return NULL;
     }
     self->x_icount += count;
-    _PyBytes_Resize(&rv, count);
+    _PyString_Resize(&rv, count);
     return rv;
 }
 
index c1c4b45e9cdf06c7383ca5b25a1c2ef2fca94b86..895a64f316fab9cb77b7ec98de8890a1b268271b 100644 (file)
@@ -196,7 +196,7 @@ static int RunMainFromImporter(char *filename)
 {
        PyObject *argv0 = NULL, *importer = NULL;
 
-       if ((argv0 = PyBytes_FromString(filename)) && 
+       if ((argv0 = PyString_FromString(filename)) && 
            (importer = PyImport_GetImporter(argv0)) &&
            (importer->ob_type != &PyNullImporter_Type))
        {
index 70952028dd124c3d5d7a89a0f055f02409165661..1e2e6e3ee81f14b7f478046d29fd0235fc728b5c 100644 (file)
@@ -80,7 +80,7 @@ md5_digest(md5object *self)
        mdContext = self->md5;
        md5_finish(&mdContext, aDigest);
 
-       return PyBytes_FromStringAndSize((char *)aDigest, 16);
+       return PyString_FromStringAndSize((char *)aDigest, 16);
 }
 
 PyDoc_STRVAR(digest_doc,
@@ -113,7 +113,7 @@ md5_hexdigest(md5object *self)
                c = (c>9) ? c+'a'-10 : c + '0';
                hexdigest[j++] = c;
        }
-       return PyBytes_FromStringAndSize((char*)hexdigest, 32);
+       return PyString_FromStringAndSize((char*)hexdigest, 32);
 }
 
 
@@ -165,7 +165,7 @@ md5_get_digest_size(PyObject *self, void *closure)
 static PyObject *
 md5_get_name(PyObject *self, void *closure)
 {
-    return PyBytes_FromStringAndSize("MD5", 3);
+    return PyString_FromStringAndSize("MD5", 3);
 }
 
 static PyGetSetDef md5_getseters[] = {
index 73fdf6d8385447876f948bf936cc3ecf9f663a1d..c71d8402cbd495ea6ce7eadcf1143a971d8c8efd 100644 (file)
@@ -222,7 +222,7 @@ mmap_read_line_method(mmap_object *self,
        else
                ++eol;          /* we're interested in the position after the
                                   newline. */
-       result = PyBytes_FromStringAndSize(start, (eol - start));
+       result = PyString_FromStringAndSize(start, (eol - start));
        self->pos += (eol - start);
        return result;
 }
@@ -700,7 +700,7 @@ mmap_item(mmap_object *self, Py_ssize_t i)
                PyErr_SetString(PyExc_IndexError, "mmap index out of range");
                return NULL;
        }
-       return PyBytes_FromStringAndSize(self->data + i, 1);
+       return PyString_FromStringAndSize(self->data + i, 1);
 }
 
 static PyObject *
@@ -718,7 +718,7 @@ mmap_slice(mmap_object *self, Py_ssize_t ilow, Py_ssize_t ihigh)
        else if ((size_t)ihigh > self->size)
                ihigh = self->size;
 
-       return PyBytes_FromStringAndSize(self->data + ilow, ihigh-ilow);
+       return PyString_FromStringAndSize(self->data + ilow, ihigh-ilow);
 }
 
 static PyObject *
@@ -736,7 +736,7 @@ mmap_subscript(mmap_object *self, PyObject *item)
                                "mmap index out of range");
                        return NULL;
                }
-               return PyBytes_FromStringAndSize(self->data + i, 1);
+               return PyString_FromStringAndSize(self->data + i, 1);
        }
        else if (PySlice_Check(item)) {
                Py_ssize_t start, stop, step, slicelen;
@@ -747,9 +747,9 @@ mmap_subscript(mmap_object *self, PyObject *item)
                }
                
                if (slicelen <= 0)
-                       return PyBytes_FromStringAndSize("", 0);
+                       return PyString_FromStringAndSize("", 0);
                else if (step == 1)
-                       return PyBytes_FromStringAndSize(self->data + start,
+                       return PyString_FromStringAndSize(self->data + start,
                                                          slicelen);
                else {
                        char *result_buf = (char *)PyMem_Malloc(slicelen);
@@ -762,7 +762,7 @@ mmap_subscript(mmap_object *self, PyObject *item)
                             cur += step, i++) {
                                result_buf[i] = self->data[cur];
                        }
-                       result = PyBytes_FromStringAndSize(result_buf,
+                       result = PyString_FromStringAndSize(result_buf,
                                                            slicelen);
                        PyMem_Free(result_buf);
                        return result;
@@ -815,19 +815,19 @@ mmap_ass_slice(mmap_object *self, Py_ssize_t ilow, Py_ssize_t ihigh, PyObject *v
                                "mmap object doesn't support slice deletion");
                return -1;
        }
-       if (! (PyBytes_Check(v)) ) {
+       if (! (PyString_Check(v)) ) {
                PyErr_SetString(PyExc_IndexError,
                                "mmap slice assignment must be a string");
                return -1;
        }
-       if (PyBytes_Size(v) != (ihigh - ilow)) {
+       if (PyString_Size(v) != (ihigh - ilow)) {
                PyErr_SetString(PyExc_IndexError,
                                "mmap slice assignment is wrong size");
                return -1;
        }
        if (!is_writeable(self))
                return -1;
-       buf = PyBytes_AsString(v);
+       buf = PyString_AsString(v);
        memcpy(self->data + ilow, buf, ihigh-ilow);
        return 0;
 }
@@ -847,14 +847,14 @@ mmap_ass_item(mmap_object *self, Py_ssize_t i, PyObject *v)
                                "mmap object doesn't support item deletion");
                return -1;
        }
-       if (! (PyBytes_Check(v) && PyBytes_Size(v)==1) ) {
+       if (! (PyString_Check(v) && PyString_Size(v)==1) ) {
                PyErr_SetString(PyExc_IndexError,
                                "mmap assignment must be single-character string");
                return -1;
        }
        if (!is_writeable(self))
                return -1;
-       buf = PyBytes_AsString(v);
+       buf = PyString_AsString(v);
        self->data[i] = buf[0];
        return 0;
 }
@@ -882,14 +882,14 @@ mmap_ass_subscript(mmap_object *self, PyObject *item, PyObject *value)
                                "mmap object doesn't support item deletion");
                        return -1;
                }
-               if (!PyBytes_Check(value) || PyBytes_Size(value) != 1) {
+               if (!PyString_Check(value) || PyString_Size(value) != 1) {
                        PyErr_SetString(PyExc_IndexError,
                          "mmap assignment must be single-character string");
                        return -1;
                }
                if (!is_writeable(self))
                        return -1;
-               buf = PyBytes_AsString(value);
+               buf = PyString_AsString(value);
                self->data[i] = buf[0];
                return 0;
        }
@@ -906,12 +906,12 @@ mmap_ass_subscript(mmap_object *self, PyObject *item, PyObject *value)
                                "mmap object doesn't support slice deletion");
                        return -1;
                }
-               if (!PyBytes_Check(value)) {
+               if (!PyString_Check(value)) {
                        PyErr_SetString(PyExc_IndexError,
                                "mmap slice assignment must be a string");
                        return -1;
                }
-               if (PyBytes_Size(value) != slicelen) {
+               if (PyString_Size(value) != slicelen) {
                        PyErr_SetString(PyExc_IndexError,
                                "mmap slice assignment is wrong size");
                        return -1;
@@ -922,7 +922,7 @@ mmap_ass_subscript(mmap_object *self, PyObject *item, PyObject *value)
                if (slicelen == 0)
                        return 0;
                else if (step == 1) {
-                       const char *buf = PyBytes_AsString(value);
+                       const char *buf = PyString_AsString(value);
 
                        if (buf == NULL)
                                return -1;
@@ -931,7 +931,7 @@ mmap_ass_subscript(mmap_object *self, PyObject *item, PyObject *value)
                }
                else {
                        Py_ssize_t cur, i;
-                       const char *buf = PyBytes_AsString(value);
+                       const char *buf = PyString_AsString(value);
                        
                        if (buf == NULL)
                                return -1;
index 8dd1d9673357981080ff77db0d5cb2ee117746eb..0811430cf03fe605077eabfd95f8c0833728b791 100644 (file)
@@ -115,8 +115,8 @@ nis_foreach (int instatus, char *inkey, int inkeylen, char *inval,
                    if (invallen > 0 && inval[invallen-1] == '\0')
                        invallen--;
                }
-               key = PyBytes_FromStringAndSize(inkey, inkeylen);
-               val = PyBytes_FromStringAndSize(inval, invallen);
+               key = PyString_FromStringAndSize(inkey, inkeylen);
+               val = PyString_FromStringAndSize(inval, invallen);
                if (key == NULL || val == NULL) {
                        /* XXX error -- don't know how to handle */
                        PyErr_Clear();
@@ -146,7 +146,7 @@ nis_get_default_domain (PyObject *self)
        if ((err = yp_get_default_domain(&domain)) != 0)
                return nis_error(err);
 
-       res = PyBytes_FromStringAndSize (domain, strlen(domain));
+       res = PyString_FromStringAndSize (domain, strlen(domain));
        return res;
 }
 
@@ -178,7 +178,7 @@ nis_match (PyObject *self, PyObject *args, PyObject *kwdict)
            len--;
        if (err != 0)
                return nis_error(err);
-       res = PyBytes_FromStringAndSize (match, len);
+       res = PyString_FromStringAndSize (match, len);
        free (match);
        return res;
 }
@@ -398,7 +398,7 @@ nis_maps (PyObject *self, PyObject *args, PyObject *kwdict)
        if ((list = PyList_New(0)) == NULL)
                return NULL;
        for (maps = maps; maps; maps = maps->next) {
-               PyObject *str = PyBytes_FromString(maps->map);
+               PyObject *str = PyString_FromString(maps->map);
                if (!str || PyList_Append(list, str) < 0)
                {
                        Py_DECREF(list);
index 7e4473970521f71343e725ad5fb2a09276857246..fd98efdbe7d64044989f89f8919b4e377cd1822d 100644 (file)
@@ -508,19 +508,19 @@ dotted_getattr(PyObject *obj, PyObject *attr)
        }
 #endif
        
-       if (!PyBytes_Check(attr)) {
+       if (!PyString_Check(attr)) {
                PyErr_SetString(PyExc_TypeError,
                                "attribute name must be a string");
                return NULL;
        }
 
-       s = PyBytes_AS_STRING(attr);
+       s = PyString_AS_STRING(attr);
        Py_INCREF(obj);
        for (;;) {
                PyObject *newobj, *str;
                p = strchr(s, '.');
-               str = p ? PyBytes_FromStringAndSize(s, (p-s)) : 
-                         PyBytes_FromString(s);
+               str = p ? PyString_FromStringAndSize(s, (p-s)) : 
+                         PyString_FromString(s);
                if (str == NULL) {
                        Py_DECREF(obj);
                        return NULL;
index 75f6c157efa6f64c1298236b2695b0d873e2fc7c..ebf101a2008f24bdab11b34907be2088a24bc2e8 100644 (file)
@@ -366,10 +366,10 @@ oss_read(oss_audio_t *self, PyObject *args)
 
     if (!PyArg_ParseTuple(args, "i:read", &size))
         return NULL;
-    rv = PyBytes_FromStringAndSize(NULL, size);
+    rv = PyString_FromStringAndSize(NULL, size);
     if (rv == NULL)
         return NULL;
-    cp = PyBytes_AS_STRING(rv);
+    cp = PyString_AS_STRING(rv);
 
     Py_BEGIN_ALLOW_THREADS
     count = read(self->fd, cp, size);
@@ -381,7 +381,7 @@ oss_read(oss_audio_t *self, PyObject *args)
         return NULL;
     }
     self->icount += count;
-    _PyBytes_Resize(&rv, count);
+    _PyString_Resize(&rv, count);
     return rv;
 }
 
@@ -811,20 +811,20 @@ oss_getattr(oss_audio_t *self, char *name)
         Py_INCREF(rval);
     }
     else if (strcmp(name, "name") == 0) {
-        rval = PyBytes_FromString(self->devicename);
+        rval = PyString_FromString(self->devicename);
     }
     else if (strcmp(name, "mode") == 0) {
         /* No need for a "default" in this switch: from newossobject(),
            self->mode can only be one of these three values. */
         switch(self->mode) {
             case O_RDONLY:
-                rval = PyBytes_FromString("r");
+                rval = PyString_FromString("r");
                 break;
             case O_RDWR:
-                rval = PyBytes_FromString("rw");
+                rval = PyString_FromString("rw");
                 break;
             case O_WRONLY:
-                rval = PyBytes_FromString("w");
+                rval = PyString_FromString("w");
                 break;
         }
     }
@@ -913,12 +913,12 @@ build_namelists (PyObject *module)
     if (labels == NULL || names == NULL)
         goto error2;
     for (i = 0; i < num_controls; i++) {
-        s = PyBytes_FromString(control_labels[i]);
+        s = PyString_FromString(control_labels[i]);
         if (s == NULL)
             goto error2;
         PyList_SET_ITEM(labels, i, s);
 
-        s = PyBytes_FromString(control_names[i]);
+        s = PyString_FromString(control_names[i]);
         if (s == NULL)
             goto error2;
         PyList_SET_ITEM(names, i, s);
index 2ff67f2216c129703e20eafe54d5268236ebd19a..6e52343e0db188669208650fc03013bcae7ebe37 100644 (file)
@@ -105,14 +105,14 @@ node2tuple(node *n,                     /* node to convert               */
         }
 
         if (TYPE(n) == encoding_decl)
-            (void) addelem(v, i+1, PyBytes_FromString(STR(n)));
+            (void) addelem(v, i+1, PyString_FromString(STR(n)));
         return (v);
     }
     else if (ISTERMINAL(TYPE(n))) {
         PyObject *result = mkseq(2 + lineno + col_offset);
         if (result != NULL) {
             (void) addelem(result, 0, PyInt_FromLong(TYPE(n)));
-            (void) addelem(result, 1, PyBytes_FromString(STR(n)));
+            (void) addelem(result, 1, PyString_FromString(STR(n)));
             if (lineno == 1)
                 (void) addelem(result, 2, PyInt_FromLong(n->n_lineno));
             if (col_offset == 1)
@@ -689,7 +689,7 @@ build_node_children(PyObject *tuple, node *root, int *line_num)
             temp = PySequence_GetItem(elem, 1);
             if (temp == NULL)
                 return 0;
-            if (!PyBytes_Check(temp)) {
+            if (!PyString_Check(temp)) {
                 PyErr_Format(parser_error,
                              "second item in terminal node must be a string,"
                              " found %s",
@@ -714,10 +714,10 @@ build_node_children(PyObject *tuple, node *root, int *line_num)
                     Py_DECREF(o);
                 }
             }
-            len = PyBytes_GET_SIZE(temp) + 1;
+            len = PyString_GET_SIZE(temp) + 1;
             strn = (char *)PyObject_MALLOC(len);
             if (strn != NULL)
-                (void) memcpy(strn, PyBytes_AS_STRING(temp), len);
+                (void) memcpy(strn, PyString_AS_STRING(temp), len);
             Py_DECREF(temp);
         }
         else if (!ISNONTERMINAL(type)) {
@@ -800,10 +800,10 @@ build_node_tree(PyObject *tuple)
             }
             if (res && encoding) {
                 Py_ssize_t len;
-                len = PyBytes_GET_SIZE(encoding) + 1;
+                len = PyString_GET_SIZE(encoding) + 1;
                 res->n_str = (char *)PyObject_MALLOC(len);
                 if (res->n_str != NULL)
-                    (void) memcpy(res->n_str, PyBytes_AS_STRING(encoding), len);
+                    (void) memcpy(res->n_str, PyString_AS_STRING(encoding), len);
                 Py_DECREF(encoding);
                 Py_DECREF(tuple);
             }
index 57fe088cc71c5751decc4f48bbd182fea97832cf..a4bbac556a7d38aad56e744b0550971242a4cb10 100644 (file)
@@ -375,12 +375,12 @@ convertenviron(void)
                char *p = strchr(*e, '=');
                if (p == NULL)
                        continue;
-               k = PyBytes_FromStringAndSize(*e, (int)(p-*e));
+               k = PyString_FromStringAndSize(*e, (int)(p-*e));
                if (k == NULL) {
                        PyErr_Clear();
                        continue;
                }
-               v = PyBytes_FromString(p+1);
+               v = PyString_FromString(p+1);
                if (v == NULL) {
                        PyErr_Clear();
                        Py_DECREF(k);
@@ -400,13 +400,13 @@ convertenviron(void)
 
         rc = DosQueryExtLIBPATH(buffer, BEGIN_LIBPATH);
        if (rc == NO_ERROR) { /* (not a type, envname is NOT 'BEGIN_LIBPATH') */
-            PyObject *v = PyBytes_FromString(buffer);
+            PyObject *v = PyString_FromString(buffer);
                    PyDict_SetItemString(d, "BEGINLIBPATH", v);
             Py_DECREF(v);
         }
         rc = DosQueryExtLIBPATH(buffer, END_LIBPATH);
         if (rc == NO_ERROR) { /* (not a typo, envname is NOT 'END_LIBPATH') */
-            PyObject *v = PyBytes_FromString(buffer);
+            PyObject *v = PyString_FromString(buffer);
                    PyDict_SetItemString(d, "ENDLIBPATH", v);
             Py_DECREF(v);
         }
@@ -1598,7 +1598,7 @@ posix_ttyname(PyObject *self, PyObject *args)
 #endif
        if (ret == NULL)
                return posix_error();
-       return PyBytes_FromString(ret);
+       return PyString_FromString(ret);
 }
 #endif
 
@@ -1620,7 +1620,7 @@ posix_ctermid(PyObject *self, PyObject *noargs)
 #endif
        if (ret == NULL)
                return posix_error();
-       return PyBytes_FromString(buffer);
+       return PyString_FromString(buffer);
 }
 #endif
 
@@ -1968,7 +1968,7 @@ posix_getcwd(PyObject *self, PyObject *noargs)
        Py_END_ALLOW_THREADS
        if (res == NULL)
                return posix_error();
-       return PyBytes_FromString(buf);
+       return PyString_FromString(buf);
 }
 
 #ifdef Py_USING_UNICODE
@@ -2174,7 +2174,7 @@ posix_listdir(PyObject *self, PyObject *args)
                /* Skip over . and .. */
                if (strcmp(FileData.cFileName, ".") != 0 &&
                    strcmp(FileData.cFileName, "..") != 0) {
-                       v = PyBytes_FromString(FileData.cFileName);
+                       v = PyString_FromString(FileData.cFileName);
                        if (v == NULL) {
                                Py_DECREF(d);
                                d = NULL;
@@ -2262,7 +2262,7 @@ posix_listdir(PyObject *self, PyObject *args)
             /* Leave Case of Name Alone -- In Native Form */
             /* (Removed Forced Lowercasing Code) */
 
-            v = PyBytes_FromString(namebuf);
+            v = PyString_FromString(namebuf);
             if (v == NULL) {
                 Py_DECREF(d);
                 d = NULL;
@@ -2312,7 +2312,7 @@ posix_listdir(PyObject *self, PyObject *args)
                    (NAMLEN(ep) == 1 ||
                     (ep->d_name[1] == '.' && NAMLEN(ep) == 2)))
                        continue;
-               v = PyBytes_FromStringAndSize(ep->d_name, NAMLEN(ep));
+               v = PyString_FromStringAndSize(ep->d_name, NAMLEN(ep));
                if (v == NULL) {
                        Py_DECREF(d);
                        d = NULL;
@@ -2397,7 +2397,7 @@ posix__getfullpathname(PyObject *self, PyObject *args)
                return PyUnicode_Decode(outbuf, strlen(outbuf),
                        Py_FileSystemDefaultEncoding, NULL);
        }
-       return PyBytes_FromString(outbuf);
+       return PyString_FromString(outbuf);
 } /* end of posix__getfullpathname */
 #endif /* MS_WINDOWS */
 
@@ -3062,7 +3062,7 @@ posix_execve(PyObject *self, PyObject *args)
         /* Omit Pseudo-Env Vars that Would Confuse Programs if Passed On */
         if (stricmp(k, "BEGINLIBPATH") != 0 && stricmp(k, "ENDLIBPATH") != 0) {
 #endif
-               len = PyBytes_Size(key) + PyBytes_Size(val) + 2;
+               len = PyString_Size(key) + PyString_Size(val) + 2;
                p = PyMem_NEW(char, len);
                if (p == NULL) {
                        PyErr_NoMemory();
@@ -3292,7 +3292,7 @@ posix_spawnve(PyObject *self, PyObject *args)
                {
                        goto fail_2;
                }
-               len = PyBytes_Size(key) + PyBytes_Size(val) + 2;
+               len = PyString_Size(key) + PyString_Size(val) + 2;
                p = PyMem_NEW(char, len);
                if (p == NULL) {
                        PyErr_NoMemory();
@@ -3525,7 +3525,7 @@ posix_spawnvpe(PyObject *self, PyObject *args)
                {
                        goto fail_2;
                }
-               len = PyBytes_Size(key) + PyBytes_Size(val) + 2;
+               len = PyString_Size(key) + PyString_Size(val) + 2;
                p = PyMem_NEW(char, len);
                if (p == NULL) {
                        PyErr_NoMemory();
@@ -3895,7 +3895,7 @@ posix_getlogin(PyObject *self, PyObject *noargs)
                                 "unable to determine login name");
         }
         else
-            result = PyBytes_FromString(name);
+            result = PyString_FromString(name);
         errno = old_errno;
 
     return result;
@@ -5884,7 +5884,7 @@ posix_readlink(PyObject *self, PyObject *args)
                return posix_error_with_allocated_filename(path);
 
        PyMem_Free(path);
-       v = PyBytes_FromStringAndSize(buf, n);
+       v = PyString_FromStringAndSize(buf, n);
 #ifdef Py_USING_UNICODE
        if (arg_is_unicode) {
                PyObject *w;
@@ -6289,18 +6289,18 @@ posix_read(PyObject *self, PyObject *args)
                errno = EINVAL;
                return posix_error();
        }
-       buffer = PyBytes_FromStringAndSize((char *)NULL, size);
+       buffer = PyString_FromStringAndSize((char *)NULL, size);
        if (buffer == NULL)
                return NULL;
        Py_BEGIN_ALLOW_THREADS
-       n = read(fd, PyBytes_AsString(buffer), size);
+       n = read(fd, PyString_AsString(buffer), size);
        Py_END_ALLOW_THREADS
        if (n < 0) {
                Py_DECREF(buffer);
                return posix_error();
        }
        if (n != size)
-               _PyBytes_Resize(&buffer, n);
+               _PyString_Resize(&buffer, n);
        return buffer;
 }
 
@@ -6647,11 +6647,11 @@ posix_putenv(PyObject *self, PyObject *args)
        /* XXX This can leak memory -- not easy to fix :-( */
        len = strlen(s1) + strlen(s2) + 2;
        /* len includes space for a trailing \0; the size arg to
-          PyBytes_FromStringAndSize does not count that */
-       newstr = PyBytes_FromStringAndSize(NULL, (int)len - 1);
+          PyString_FromStringAndSize does not count that */
+       newstr = PyString_FromStringAndSize(NULL, (int)len - 1);
        if (newstr == NULL)
                return PyErr_NoMemory();
-       newenv = PyBytes_AS_STRING(newstr);
+       newenv = PyString_AS_STRING(newstr);
        PyOS_snprintf(newenv, len, "%s=%s", s1, s2);
        if (putenv(newenv)) {
                 Py_DECREF(newstr);
@@ -6727,7 +6727,7 @@ posix_strerror(PyObject *self, PyObject *args)
                                "strerror() argument out of range");
                return NULL;
        }
-       return PyBytes_FromString(message);
+       return PyString_FromString(message);
 }
 
 
@@ -7009,7 +7009,7 @@ posix_tempnam(PyObject *self, PyObject *args)
 #endif
     if (name == NULL)
         return PyErr_NoMemory();
-    result = PyBytes_FromString(name);
+    result = PyString_FromString(name);
     free(name);
     return result;
 }
@@ -7066,7 +7066,7 @@ posix_tmpnam(PyObject *self, PyObject *noargs)
        Py_XDECREF(err);
        return NULL;
     }
-    return PyBytes_FromString(buffer);
+    return PyString_FromString(buffer);
 }
 #endif
 
@@ -7095,13 +7095,13 @@ conv_confname(PyObject *arg, int *valuep, struct constdef *table,
         *valuep = PyInt_AS_LONG(arg);
         return 1;
     }
-    if (PyBytes_Check(arg)) {
+    if (PyString_Check(arg)) {
         /* look up the value in the table using a binary search */
         size_t lo = 0;
                size_t mid;
         size_t hi = tablesize;
         int cmp;
-        char *confname = PyBytes_AS_STRING(arg);
+        char *confname = PyString_AS_STRING(arg);
         while (lo < hi) {
             mid = (lo + hi) / 2;
             cmp = strcmp(confname, table[mid].name);
@@ -7431,12 +7431,12 @@ posix_confstr(PyObject *self, PyObject *args)
         }
         else {
            if ((unsigned int)len >= sizeof(buffer)) {
-                result = PyBytes_FromStringAndSize(NULL, len-1);
+                result = PyString_FromStringAndSize(NULL, len-1);
                 if (result != NULL)
-                    confstr(name, PyBytes_AS_STRING(result), len);
+                    confstr(name, PyString_AS_STRING(result), len);
             }
             else
-                result = PyBytes_FromStringAndSize(buffer, len-1);
+                result = PyString_FromStringAndSize(buffer, len-1);
         }
     }
     return result;
@@ -8225,11 +8225,11 @@ win32_urandom(PyObject *self, PyObject *args)
        }
 
        /* Allocate bytes */
-       result = PyBytes_FromStringAndSize(NULL, howMany);
+       result = PyString_FromStringAndSize(NULL, howMany);
        if (result != NULL) {
                /* Get random data */
                if (! pCryptGenRandom(hCryptProv, howMany, (unsigned char*)
-                                     PyBytes_AS_STRING(result))) {
+                                     PyString_AS_STRING(result))) {
                        Py_DECREF(result);
                        return win32_error("CryptGenRandom", NULL);
                }
@@ -8259,11 +8259,11 @@ vms_urandom(PyObject *self, PyObject *args)
                                    "negative argument not allowed");
 
        /* Allocate bytes */
-       result = PyBytes_FromStringAndSize(NULL, howMany);
+       result = PyString_FromStringAndSize(NULL, howMany);
        if (result != NULL) {
                /* Get random data */
                if (RAND_pseudo_bytes((unsigned char*)
-                                     PyBytes_AS_STRING(result),
+                                     PyString_AS_STRING(result),
                                      howMany) < 0) {
                        Py_DECREF(result);
                        return PyErr_Format(PyExc_ValueError,
index dff1bcbc5230ddedb1bcbb817c903294339bb711..9e01f4875768fd957e7045a8d2c895875b1d8c76 100644 (file)
@@ -49,7 +49,7 @@ static void
 sets(PyObject *v, int i, char* val)
 {
   if (val)
-         PyStructSequence_SET_ITEM(v, i, PyBytes_FromString(val));
+         PyStructSequence_SET_ITEM(v, i, PyString_FromString(val));
   else {
          PyStructSequence_SET_ITEM(v, i, Py_None);
          Py_INCREF(Py_None);
index f85b2efa164bc3801a552b271724fe5fc32d8749..01971b78ed91de65f4fb66dcaf613a721a9ad801 100644 (file)
@@ -153,7 +153,7 @@ get_handler_name(struct HandlerInfo *hinfo)
 {
     PyObject *name = hinfo->nameobj;
     if (name == NULL) {
-        name = PyBytes_FromString(hinfo->name);
+        name = PyString_FromString(hinfo->name);
         hinfo->nameobj = name;
     }
     Py_XINCREF(name);
@@ -205,7 +205,7 @@ conv_string_to_utf8(const XML_Char *str)
         Py_INCREF(Py_None);
         return Py_None;
     }
-    return PyBytes_FromString(str);
+    return PyString_FromString(str);
 }
 
 static PyObject *
@@ -218,7 +218,7 @@ conv_string_len_to_utf8(const XML_Char *str, int len)
         Py_INCREF(Py_None);
         return Py_None;
     }
-    return PyBytes_FromStringAndSize((const char *)str, len);
+    return PyString_FromStringAndSize((const char *)str, len);
 }
 
 /* Callback routines */
@@ -267,16 +267,16 @@ getcode(enum HandlerTypes slot, char* func_name, int lineno)
     PyObject *filename = NULL;
 
     if (handler_info[slot].tb_code == NULL) {
-        code = PyBytes_FromString("");
+        code = PyString_FromString("");
         if (code == NULL)
             goto failed;
-        name = PyBytes_FromString(func_name);
+        name = PyString_FromString(func_name);
         if (name == NULL)
             goto failed;
         nulltuple = PyTuple_New(0);
         if (nulltuple == NULL)
             goto failed;
-        filename = PyBytes_FromString(__FILE__);
+        filename = PyString_FromString(__FILE__);
         handler_info[slot].tb_code =
             PyCode_New(0,              /* argcount */
                        0,              /* nlocals */
@@ -971,13 +971,13 @@ readinst(char *buf, int buf_size, PyObject *meth)
         goto finally;
 
     /* XXX what to do if it returns a Unicode string? */
-    if (!PyBytes_Check(str)) {
+    if (!PyString_Check(str)) {
         PyErr_Format(PyExc_TypeError,
                      "read() did not return a string object (type=%.400s)",
                      Py_TYPE(str)->tp_name);
         goto finally;
     }
-    len = PyBytes_GET_SIZE(str);
+    len = PyString_GET_SIZE(str);
     if (len > buf_size) {
         PyErr_Format(PyExc_ValueError,
                      "read() returned too much data: "
@@ -985,7 +985,7 @@ readinst(char *buf, int buf_size, PyObject *meth)
                      buf_size, len);
         goto finally;
     }
-    memcpy(buf, PyBytes_AsString(str), len);
+    memcpy(buf, PyString_AsString(str), len);
 finally:
     Py_XDECREF(arg);
     Py_XDECREF(str);
@@ -1094,7 +1094,7 @@ xmlparse_GetInputContext(xmlparseobject *self, PyObject *unused)
             = XML_GetInputContext(self->itself, &offset, &size);
 
         if (buffer != NULL)
-            return PyBytes_FromStringAndSize(buffer + offset,
+            return PyString_FromStringAndSize(buffer + offset,
                                               size - offset);
         else
             Py_RETURN_NONE;
@@ -1511,7 +1511,7 @@ xmlparse_getattr(xmlparseobject *self, char *name)
 
 #define APPEND(list, str)                              \
         do {                                           \
-                PyObject *o = PyBytes_FromString(str); \
+                PyObject *o = PyString_FromString(str);        \
                 if (o != NULL)                         \
                        PyList_Append(list, o);         \
                 Py_XDECREF(o);                         \
@@ -1862,7 +1862,7 @@ get_version_string(void)
     while (rev[i] != ' ' && rev[i] != '\0')
         ++i;
 
-    return PyBytes_FromStringAndSize(rev, i);
+    return PyString_FromStringAndSize(rev, i);
 }
 
 /* Initialization function for the module */
@@ -1889,7 +1889,7 @@ PyMODINIT_FUNC
 MODULE_INITFUNC(void)
 {
     PyObject *m, *d;
-    PyObject *errmod_name = PyBytes_FromString(MODULE_NAME ".errors");
+    PyObject *errmod_name = PyString_FromString(MODULE_NAME ".errors");
     PyObject *errors_module;
     PyObject *modelmod_name;
     PyObject *model_module;
@@ -1899,7 +1899,7 @@ MODULE_INITFUNC(void)
 
     if (errmod_name == NULL)
         return;
-    modelmod_name = PyBytes_FromString(MODULE_NAME ".model");
+    modelmod_name = PyString_FromString(MODULE_NAME ".model");
     if (modelmod_name == NULL)
         return;
 
index f988d5001af76c4b1e893f7ce0d16a2adb0b9f30..90904ab434faac37f7ade09030df7f285bb2d695 100644 (file)
@@ -421,7 +421,7 @@ add a line to the history buffer");
 static PyObject *
 get_completer_delims(PyObject *self, PyObject *noarg)
 {
-       return PyBytes_FromString(rl_completer_word_break_characters);
+       return PyString_FromString(rl_completer_word_break_characters);
 }
 
 PyDoc_STRVAR(doc_get_completer_delims,
@@ -471,7 +471,7 @@ get_history_item(PyObject *self, PyObject *args)
        if (!PyArg_ParseTuple(args, "i:index", &idx))
                return NULL;
        if ((hist_ent = history_get(idx)))
-               return PyBytes_FromString(hist_ent->line);
+               return PyString_FromString(hist_ent->line);
        else {
                Py_RETURN_NONE;
        }
@@ -503,7 +503,7 @@ return the current (not the maximum) length of history.");
 static PyObject *
 get_line_buffer(PyObject *self, PyObject *noarg)
 {
-       return PyBytes_FromString(rl_line_buffer);
+       return PyString_FromString(rl_line_buffer);
 }
 
 PyDoc_STRVAR(doc_get_line_buffer,
@@ -676,7 +676,7 @@ on_completion_display_matches_hook(char **matches,
        if (m == NULL)
                goto error;
        for (i = 0; i < num_matches; i++) {
-               s = PyBytes_FromString(matches[i+1]);
+               s = PyString_FromString(matches[i+1]);
                if (s == NULL)
                        goto error;
                if (PyList_SetItem(m, i, s) == -1)
@@ -725,7 +725,7 @@ on_completion(const char *text, int state)
                        result = NULL;
                }
                else {
-                       char *s = PyBytes_AsString(r);
+                       char *s = PyString_AsString(r);
                        if (s == NULL)
                                goto error;
                        result = strdup(s);
index 252332dc6b26b9e51a1eab14aceadfdc5b61e474..83a6538a411790fe22e1728a728223401cf405c5 100644 (file)
@@ -1219,7 +1219,7 @@ kqueue_event_repr(kqueue_event_Object *s)
                "data=0x%lx udata=%p>",
                (unsigned long)(s->e.ident), s->e.filter, s->e.flags,
                s->e.fflags, (long)(s->e.data), s->e.udata);
-       return PyBytes_FromString(buf);
+       return PyString_FromString(buf);
 }
 
 static int
index d2eefa44292ba1d69283e80fcfdb7d8add29558b..7d569002013e6131d07aedb81bdde64a937730da 100644 (file)
@@ -432,7 +432,7 @@ SHA256_digest(SHAobject *self, PyObject *unused)
 
     SHAcopy(self, &temp);
     sha_final(digest, &temp);
-    return PyBytes_FromStringAndSize((const char *)digest, self->digestsize);
+    return PyString_FromStringAndSize((const char *)digest, self->digestsize);
 }
 
 PyDoc_STRVAR(SHA256_hexdigest__doc__,
@@ -452,10 +452,10 @@ SHA256_hexdigest(SHAobject *self, PyObject *unused)
     sha_final(digest, &temp);
 
     /* Create a new string */
-    retval = PyBytes_FromStringAndSize(NULL, self->digestsize * 2);
+    retval = PyString_FromStringAndSize(NULL, self->digestsize * 2);
     if (!retval)
            return NULL;
-    hex_digest = PyBytes_AsString(retval);
+    hex_digest = PyString_AsString(retval);
     if (!hex_digest) {
            Py_DECREF(retval);
            return NULL;
@@ -510,9 +510,9 @@ static PyObject *
 SHA256_get_name(PyObject *self, void *closure)
 {
     if (((SHAobject *)self)->digestsize == 32)
-        return PyBytes_FromStringAndSize("SHA256", 6);
+        return PyString_FromStringAndSize("SHA256", 6);
     else
-        return PyBytes_FromStringAndSize("SHA224", 6);
+        return PyString_FromStringAndSize("SHA224", 6);
 }
 
 static PyGetSetDef SHA_getseters[] = {
index 1a2b145aa5d1084bef5dfce78036b47065066298..f2c230b3fa0f7bb1ec3924f6eb1f0e22441787fe 100644 (file)
@@ -498,7 +498,7 @@ SHA512_digest(SHAobject *self, PyObject *unused)
 
     SHAcopy(self, &temp);
     sha512_final(digest, &temp);
-    return PyBytes_FromStringAndSize((const char *)digest, self->digestsize);
+    return PyString_FromStringAndSize((const char *)digest, self->digestsize);
 }
 
 PyDoc_STRVAR(SHA512_hexdigest__doc__,
@@ -518,10 +518,10 @@ SHA512_hexdigest(SHAobject *self, PyObject *unused)
     sha512_final(digest, &temp);
 
     /* Create a new string */
-    retval = PyBytes_FromStringAndSize(NULL, self->digestsize * 2);
+    retval = PyString_FromStringAndSize(NULL, self->digestsize * 2);
     if (!retval)
            return NULL;
-    hex_digest = PyBytes_AsString(retval);
+    hex_digest = PyString_AsString(retval);
     if (!hex_digest) {
            Py_DECREF(retval);
            return NULL;
@@ -576,9 +576,9 @@ static PyObject *
 SHA512_get_name(PyObject *self, void *closure)
 {
     if (((SHAobject *)self)->digestsize == 64)
-        return PyBytes_FromStringAndSize("SHA512", 6);
+        return PyString_FromStringAndSize("SHA512", 6);
     else
-        return PyBytes_FromStringAndSize("SHA384", 6);
+        return PyString_FromStringAndSize("SHA384", 6);
 }
 
 static PyGetSetDef SHA_getseters[] = {
index 0cb8784048944d40fc0935da53724d683b037d75..1a7fc2c5ee69b0c755d7e08d43e7a2fa9a7ceb35 100644 (file)
@@ -380,7 +380,7 @@ SHA_digest(SHAobject *self, PyObject *unused)
 
     SHAcopy(self, &temp);
     sha_final(digest, &temp);
-    return PyBytes_FromStringAndSize((const char *)digest, sizeof(digest));
+    return PyString_FromStringAndSize((const char *)digest, sizeof(digest));
 }
 
 PyDoc_STRVAR(SHA_hexdigest__doc__,
@@ -400,10 +400,10 @@ SHA_hexdigest(SHAobject *self, PyObject *unused)
     sha_final(digest, &temp);
 
     /* Create a new string */
-    retval = PyBytes_FromStringAndSize(NULL, sizeof(digest) * 2);
+    retval = PyString_FromStringAndSize(NULL, sizeof(digest) * 2);
     if (!retval)
            return NULL;
-    hex_digest = PyBytes_AsString(retval);
+    hex_digest = PyString_AsString(retval);
     if (!hex_digest) {
            Py_DECREF(retval);
            return NULL;
@@ -463,7 +463,7 @@ SHA_get_digest_size(PyObject *self, void *closure)
 static PyObject *
 SHA_get_name(PyObject *self, void *closure)
 {
-    return PyBytes_FromStringAndSize("SHA1", 4);
+    return PyString_FromStringAndSize("SHA1", 4);
 }
 
 static PyGetSetDef SHA_getseters[] = {
index fd6b5531babd2cee843e3b1b77fb679c4d6a1d42..e9568315d4f4b49b181e09f977103ea51762030d 100644 (file)
@@ -911,7 +911,7 @@ makeipaddr(struct sockaddr *addr, int addrlen)
                set_gaierror(error);
                return NULL;
        }
-       return PyBytes_FromString(buf);
+       return PyString_FromString(buf);
 }
 
 
@@ -955,7 +955,7 @@ makebdaddr(bdaddr_t *bdaddr)
        sprintf(buf, "%02X:%02X:%02X:%02X:%02X:%02X",
                bdaddr->b[5], bdaddr->b[4], bdaddr->b[3],
                bdaddr->b[2], bdaddr->b[1], bdaddr->b[0]);
-       return PyBytes_FromString(buf);
+       return PyString_FromString(buf);
 }
 #endif
 
@@ -1002,14 +1002,14 @@ makesockaddr(int sockfd, struct sockaddr *addr, int addrlen, int proto)
 #ifdef linux
                if (a->sun_path[0] == 0) {  /* Linux abstract namespace */
                        addrlen -= offsetof(struct sockaddr_un, sun_path);
-                       return PyBytes_FromStringAndSize(a->sun_path,
+                       return PyString_FromStringAndSize(a->sun_path,
                                                          addrlen);
                }
                else
 #endif /* linux */
                {
                        /* regular NULL-terminated string */
-                       return PyBytes_FromString(a->sun_path);
+                       return PyString_FromString(a->sun_path);
                }
        }
 #endif /* AF_UNIX */
@@ -1362,7 +1362,7 @@ getsockaddrarg(PySocketSockObject *s, PyObject *args,
 
                        addr = (struct sockaddr_sco *)addr_ret;
                        _BT_SCO_MEMB(addr, family) = AF_BLUETOOTH;
-                       straddr = PyBytes_AsString(args);
+                       straddr = PyString_AsString(args);
                        if (straddr == NULL) {
                                PyErr_SetString(socket_error, "getsockaddrarg: "
                                                "wrong format");
@@ -1854,16 +1854,16 @@ sock_getsockopt(PySocketSockObject *s, PyObject *args)
                                "getsockopt buflen out of range");
                return NULL;
        }
-       buf = PyBytes_FromStringAndSize((char *)NULL, buflen);
+       buf = PyString_FromStringAndSize((char *)NULL, buflen);
        if (buf == NULL)
                return NULL;
        res = getsockopt(s->sock_fd, level, optname,
-                        (void *)PyBytes_AS_STRING(buf), &buflen);
+                        (void *)PyString_AS_STRING(buf), &buflen);
        if (res < 0) {
                Py_DECREF(buf);
                return s->errorhandler();
        }
-       _PyBytes_Resize(&buf, buflen);
+       _PyString_Resize(&buf, buflen);
        return buf;
 #endif /* __BEOS__ */
 }
@@ -2386,12 +2386,12 @@ sock_recv(PySocketSockObject *s, PyObject *args)
        }
 
        /* Allocate a new string. */
-       buf = PyBytes_FromStringAndSize((char *) 0, recvlen);
+       buf = PyString_FromStringAndSize((char *) 0, recvlen);
        if (buf == NULL)
                return NULL;
 
        /* Call the guts */
-       outlen = sock_recv_guts(s, PyBytes_AS_STRING(buf), recvlen, flags);
+       outlen = sock_recv_guts(s, PyString_AS_STRING(buf), recvlen, flags);
        if (outlen < 0) {
                /* An error occurred, release the string and return an
                   error. */
@@ -2401,7 +2401,7 @@ sock_recv(PySocketSockObject *s, PyObject *args)
        if (outlen != recvlen) {
                /* We did not read as many bytes as we anticipated, resize the
                   string if possible and be succesful. */
-               if (_PyBytes_Resize(&buf, outlen) < 0)
+               if (_PyString_Resize(&buf, outlen) < 0)
                        /* Oopsy, not so succesful after all. */
                        return NULL;
        }
@@ -2560,11 +2560,11 @@ sock_recvfrom(PySocketSockObject *s, PyObject *args)
                return NULL;
        }
 
-       buf = PyBytes_FromStringAndSize((char *) 0, recvlen);
+       buf = PyString_FromStringAndSize((char *) 0, recvlen);
        if (buf == NULL)
                return NULL;
 
-       outlen = sock_recvfrom_guts(s, PyBytes_AS_STRING(buf),
+       outlen = sock_recvfrom_guts(s, PyString_AS_STRING(buf),
                                    recvlen, flags, &addr);
        if (outlen < 0) {
                goto finally;
@@ -2573,7 +2573,7 @@ sock_recvfrom(PySocketSockObject *s, PyObject *args)
        if (outlen != recvlen) {
                /* We did not read as many bytes as we anticipated, resize the
                   string if possible and be succesful. */
-               if (_PyBytes_Resize(&buf, outlen) < 0)
+               if (_PyString_Resize(&buf, outlen) < 0)
                        /* Oopsy, not so succesful after all. */
                        goto finally;
        }
@@ -2941,7 +2941,7 @@ sock_repr(PySocketSockObject *s)
                (long)s->sock_fd, s->sock_family,
                s->sock_type,
                s->sock_proto);
-       return PyBytes_FromString(buf);
+       return PyString_FromString(buf);
 }
 
 
@@ -3057,7 +3057,7 @@ socket_gethostname(PyObject *self, PyObject *unused)
        if (res < 0)
                return set_error();
        buf[sizeof buf - 1] = '\0';
-       return PyBytes_FromString(buf);
+       return PyString_FromString(buf);
 }
 
 PyDoc_STRVAR(gethostname_doc,
@@ -3143,7 +3143,7 @@ gethost_common(struct hostent *h, struct sockaddr *addr, int alen, int af)
        if (h->h_aliases) {
                for (pch = h->h_aliases; *pch != NULL; pch++) {
                        int status;
-                       tmp = PyBytes_FromString(*pch);
+                       tmp = PyString_FromString(*pch);
                        if (tmp == NULL)
                                goto err;
 
@@ -3432,7 +3432,7 @@ socket_getservbyport(PyObject *self, PyObject *args)
                PyErr_SetString(socket_error, "port/proto not found");
                return NULL;
        }
-       return PyBytes_FromString(sp->s_name);
+       return PyString_FromString(sp->s_name);
 }
 
 PyDoc_STRVAR(getservbyport_doc,
@@ -3734,7 +3734,7 @@ socket_inet_aton(PyObject *self, PyObject *args)
     if (inet_aton != NULL) {
 #endif
        if (inet_aton(ip_addr, &buf))
-               return PyBytes_FromStringAndSize((char *)(&buf),
+               return PyString_FromStringAndSize((char *)(&buf),
                                                  sizeof(buf));
 
        PyErr_SetString(socket_error,
@@ -3763,7 +3763,7 @@ socket_inet_aton(PyObject *self, PyObject *args)
                        return NULL;
                }
        }
-       return PyBytes_FromStringAndSize((char *) &packed_addr,
+       return PyString_FromStringAndSize((char *) &packed_addr,
                                          sizeof(packed_addr));
 
 #ifdef USE_INET_ATON_WEAKLINK
@@ -3797,7 +3797,7 @@ socket_inet_ntoa(PyObject *self, PyObject *args)
 
        memcpy(&packed_addr, packed_str, addr_len);
 
-       return PyBytes_FromString(inet_ntoa(packed_addr));
+       return PyString_FromString(inet_ntoa(packed_addr));
 }
 
 #ifdef HAVE_INET_PTON
@@ -3840,11 +3840,11 @@ socket_inet_pton(PyObject *self, PyObject *args)
                        "illegal IP address string passed to inet_pton");
                return NULL;
        } else if (af == AF_INET) {
-               return PyBytes_FromStringAndSize(packed,
+               return PyString_FromStringAndSize(packed,
                        sizeof(struct in_addr));
 #ifdef ENABLE_IPV6
        } else if (af == AF_INET6) {
-               return PyBytes_FromStringAndSize(packed,
+               return PyString_FromStringAndSize(packed,
                        sizeof(struct in6_addr));
 #endif
        } else {
@@ -3871,7 +3871,7 @@ socket_inet_ntop(PyObject *self, PyObject *args)
        char ip[INET_ADDRSTRLEN + 1];
 #endif
 
-       /* Guarantee NUL-termination for PyBytes_FromString() below */
+       /* Guarantee NUL-termination for PyString_FromString() below */
        memset((void *) &ip[0], '\0', sizeof(ip));
 
        if (!PyArg_ParseTuple(args, "is#:inet_ntop", &af, &packed, &len)) {
@@ -3903,7 +3903,7 @@ socket_inet_ntop(PyObject *self, PyObject *args)
                PyErr_SetFromErrno(socket_error);
                return NULL;
        } else {
-               return PyBytes_FromString(retval);
+               return PyString_FromString(retval);
        }
 
        /* NOTREACHED */
@@ -3944,9 +3944,9 @@ socket_getaddrinfo(PyObject *self, PyObject *args)
                idna = PyObject_CallMethod(hobj, "encode", "s", "idna");
                if (!idna)
                        return NULL;
-               hptr = PyBytes_AsString(idna);
-       } else if (PyBytes_Check(hobj)) {
-               hptr = PyBytes_AsString(hobj);
+               hptr = PyString_AsString(idna);
+       } else if (PyString_Check(hobj)) {
+               hptr = PyString_AsString(hobj);
        } else {
                PyErr_SetString(PyExc_TypeError,
                                "getaddrinfo() argument 1 must be string or None");
@@ -3955,8 +3955,8 @@ socket_getaddrinfo(PyObject *self, PyObject *args)
        if (PyInt_Check(pobj)) {
                PyOS_snprintf(pbuf, sizeof(pbuf), "%ld", PyInt_AsLong(pobj));
                pptr = pbuf;
-       } else if (PyBytes_Check(pobj)) {
-               pptr = PyBytes_AsString(pobj);
+       } else if (PyString_Check(pobj)) {
+               pptr = PyString_AsString(pobj);
        } else if (pobj == Py_None) {
                pptr = (char *)NULL;
        } else {
index 221223ec2558d6b2aacdbb14779a41c74074fa2a..d3f309afa8fbad399e270dca23d8f053508d449a 100644 (file)
@@ -60,7 +60,7 @@ static void
 sets(PyObject *v, int i, char* val)
 {
   if (val)
-         PyStructSequence_SET_ITEM(v, i, PyBytes_FromString(val));
+         PyStructSequence_SET_ITEM(v, i, PyString_FromString(val));
   else {
          PyStructSequence_SET_ITEM(v, i, Py_None);
          Py_INCREF(Py_None);
index e0e5ad0d6faf6aee61d4c710fc45fbd262dbfba5..8b00fed69a8434da5f5495a45bbadae6f8554b68 100644 (file)
@@ -47,7 +47,7 @@ split_whitespace(char *s, Py_ssize_t len, Py_ssize_t maxsplit)
                        i = i+1;
                }
                if (j < i) {
-                       item = PyBytes_FromStringAndSize(s+j, i-j);
+                       item = PyString_FromStringAndSize(s+j, i-j);
                        if (item == NULL)
                                goto finally;
 
@@ -61,7 +61,7 @@ split_whitespace(char *s, Py_ssize_t len, Py_ssize_t maxsplit)
                                i = i+1;
                        }
                        if (maxsplit && (countsplit >= maxsplit) && i < len) {
-                               item = PyBytes_FromStringAndSize(
+                               item = PyString_FromStringAndSize(
                                         s+i, len - i);
                                if (item == NULL)
                                        goto finally;
@@ -122,7 +122,7 @@ strop_splitfields(PyObject *self, PyObject *args)
        i = j = 0;
        while (i+n <= len) {
                if (s[i] == sub[0] && (n == 1 || memcmp(s+i, sub, n) == 0)) {
-                       item = PyBytes_FromStringAndSize(s+j, i-j);
+                       item = PyString_FromStringAndSize(s+j, i-j);
                        if (item == NULL)
                                goto fail;
                        err = PyList_Append(list, item);
@@ -137,7 +137,7 @@ strop_splitfields(PyObject *self, PyObject *args)
                else
                        i++;
        }
-       item = PyBytes_FromStringAndSize(s+j, len-j);
+       item = PyString_FromStringAndSize(s+j, len-j);
        if (item == NULL)
                goto fail;
        err = PyList_Append(list, item);
@@ -189,7 +189,7 @@ strop_joinfields(PyObject *self, PyObject *args)
        if (seqlen == 1) {
                /* Optimization if there's only one item */
                PyObject *item = PySequence_GetItem(seq, 0);
-               if (item && !PyBytes_Check(item)) {
+               if (item && !PyString_Check(item)) {
                        PyErr_SetString(PyExc_TypeError,
                                 "first argument must be sequence of strings");
                        Py_DECREF(item);
@@ -198,9 +198,9 @@ strop_joinfields(PyObject *self, PyObject *args)
                return item;
        }
 
-       if (!(res = PyBytes_FromStringAndSize((char*)NULL, sz)))
+       if (!(res = PyString_FromStringAndSize((char*)NULL, sz)))
                return NULL;
-       p = PyBytes_AsString(res);
+       p = PyString_AsString(res);
 
        /* optimize for lists, since it's the most common case.  all others
         * (tuples and arbitrary sequences) just use the sequence abstract
@@ -209,29 +209,29 @@ strop_joinfields(PyObject *self, PyObject *args)
        if (PyList_Check(seq)) {
                for (i = 0; i < seqlen; i++) {
                        PyObject *item = PyList_GET_ITEM(seq, i);
-                       if (!PyBytes_Check(item)) {
+                       if (!PyString_Check(item)) {
                                PyErr_SetString(PyExc_TypeError,
                                "first argument must be sequence of strings");
                                Py_DECREF(res);
                                return NULL;
                        }
-                       slen = PyBytes_GET_SIZE(item);
+                       slen = PyString_GET_SIZE(item);
                        while (reslen + slen + seplen >= sz) {
-                               if (_PyBytes_Resize(&res, sz * 2) < 0)
+                               if (_PyString_Resize(&res, sz * 2) < 0)
                                        return NULL;
                                sz *= 2;
-                               p = PyBytes_AsString(res) + reslen;
+                               p = PyString_AsString(res) + reslen;
                        }
                        if (i > 0) {
                                memcpy(p, sep, seplen);
                                p += seplen;
                                reslen += seplen;
                        }
-                       memcpy(p, PyBytes_AS_STRING(item), slen);
+                       memcpy(p, PyString_AS_STRING(item), slen);
                        p += slen;
                        reslen += slen;
                }
-               _PyBytes_Resize(&res, reslen);
+               _PyString_Resize(&res, reslen);
                return res;
        }
 
@@ -245,33 +245,33 @@ strop_joinfields(PyObject *self, PyObject *args)
        /* This is now type safe */
        for (i = 0; i < seqlen; i++) {
                PyObject *item = getitemfunc(seq, i);
-               if (!item || !PyBytes_Check(item)) {
+               if (!item || !PyString_Check(item)) {
                        PyErr_SetString(PyExc_TypeError,
                                 "first argument must be sequence of strings");
                        Py_DECREF(res);
                        Py_XDECREF(item);
                        return NULL;
                }
-               slen = PyBytes_GET_SIZE(item);
+               slen = PyString_GET_SIZE(item);
                while (reslen + slen + seplen >= sz) {
-                       if (_PyBytes_Resize(&res, sz * 2) < 0) {
+                       if (_PyString_Resize(&res, sz * 2) < 0) {
                                Py_DECREF(item);
                                return NULL;
                        }
                        sz *= 2;
-                       p = PyBytes_AsString(res) + reslen;
+                       p = PyString_AsString(res) + reslen;
                }
                if (i > 0) {
                        memcpy(p, sep, seplen);
                        p += seplen;
                        reslen += seplen;
                }
-               memcpy(p, PyBytes_AS_STRING(item), slen);
+               memcpy(p, PyString_AS_STRING(item), slen);
                p += slen;
                reslen += slen;
                Py_DECREF(item);
        }
-       _PyBytes_Resize(&res, reslen);
+       _PyString_Resize(&res, reslen);
        return res;
 }
 
@@ -369,7 +369,7 @@ do_strip(PyObject *args, int striptype)
        Py_ssize_t len, i, j;
 
 
-       if (PyBytes_AsStringAndSize(args, &s, &len))
+       if (PyString_AsStringAndSize(args, &s, &len))
                return NULL;
 
        i = 0;
@@ -392,7 +392,7 @@ do_strip(PyObject *args, int striptype)
                return args;
        }
        else
-               return PyBytes_FromStringAndSize(s+i, j-i);
+               return PyString_FromStringAndSize(s+i, j-i);
 }
 
 
@@ -450,12 +450,12 @@ strop_lower(PyObject *self, PyObject *args)
        int changed;
 
        WARN;
-       if (PyBytes_AsStringAndSize(args, &s, &n))
+       if (PyString_AsStringAndSize(args, &s, &n))
                return NULL;
-       newstr = PyBytes_FromStringAndSize(NULL, n);
+       newstr = PyString_FromStringAndSize(NULL, n);
        if (newstr == NULL)
                return NULL;
-       s_new = PyBytes_AsString(newstr);
+       s_new = PyString_AsString(newstr);
        changed = 0;
        for (i = 0; i < n; i++) {
                int c = Py_CHARMASK(*s++);
@@ -489,12 +489,12 @@ strop_upper(PyObject *self, PyObject *args)
        int changed;
 
        WARN;
-       if (PyBytes_AsStringAndSize(args, &s, &n))
+       if (PyString_AsStringAndSize(args, &s, &n))
                return NULL;
-       newstr = PyBytes_FromStringAndSize(NULL, n);
+       newstr = PyString_FromStringAndSize(NULL, n);
        if (newstr == NULL)
                return NULL;
-       s_new = PyBytes_AsString(newstr);
+       s_new = PyString_AsString(newstr);
        changed = 0;
        for (i = 0; i < n; i++) {
                int c = Py_CHARMASK(*s++);
@@ -529,12 +529,12 @@ strop_capitalize(PyObject *self, PyObject *args)
        int changed;
 
        WARN;
-       if (PyBytes_AsStringAndSize(args, &s, &n))
+       if (PyString_AsStringAndSize(args, &s, &n))
                return NULL;
-       newstr = PyBytes_FromStringAndSize(NULL, n);
+       newstr = PyString_FromStringAndSize(NULL, n);
        if (newstr == NULL)
                return NULL;
-       s_new = PyBytes_AsString(newstr);
+       s_new = PyString_AsString(newstr);
        changed = 0;
        if (0 < n) {
                int c = Py_CHARMASK(*s++);
@@ -610,12 +610,12 @@ strop_expandtabs(PyObject *self, PyObject *args)
        }
 
        /* Second pass: create output string and fill it */
-       out = PyBytes_FromStringAndSize(NULL, i+j);
+       out = PyString_FromStringAndSize(NULL, i+j);
        if (out == NULL)
                return NULL;
 
        i = 0;
-       q = PyBytes_AS_STRING(out);
+       q = PyString_AS_STRING(out);
 
        for (p = string; p < e; p++) {
                if (*p == '\t') {
@@ -695,12 +695,12 @@ strop_swapcase(PyObject *self, PyObject *args)
        int changed;
 
        WARN;
-       if (PyBytes_AsStringAndSize(args, &s, &n))
+       if (PyString_AsStringAndSize(args, &s, &n))
                return NULL;
-       newstr = PyBytes_FromStringAndSize(NULL, n);
+       newstr = PyString_FromStringAndSize(NULL, n);
        if (newstr == NULL)
                return NULL;
-       s_new = PyBytes_AsString(newstr);
+       s_new = PyString_AsString(newstr);
        changed = 0;
        for (i = 0; i < n; i++) {
                int c = Py_CHARMASK(*s++);
@@ -898,10 +898,10 @@ strop_maketrans(PyObject *self, PyObject *args)
                return NULL;
        }
 
-       result = PyBytes_FromStringAndSize((char *)NULL, 256);
+       result = PyString_FromStringAndSize((char *)NULL, 256);
        if (result == NULL)
                return NULL;
-       c = (unsigned char *) PyBytes_AS_STRING((PyBytesObject *)result);
+       c = (unsigned char *) PyString_AS_STRING((PyStringObject *)result);
        for (i = 0; i < 256; i++)
                c[i]=(unsigned char)i;
        for (i = 0; i < fromlen; i++)
@@ -942,12 +942,12 @@ strop_translate(PyObject *self, PyObject *args)
        }
 
        table = table1;
-       inlen = PyBytes_GET_SIZE(input_obj);
-       result = PyBytes_FromStringAndSize((char *)NULL, inlen);
+       inlen = PyString_GET_SIZE(input_obj);
+       result = PyString_FromStringAndSize((char *)NULL, inlen);
        if (result == NULL)
                return NULL;
-       output_start = output = PyBytes_AsString(result);
-       input = PyBytes_AsString(input_obj);
+       output_start = output = PyString_AsString(result);
+       input = PyString_AsString(input_obj);
 
        if (dellen == 0) {
                /* If no deletions are required, use faster code */
@@ -983,7 +983,7 @@ strop_translate(PyObject *self, PyObject *args)
        }
        /* Fix the size of the resulting string */
        if (inlen > 0)
-               _PyBytes_Resize(&result, output - output_start);
+               _PyString_Resize(&result, output - output_start);
        return result;
 }
 
@@ -1169,7 +1169,7 @@ strop_replace(PyObject *self, PyObject *args)
                Py_XINCREF(newstr);
        }
        else {
-               newstr = PyBytes_FromStringAndSize(new_s, out_len);
+               newstr = PyString_FromStringAndSize(new_s, out_len);
                PyMem_FREE(new_s);
        }
        return newstr;
@@ -1222,7 +1222,7 @@ initstrop(void)
                if (isspace(c))
                        buf[n++] = c;
        }
-       s = PyBytes_FromStringAndSize(buf, n);
+       s = PyString_FromStringAndSize(buf, n);
        if (s)
                PyModule_AddObject(m, "whitespace", s);
 
@@ -1232,7 +1232,7 @@ initstrop(void)
                if (islower(c))
                        buf[n++] = c;
        }
-       s = PyBytes_FromStringAndSize(buf, n);
+       s = PyString_FromStringAndSize(buf, n);
        if (s)
                PyModule_AddObject(m, "lowercase", s);
 
@@ -1242,7 +1242,7 @@ initstrop(void)
                if (isupper(c))
                        buf[n++] = c;
        }
-       s = PyBytes_FromStringAndSize(buf, n);
+       s = PyString_FromStringAndSize(buf, n);
        if (s)
                PyModule_AddObject(m, "uppercase", s);
 }
index f4b430e2070c6140dd44c0a9cfbc2344664e1161..285dc66ddda6a2f63089b00874bec033b9a3305a 100644 (file)
@@ -135,11 +135,11 @@ sad_read(sadobject *self, PyObject *args)
        
         if (!PyArg_ParseTuple(args, "i:read", &size))
                return NULL;
-       rv = PyBytes_FromStringAndSize(NULL, size);
+       rv = PyString_FromStringAndSize(NULL, size);
        if (rv == NULL)
                return NULL;
 
-       if (!(cp = PyBytes_AsString(rv)))
+       if (!(cp = PyString_AsString(rv)))
                goto finally;
 
        count = read(self->x_fd, cp, size);
index 485259fa7ea194fa0bfc3320ce893f0020ace725..3845e20f6276f37c3ae921c6ffc9e09ec829517d 100644 (file)
@@ -47,13 +47,13 @@ svc_conversion(captureobject *self, PyObject *args, void (*function)(),     float fa
        if (!PyArg_Parse(args, "i", &invert))
                return NULL;
 
-       if (!(output = PyBytes_FromStringAndSize(
+       if (!(output = PyString_FromStringAndSize(
                NULL,
                (int)(self->ob_info.width * self->ob_info.height * factor))))
        {
                return NULL;
        }
-       if (!(outstr = PyBytes_AsString(output))) {
+       if (!(outstr = PyString_AsString(output))) {
                Py_DECREF(output);
                return NULL;
        }
@@ -152,9 +152,9 @@ svc_GetFields(captureobject *self, PyObject *args)
        fieldsize = self->ob_info.width * self->ob_info.height / 2;
        obcapture = (char*)self->ob_capture;
        
-       if (!(f1 = PyBytes_FromStringAndSize(obcapture, fieldsize)))
+       if (!(f1 = PyString_FromStringAndSize(obcapture, fieldsize)))
                goto finally;
-       if (!(f2 = PyBytes_FromStringAndSize(obcapture + fieldsize,
+       if (!(f2 = PyString_FromStringAndSize(obcapture + fieldsize,
                                              fieldsize)))
                goto finally;
        ret = PyTuple_Pack(2, f1, f2);
@@ -535,12 +535,12 @@ sv_CaptureBurst(svobject *self, PyObject *args)
                goto finally;
        }
 
-       if (!(videodata = PyBytes_FromStringAndSize(NULL, bytes)))
+       if (!(videodata = PyString_FromStringAndSize(NULL, bytes)))
                goto finally;
 
        /* XXX -- need to do something about the bitvector */
        {
-               char* str = PyBytes_AsString(videodata);
+               char* str = PyString_AsString(videodata);
                if (!str)
                        goto finally;
                
@@ -615,10 +615,10 @@ sv_CaptureOneFrame(svobject *self, PyObject *args)
        if (svQueryCaptureBufferSize(self->ob_svideo, &info, &bytes))
                return sv_error();
 
-       if (!(videodata = PyBytes_FromStringAndSize(NULL, bytes)))
+       if (!(videodata = PyString_FromStringAndSize(NULL, bytes)))
                return NULL;
        
-       str = PyBytes_AsString(videodata);
+       str = PyString_AsString(videodata);
        if (!str)
                goto finally;
 
@@ -849,11 +849,11 @@ sv_conversion(PyObject *self, PyObject *args, void (*function)(),
                return NULL;
        }
 
-       if (!(output = PyBytes_FromStringAndSize(NULL,
+       if (!(output = PyString_FromStringAndSize(NULL,
                                              (int)(width * height * factor))))
                return NULL;
 
-       str = PyBytes_AsString(output);
+       str = PyString_AsString(output);
        if (!str) {
                Py_DECREF(output);
                return NULL;
index a515a178b0bc62b7ada6f773eac903bf69beb0c3..9e1ed0619f1ff7b3fd55c2ce04b937bc12a6d528 100644 (file)
@@ -71,7 +71,7 @@ syslog_openlog(PyObject * self, PyObject * args)
        S_ident_o = new_S_ident_o;
        Py_INCREF(S_ident_o);
 
-       openlog(PyBytes_AsString(S_ident_o), logopt, facility);
+       openlog(PyString_AsString(S_ident_o), logopt, facility);
 
        Py_INCREF(Py_None);
        return Py_None;
index c6d05cef8b5daca1a49b4399899955b01ae0b7bc..c53566c12b70524941dea6ec1fe7a145c7703573 100644 (file)
@@ -91,7 +91,7 @@ termios_tcgetattr(PyObject *self, PyObject *args)
                return NULL;
        for (i = 0; i < NCCS; i++) {
                ch = (char)mode.c_cc[i];
-               v = PyBytes_FromStringAndSize(&ch, 1);
+               v = PyString_FromStringAndSize(&ch, 1);
                if (v == NULL)
                        goto err;
                PyList_SetItem(cc, i, v);
@@ -183,8 +183,8 @@ termios_tcsetattr(PyObject *self, PyObject *args)
        for (i = 0; i < NCCS; i++) {
                v = PyList_GetItem(cc, i);
 
-               if (PyBytes_Check(v) && PyBytes_Size(v) == 1)
-                       mode.c_cc[i] = (cc_t) * PyBytes_AsString(v);
+               if (PyString_Check(v) && PyString_Size(v) == 1)
+                       mode.c_cc[i] = (cc_t) * PyString_AsString(v);
                else if (PyInt_Check(v))
                        mode.c_cc[i] = (cc_t) PyInt_AsLong(v);
                else {
index 7b52f727e2f91d1f4b0617451e63c078fcea5972..81bf2882047bee2c6756422f3b19ef38e8a43fa8 100644 (file)
@@ -190,7 +190,7 @@ local_new(PyTypeObject *type, PyObject *args, PyObject *kw)
        Py_XINCREF(kw);
        self->kw = kw;
        self->dict = NULL;      /* making sure */
-       self->key = PyBytes_FromFormat("thread.local.%p", self);
+       self->key = PyString_FromFormat("thread.local.%p", self);
        if (self->key == NULL) 
                goto err;
 
index 92c47cb603e21b511ff590de56a76ca5fa212565..c6f68f8e234e15f7425be20a426461ea1a36ad66 100644 (file)
@@ -488,7 +488,7 @@ time_strftime(PyObject *self, PyObject *args)
                           e.g. an empty format, or %Z when the timezone
                           is unknown. */
                        PyObject *ret;
-                       ret = PyBytes_FromStringAndSize(outbuf, buflen);
+                       ret = PyString_FromStringAndSize(outbuf, buflen);
                        free(outbuf);
                        return ret;
                }
@@ -548,7 +548,7 @@ time_asctime(PyObject *self, PyObject *args)
        p = asctime(&buf);
        if (p[24] == '\n')
                p[24] = '\0';
-       return PyBytes_FromString(p);
+       return PyString_FromString(p);
 }
 
 PyDoc_STRVAR(asctime_doc,
@@ -584,7 +584,7 @@ time_ctime(PyObject *self, PyObject *args)
        }
        if (p[24] == '\n')
                p[24] = '\0';
-       return PyBytes_FromString(p);
+       return PyString_FromString(p);
 }
 
 PyDoc_STRVAR(ctime_doc,
index 8ce280f16b753ff11c04dfdd61559c89b0196a53..abb391a0a1b6273ca5737d40c69767fa352b3ace 100644 (file)
@@ -266,7 +266,7 @@ unicodedata_category(PyObject *self, PyObject *args)
         if (old->category_changed != 0xFF)
             index = old->category_changed;
     }
-    return PyBytes_FromString(_PyUnicode_CategoryNames[index]);
+    return PyString_FromString(_PyUnicode_CategoryNames[index]);
 }
 
 PyDoc_STRVAR(unicodedata_bidirectional__doc__,
@@ -297,7 +297,7 @@ unicodedata_bidirectional(PyObject *self, PyObject *args)
         else if (old->bidir_changed != 0xFF)
             index = old->bidir_changed;
     }
-    return PyBytes_FromString(_PyUnicode_BidirectionalNames[index]);
+    return PyString_FromString(_PyUnicode_BidirectionalNames[index]);
 }
 
 PyDoc_STRVAR(unicodedata_combining__doc__,
@@ -383,7 +383,7 @@ unicodedata_east_asian_width(PyObject *self, PyObject *args)
         if (old->category_changed == 0)
             index = 0; /* unassigned */
     }
-    return PyBytes_FromString(_PyUnicode_EastAsianWidthNames[index]);
+    return PyString_FromString(_PyUnicode_EastAsianWidthNames[index]);
 }
 
 PyDoc_STRVAR(unicodedata_decomposition__doc__,
@@ -414,7 +414,7 @@ unicodedata_decomposition(PyObject *self, PyObject *args)
     if (self) {
         const change_record *old = get_old_record(self, c);
         if (old->category_changed == 0)
-            return PyBytes_FromString(""); /* unassigned */
+            return PyString_FromString(""); /* unassigned */
     }
 
     if (code < 0 || code >= 0x110000)
@@ -453,7 +453,7 @@ unicodedata_decomposition(PyObject *self, PyObject *args)
     
     decomp[i] = '\0';
 
-    return PyBytes_FromString(decomp);
+    return PyString_FromString(decomp);
 }
 
 static void
@@ -518,7 +518,7 @@ nfd_nfkd(PyObject *self, PyObject *input, int k)
             /* Hangul Decomposition adds three characters in
                a single step, so we need atleast that much room. */
             if (space < 3) {
-                Py_ssize_t newsize = PyBytes_GET_SIZE(result) + 10;
+                Py_ssize_t newsize = PyString_GET_SIZE(result) + 10;
                 space += 10;
                 if (PyUnicode_Resize(&result, newsize) == -1)
                     return NULL;
index bd1348798f4b11c3f8e78028f448c2d8cf0d7d4b..d3cd4ad61a753b532f7c4a8b263de84c09e3e0cd 100644 (file)
@@ -154,11 +154,11 @@ zipimporter_init(ZipImporter *self, PyObject *args, PyObject *kwds)
                }
        }
 
-       self->archive = PyBytes_FromString(buf);
+       self->archive = PyString_FromString(buf);
        if (self->archive == NULL)
                return -1;
 
-       self->prefix = PyBytes_FromString(prefix);
+       self->prefix = PyString_FromString(prefix);
        if (self->prefix == NULL)
                return -1;
 
@@ -191,10 +191,10 @@ zipimporter_repr(ZipImporter *self)
        char *archive = "???";
        char *prefix = "";
 
-       if (self->archive != NULL && PyBytes_Check(self->archive))
-               archive = PyBytes_AsString(self->archive);
-       if (self->prefix != NULL && PyBytes_Check(self->prefix))
-               prefix = PyBytes_AsString(self->prefix);
+       if (self->archive != NULL && PyString_Check(self->archive))
+               archive = PyString_AsString(self->archive);
+       if (self->prefix != NULL && PyString_Check(self->prefix))
+               prefix = PyString_AsString(self->prefix);
        if (prefix != NULL && *prefix)
                PyOS_snprintf(buf, sizeof(buf),
                              "<zipimporter object \"%.300s%c%.150s\">",
@@ -203,7 +203,7 @@ zipimporter_repr(ZipImporter *self)
                PyOS_snprintf(buf, sizeof(buf),
                              "<zipimporter object \"%.300s\">",
                              archive);
-       return PyBytes_FromString(buf);
+       return PyString_FromString(buf);
 }
 
 /* return fullname.split(".")[-1] */
@@ -263,7 +263,7 @@ get_module_info(ZipImporter *self, char *fullname)
 
        subname = get_subname(fullname);
 
-       len = make_filename(PyBytes_AsString(self->prefix), subname, path);
+       len = make_filename(PyString_AsString(self->prefix), subname, path);
        if (len < 0)
                return MI_ERROR;
 
@@ -336,12 +336,12 @@ zipimporter_load_module(PyObject *obj, PyObject *args)
                /* add __path__ to the module *before* the code gets
                   executed */
                PyObject *pkgpath, *fullpath;
-               char *prefix = PyBytes_AsString(self->prefix);
+               char *prefix = PyString_AsString(self->prefix);
                char *subname = get_subname(fullname);
                int err;
 
-               fullpath = PyBytes_FromFormat("%s%c%s%s",
-                                       PyBytes_AsString(self->archive),
+               fullpath = PyString_FromFormat("%s%c%s%s",
+                                       PyString_AsString(self->archive),
                                        SEP,
                                        *prefix ? prefix : "",
                                        subname);
@@ -418,9 +418,9 @@ zipimporter_get_data(PyObject *obj, PyObject *args)
        }
        path = buf;
 #endif
-       len = PyBytes_Size(self->archive);
+       len = PyString_Size(self->archive);
        if ((size_t)len < strlen(path) &&
-           strncmp(path, PyBytes_AsString(self->archive), len) == 0 &&
+           strncmp(path, PyString_AsString(self->archive), len) == 0 &&
            path[len] == SEP) {
                path = path + len + 1;
        }
@@ -430,7 +430,7 @@ zipimporter_get_data(PyObject *obj, PyObject *args)
                PyErr_SetFromErrnoWithFilename(PyExc_IOError, path);
                return NULL;
        }
-       return get_data(PyBytes_AsString(self->archive), toc_entry);
+       return get_data(PyString_AsString(self->archive), toc_entry);
 }
 
 static PyObject *
@@ -467,7 +467,7 @@ zipimporter_get_source(PyObject *obj, PyObject *args)
        }
        subname = get_subname(fullname);
 
-       len = make_filename(PyBytes_AsString(self->prefix), subname, path);
+       len = make_filename(PyString_AsString(self->prefix), subname, path);
        if (len < 0)
                return NULL;
 
@@ -480,7 +480,7 @@ zipimporter_get_source(PyObject *obj, PyObject *args)
 
        toc_entry = PyDict_GetItemString(self->files, path);
        if (toc_entry != NULL)
-               return get_data(PyBytes_AsString(self->archive), toc_entry);
+               return get_data(PyString_AsString(self->archive), toc_entry);
 
        /* we have the module, but no source */
        Py_INCREF(Py_None);
@@ -843,13 +843,13 @@ get_data(char *archive, PyObject *toc_entry)
            PyMarshal_ReadShortFromFile(fp);    /* local header size */
        file_offset += l;       /* Start of file data */
 
-       raw_data = PyBytes_FromStringAndSize((char *)NULL, compress == 0 ?
+       raw_data = PyString_FromStringAndSize((char *)NULL, compress == 0 ?
                                              data_size : data_size + 1);
        if (raw_data == NULL) {
                fclose(fp);
                return NULL;
        }
-       buf = PyBytes_AsString(raw_data);
+       buf = PyString_AsString(raw_data);
 
        err = fseek(fp, file_offset, 0);
        if (err == 0)
@@ -907,8 +907,8 @@ static PyObject *
 unmarshal_code(char *pathname, PyObject *data, time_t mtime)
 {
        PyObject *code;
-       char *buf = PyBytes_AsString(data);
-       Py_ssize_t size = PyBytes_Size(data);
+       char *buf = PyString_AsString(data);
+       Py_ssize_t size = PyString_Size(data);
 
        if (size <= 9) {
                PyErr_SetString(ZipImportError,
@@ -953,14 +953,14 @@ unmarshal_code(char *pathname, PyObject *data, time_t mtime)
 static PyObject *
 normalize_line_endings(PyObject *source)
 {
-       char *buf, *q, *p = PyBytes_AsString(source);
+       char *buf, *q, *p = PyString_AsString(source);
        PyObject *fixed_source;
 
        if (!p)
                return NULL;
 
        /* one char extra for trailing \n and one for terminating \0 */
-       buf = (char *)PyMem_Malloc(PyBytes_Size(source) + 2);
+       buf = (char *)PyMem_Malloc(PyString_Size(source) + 2);
        if (buf == NULL) {
                PyErr_SetString(PyExc_MemoryError,
                                "zipimport: no memory to allocate "
@@ -979,7 +979,7 @@ normalize_line_endings(PyObject *source)
        }
        *q++ = '\n';  /* add trailing \n */
        *q = '\0';
-       fixed_source = PyBytes_FromString(buf);
+       fixed_source = PyString_FromString(buf);
        PyMem_Free(buf);
        return fixed_source;
 }
@@ -995,7 +995,7 @@ compile_source(char *pathname, PyObject *source)
        if (fixed_source == NULL)
                return NULL;
 
-       code = Py_CompileString(PyBytes_AsString(fixed_source), pathname,
+       code = Py_CompileString(PyString_AsString(fixed_source), pathname,
                                Py_file_input);
        Py_DECREF(fixed_source);
        return code;
@@ -1054,7 +1054,7 @@ get_code_from_data(ZipImporter *self, int ispackage, int isbytecode,
 {
        PyObject *data, *code;
        char *modpath;
-       char *archive = PyBytes_AsString(self->archive);
+       char *archive = PyString_AsString(self->archive);
 
        if (archive == NULL)
                return NULL;
@@ -1063,7 +1063,7 @@ get_code_from_data(ZipImporter *self, int ispackage, int isbytecode,
        if (data == NULL)
                return NULL;
 
-       modpath = PyBytes_AsString(PyTuple_GetItem(toc_entry, 0));
+       modpath = PyString_AsString(PyTuple_GetItem(toc_entry, 0));
 
        if (isbytecode) {
                code = unmarshal_code(modpath, data, mtime);
@@ -1088,7 +1088,7 @@ get_module_code(ZipImporter *self, char *fullname,
 
        subname = get_subname(fullname);
 
-       len = make_filename(PyBytes_AsString(self->prefix), subname, path);
+       len = make_filename(PyString_AsString(self->prefix), subname, path);
        if (len < 0)
                return NULL;
 
@@ -1098,7 +1098,7 @@ get_module_code(ZipImporter *self, char *fullname,
                strcpy(path + len, zso->suffix);
                if (Py_VerboseFlag > 1)
                        PySys_WriteStderr("# trying %s%c%s\n",
-                                         PyBytes_AsString(self->archive),
+                                         PyString_AsString(self->archive),
                                          SEP, path);
                toc_entry = PyDict_GetItemString(self->files, path);
                if (toc_entry != NULL) {
@@ -1120,7 +1120,7 @@ get_module_code(ZipImporter *self, char *fullname,
                                continue;
                        }
                        if (code != NULL && p_modpath != NULL)
-                               *p_modpath = PyBytes_AsString(
+                               *p_modpath = PyString_AsString(
                                        PyTuple_GetItem(toc_entry, 0));
                        return code;
                }
index 590ab5fb555f8ef254b86e2e80cdc5c202ac63ea..4f78dbcb15dabaf2952bee247abfc9d3127558f1 100644 (file)
@@ -96,12 +96,12 @@ newcompobject(PyTypeObject *type)
     if (self == NULL)
        return NULL;
     self->is_initialised = 0;
-    self->unused_data = PyBytes_FromString("");
+    self->unused_data = PyString_FromString("");
     if (self->unused_data == NULL) {
        Py_DECREF(self);
        return NULL;
     }
-    self->unconsumed_tail = PyBytes_FromString("");
+    self->unconsumed_tail = PyString_FromString("");
     if (self->unconsumed_tail == NULL) {
        Py_DECREF(self);
        return NULL;
@@ -174,7 +174,7 @@ PyZlib_compress(PyObject *self, PyObject *args)
 
     err=deflateEnd(&zst);
     if (err == Z_OK)
-       ReturnVal = PyBytes_FromStringAndSize((char *)output,
+       ReturnVal = PyString_FromStringAndSize((char *)output,
                                               zst.total_out);
     else
        zlib_error(zst, err, "while finishing compression");
@@ -211,12 +211,12 @@ PyZlib_decompress(PyObject *self, PyObject *args)
     zst.avail_in = length;
     zst.avail_out = r_strlen;
 
-    if (!(result_str = PyBytes_FromStringAndSize(NULL, r_strlen)))
+    if (!(result_str = PyString_FromStringAndSize(NULL, r_strlen)))
        return NULL;
 
     zst.zalloc = (alloc_func)NULL;
     zst.zfree = (free_func)Z_NULL;
-    zst.next_out = (Byte *)PyBytes_AS_STRING(result_str);
+    zst.next_out = (Byte *)PyString_AS_STRING(result_str);
     zst.next_in = (Byte *)input;
     err = inflateInit2(&zst, wsize);
 
@@ -256,11 +256,11 @@ PyZlib_decompress(PyObject *self, PyObject *args)
            /* fall through */
        case(Z_OK):
            /* need more memory */
-           if (_PyBytes_Resize(&result_str, r_strlen << 1) < 0) {
+           if (_PyString_Resize(&result_str, r_strlen << 1) < 0) {
                inflateEnd(&zst);
                goto error;
            }
-           zst.next_out = (unsigned char *)PyBytes_AS_STRING(result_str) \
+           zst.next_out = (unsigned char *)PyString_AS_STRING(result_str) \
                + r_strlen;
            zst.avail_out = r_strlen;
            r_strlen = r_strlen << 1;
@@ -278,7 +278,7 @@ PyZlib_decompress(PyObject *self, PyObject *args)
        goto error;
     }
 
-    _PyBytes_Resize(&result_str, zst.total_out);
+    _PyString_Resize(&result_str, zst.total_out);
     return result_str;
 
  error:
@@ -400,7 +400,7 @@ PyZlib_objcompress(compobject *self, PyObject *args)
     if (!PyArg_ParseTuple(args, "s#:compress", &input, &inplen))
        return NULL;
 
-    if (!(RetVal = PyBytes_FromStringAndSize(NULL, length)))
+    if (!(RetVal = PyString_FromStringAndSize(NULL, length)))
        return NULL;
 
     ENTER_ZLIB
@@ -409,7 +409,7 @@ PyZlib_objcompress(compobject *self, PyObject *args)
     self->zst.avail_in = inplen;
     self->zst.next_in = input;
     self->zst.avail_out = length;
-    self->zst.next_out = (unsigned char *)PyBytes_AS_STRING(RetVal);
+    self->zst.next_out = (unsigned char *)PyString_AS_STRING(RetVal);
 
     Py_BEGIN_ALLOW_THREADS
     err = deflate(&(self->zst), Z_NO_FLUSH);
@@ -418,9 +418,9 @@ PyZlib_objcompress(compobject *self, PyObject *args)
     /* while Z_OK and the output buffer is full, there might be more output,
        so extend the output buffer and try again */
     while (err == Z_OK && self->zst.avail_out == 0) {
-       if (_PyBytes_Resize(&RetVal, length << 1) < 0)
+       if (_PyString_Resize(&RetVal, length << 1) < 0)
            goto error;
-       self->zst.next_out = (unsigned char *)PyBytes_AS_STRING(RetVal) \
+       self->zst.next_out = (unsigned char *)PyString_AS_STRING(RetVal) \
            + length;
        self->zst.avail_out = length;
        length = length << 1;
@@ -440,7 +440,7 @@ PyZlib_objcompress(compobject *self, PyObject *args)
        RetVal = NULL;
        goto error;
     }
-    _PyBytes_Resize(&RetVal, self->zst.total_out - start_total_out);
+    _PyString_Resize(&RetVal, self->zst.total_out - start_total_out);
 
  error:
     LEAVE_ZLIB
@@ -479,7 +479,7 @@ PyZlib_objdecompress(compobject *self, PyObject *args)
     /* limit amount of data allocated to max_length */
     if (max_length && length > max_length)
        length = max_length;
-    if (!(RetVal = PyBytes_FromStringAndSize(NULL, length)))
+    if (!(RetVal = PyString_FromStringAndSize(NULL, length)))
        return NULL;
 
     ENTER_ZLIB
@@ -488,7 +488,7 @@ PyZlib_objdecompress(compobject *self, PyObject *args)
     self->zst.avail_in = inplen;
     self->zst.next_in = input;
     self->zst.avail_out = length;
-    self->zst.next_out = (unsigned char *)PyBytes_AS_STRING(RetVal);
+    self->zst.next_out = (unsigned char *)PyString_AS_STRING(RetVal);
 
     Py_BEGIN_ALLOW_THREADS
     err = inflate(&(self->zst), Z_SYNC_FLUSH);
@@ -510,9 +510,9 @@ PyZlib_objdecompress(compobject *self, PyObject *args)
        if (max_length && length > max_length)
            length = max_length;
 
-       if (_PyBytes_Resize(&RetVal, length) < 0)
+       if (_PyString_Resize(&RetVal, length) < 0)
            goto error;
-       self->zst.next_out = (unsigned char *)PyBytes_AS_STRING(RetVal) \
+       self->zst.next_out = (unsigned char *)PyString_AS_STRING(RetVal) \
            + old_length;
        self->zst.avail_out = length - old_length;
 
@@ -525,7 +525,7 @@ PyZlib_objdecompress(compobject *self, PyObject *args)
        of specified size. Return the unconsumed tail in an attribute.*/
     if(max_length) {
        Py_DECREF(self->unconsumed_tail);
-       self->unconsumed_tail = PyBytes_FromStringAndSize((char *)self->zst.next_in,
+       self->unconsumed_tail = PyString_FromStringAndSize((char *)self->zst.next_in,
                                                           self->zst.avail_in);
        if(!self->unconsumed_tail) {
            Py_DECREF(RetVal);
@@ -542,7 +542,7 @@ PyZlib_objdecompress(compobject *self, PyObject *args)
     */
     if (err == Z_STREAM_END) {
        Py_XDECREF(self->unused_data);  /* Free original empty string */
-       self->unused_data = PyBytes_FromStringAndSize(
+       self->unused_data = PyString_FromStringAndSize(
            (char *)self->zst.next_in, self->zst.avail_in);
        if (self->unused_data == NULL) {
            Py_DECREF(RetVal);
@@ -559,7 +559,7 @@ PyZlib_objdecompress(compobject *self, PyObject *args)
        goto error;
     }
 
-    _PyBytes_Resize(&RetVal, self->zst.total_out - start_total_out);
+    _PyString_Resize(&RetVal, self->zst.total_out - start_total_out);
 
  error:
     LEAVE_ZLIB
@@ -589,10 +589,10 @@ PyZlib_flush(compobject *self, PyObject *args)
     /* Flushing with Z_NO_FLUSH is a no-op, so there's no point in
        doing any work at all; just return an empty string. */
     if (flushmode == Z_NO_FLUSH) {
-       return PyBytes_FromStringAndSize(NULL, 0);
+       return PyString_FromStringAndSize(NULL, 0);
     }
 
-    if (!(RetVal = PyBytes_FromStringAndSize(NULL, length)))
+    if (!(RetVal = PyString_FromStringAndSize(NULL, length)))
        return NULL;
 
     ENTER_ZLIB
@@ -600,7 +600,7 @@ PyZlib_flush(compobject *self, PyObject *args)
     start_total_out = self->zst.total_out;
     self->zst.avail_in = 0;
     self->zst.avail_out = length;
-    self->zst.next_out = (unsigned char *)PyBytes_AS_STRING(RetVal);
+    self->zst.next_out = (unsigned char *)PyString_AS_STRING(RetVal);
 
     Py_BEGIN_ALLOW_THREADS
     err = deflate(&(self->zst), flushmode);
@@ -609,9 +609,9 @@ PyZlib_flush(compobject *self, PyObject *args)
     /* while Z_OK and the output buffer is full, there might be more output,
        so extend the output buffer and try again */
     while (err == Z_OK && self->zst.avail_out == 0) {
-       if (_PyBytes_Resize(&RetVal, length << 1) < 0)
+       if (_PyString_Resize(&RetVal, length << 1) < 0)
            goto error;
-       self->zst.next_out = (unsigned char *)PyBytes_AS_STRING(RetVal) \
+       self->zst.next_out = (unsigned char *)PyString_AS_STRING(RetVal) \
            + length;
        self->zst.avail_out = length;
        length = length << 1;
@@ -646,7 +646,7 @@ PyZlib_flush(compobject *self, PyObject *args)
        goto error;
     }
 
-    _PyBytes_Resize(&RetVal, self->zst.total_out - start_total_out);
+    _PyString_Resize(&RetVal, self->zst.total_out - start_total_out);
 
  error:
     LEAVE_ZLIB
@@ -778,7 +778,7 @@ PyZlib_unflush(compobject *self, PyObject *args)
        PyErr_SetString(PyExc_ValueError, "length must be greater than zero");
        return NULL;
     }
-    if (!(retval = PyBytes_FromStringAndSize(NULL, length)))
+    if (!(retval = PyString_FromStringAndSize(NULL, length)))
        return NULL;
 
 
@@ -786,7 +786,7 @@ PyZlib_unflush(compobject *self, PyObject *args)
 
     start_total_out = self->zst.total_out;
     self->zst.avail_out = length;
-    self->zst.next_out = (Byte *)PyBytes_AS_STRING(retval);
+    self->zst.next_out = (Byte *)PyString_AS_STRING(retval);
 
     Py_BEGIN_ALLOW_THREADS
     err = inflate(&(self->zst), Z_FINISH);
@@ -795,9 +795,9 @@ PyZlib_unflush(compobject *self, PyObject *args)
     /* while Z_OK and the output buffer is full, there might be more output,
        so extend the output buffer and try again */
     while ((err == Z_OK || err == Z_BUF_ERROR) && self->zst.avail_out == 0) {
-       if (_PyBytes_Resize(&retval, length << 1) < 0)
+       if (_PyString_Resize(&retval, length << 1) < 0)
            goto error;
-       self->zst.next_out = (Byte *)PyBytes_AS_STRING(retval) + length;
+       self->zst.next_out = (Byte *)PyString_AS_STRING(retval) + length;
        self->zst.avail_out = length;
        length = length << 1;
 
@@ -819,7 +819,7 @@ PyZlib_unflush(compobject *self, PyObject *args)
            goto error;
        }
     }
-    _PyBytes_Resize(&retval, self->zst.total_out - start_total_out);
+    _PyString_Resize(&retval, self->zst.total_out - start_total_out);
 
 error:
 
@@ -1027,7 +1027,7 @@ PyInit_zlib(void)
     PyModule_AddIntConstant(m, "Z_SYNC_FLUSH", Z_SYNC_FLUSH);
     PyModule_AddIntConstant(m, "Z_FULL_FLUSH", Z_FULL_FLUSH);
 
-    ver = PyBytes_FromString(ZLIB_VERSION);
+    ver = PyString_FromString(ZLIB_VERSION);
     if (ver != NULL)
        PyModule_AddObject(m, "ZLIB_VERSION", ver);
 
index aa30129e921273dc6638eec4181f0e4e407a6ad6..1d5c4d548b7187e628eaf6a46c0efcdf00baa4d4 100644 (file)
@@ -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;
        }
index 93affd1383b26afa86accbced5e7dc1843fa9a35..fd73d2809535db429c1452f3fb37d33d7b087368 100644 (file)
@@ -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;
 }
index ee8dd3db15863a8b306d83680ceb27a85bea6fa1..37d9bcbb5a6ad7801b5c66b5a85a803a95b842c4 100644 (file)
@@ -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;
index 2d55601d39a92e0849cd5aa174e7db13bc7659df..de87905d803e83096bc6e8141aeb73061ad866b3 100644 (file)
@@ -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++);
index 61ee42ab8c32c61af3aaf2b5ffa6e4583bd76ecf..d0e4e26edbcece55cc30f3bfe41b6318d35421d2 100644 (file)
@@ -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++) {
index 16bb150640c6dfee7b386d65736f1836a327582a..4e0bcf8833ed6c5260fe23ab70cafbdd501d2e60 100644 (file)
@@ -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);
 }
index 372a40e0b51f335d9ce16e5e8a8daa921739d0f0..caf6b3e7b0de0a5e82a0f255a5a27d4dfca2e658 100644 (file)
@@ -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);
index 9892d9c93baaf1e47527756472d519ce3cbe8850..e94b4cc85b1f5feb0f1fa09a8bc34b32b0e0018d 100644 (file)
@@ -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;
index 6110b997f16ceeb873eaa7907270f85056eddbe8..9943d0d5004af2abdc59dbd74b4f017064d90d5f 100644 (file)
@@ -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;
        }
index 7cf5e6248c6b8aa15a99e30c994ff253e6de0754..fcc174e0b7c33f8da1ff53ff4e62f1eba0618e77 100644 (file)
@@ -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);
        }
 }
 
index 6b15131cd71479b5009d4fcc699b117bfed93c38..9b14e63912308dc850a4792c53b0d330ed2e8d15 100644 (file)
@@ -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);
index 085ef36630aefb89239a6e963e6f6739020077ad..48b47b06102747e214cfce232f2fdb90d2734d4f 100644 (file)
@@ -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");
index 4ea97f5de9b8abc1e1c0db82bc583b385583c05c..8cc829bacd02d987739fc4fd9d8f2cea21189f9f 100644 (file)
@@ -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;
index baf55aaf83b22fe38e6c7b176fcf481c926a0f23..32e7cc8088cec0e9d961c46584719145f68239b8 100644 (file)
@@ -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;
index 36c1fc2d932ecb8f9ae2e03b86b3a7954baa5ace..025431e56b4de2d91c1dbad5429e047948fd104b 100644 (file)
@@ -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();
index 216b6da95f66e60ca7cb14485e8eb4df5590b077..a2e87b733ccf69c3b23e8c1e068acfd45b61cf02 100644 (file)
@@ -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);
 }
 
index b1c51a83d219f687bd24ecfa410312cf299f82cc..d2ef508837cab85c56ed7e1c921ddacc6743dc98 100644 (file)
@@ -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);
 }
 
index 3b68640163a030da7aad53e68cbf99499024660e..f98aee0e2e1544d1e59cbfc3ab5b1c8a8a7216db 100644 (file)
@@ -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 *
index 796e8cb26e0b3bea4229a01a077451cc57bdb060..e72f81ffd1777209ea44fc9050b9babcf89179a1 100644 (file)
@@ -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;
index c9d138b9a8c9aa413aba99449c94c8b615da3b7c..c65d0c00abe8037ea85552d941dcb7414d2bb726 100644 (file)
@@ -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))
index 57ab5c51d4db1625711a05b9439bee7d82b8e036..737a3f780ed60eefe6a6b69b4050608c83717254 100644 (file)
@@ -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) {
index fa3daa9e1541f0201e12a234e0882be778eca62c..d1aa771935768b2c6b1f56e1f406379211395ecc 100644 (file)
@@ -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
index 8f9d731272a21a3a05e92746f91b3975897e35dc..ccb5ab78ce4f280c56b8e72fcd01815de00b99c9 100644 (file)
@@ -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)
index b3ed673226c0822ad078fc3a6950b2916bfba1b6..da4356b9f1601b0b269293a7c5d6dfb59ba5bf44 100644 (file)
@@ -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);
index 5e8e05dd897f3fc3570ff52d5a66b6a88ff77305..371d8c154177ec4cba34a59910143b747c4f735b 100644 (file)
@@ -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++;
        }
index 75048e353f478ae51e22eaad418b1e0185328dd6..075418ebccde39969fb90ff904da43a0ff17f14e 100644 (file)
@@ -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;
 }
index 2e9c7efd4c14e68ffdb3da77a7e3580663c791ae..be8e8080851697ebf8259e72593f592992ebef15 100644 (file)
@@ -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 */
index bdc3a29160c10d93f70d998da296b6f0baeb9caf..daaa2e2b0f7be7ad91c1996b386881dcbb3d92be 100644 (file)
@@ -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"
 #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 */
index c348254a82f05646183dde488c958f33e8721f59..b6126bae467e99b038542b1bd1076acc2fd9c65b 100644 (file)
@@ -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 *
index 0524aae61b289ee65fc8f6a7c1f39e440222db9b..e9cb3efbe8e86aeb944cd29ff4bc3c82d17e5b98 100644 (file)
@@ -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:
index e88ca05a8cf35c06c78d5b6691b6bfee97d012b0..e0ae55b057ca92038351e36eba9e4f50479bc55f 100644 (file)
                 >> (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;
                }
index 3ffe99c912c6622e5566576ab7c25853bcba6121..873f1c43957171213b2952131f6404fdc3e49993 100644 (file)
@@ -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);
index 2899bc70a8f2870bdc0e1b2a482a9746fbb00142..1aee5a55302f74f46247c101826f08ae1e72c6ba 100644 (file)
@@ -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);
 }
 
 
index 6b1c594d1c048f401d7c98079365cd7234e23fa1..58b253061564962c767e8b83fd6361f1bd8db0aa 100644 (file)
--- a/PC/_msi.c
+++ b/PC/_msi.c
@@ -35,7 +35,7 @@ uuidcreate(PyObject* obj, PyObject*args)
        return NULL;
     }
 
-    oresult = PyBytes_FromString(cresult);
+    oresult = PyString_FromString(cresult);
     RpcStringFree(&cresult);
     return oresult;
 
@@ -136,14 +136,14 @@ static FNFCIGETNEXTCABINET(cb_getnextcabinet)
        PyObject *result = PyObject_CallMethod(pv, "getnextcabinet", "i", pccab->iCab);
        if (result == NULL)
            return -1;
-       if (!PyBytes_Check(result)) {
+       if (!PyString_Check(result)) {
            PyErr_Format(PyExc_TypeError, 
                "Incorrect return type %s from getnextcabinet",
                result->ob_type->tp_name);
            Py_DECREF(result);
            return FALSE;
        }
-       strncpy(pccab->szCab, PyBytes_AsString(result), sizeof(pccab->szCab));
+       strncpy(pccab->szCab, PyString_AsString(result), sizeof(pccab->szCab));
        return TRUE;
     }
     return FALSE;
@@ -554,7 +554,7 @@ summary_getproperty(msiobj* si, PyObject *args)
            PyErr_SetString(PyExc_NotImplementedError, "FILETIME result");
            return NULL;
        case VT_LPSTR:
-           result = PyBytes_FromStringAndSize(sval, ssize);
+           result = PyString_FromStringAndSize(sval, ssize);
            if (sval != sbuf)
                free(sval);
            return result;
@@ -586,9 +586,9 @@ summary_setproperty(msiobj* si, PyObject *args)
     if (!PyArg_ParseTuple(args, "iO:SetProperty", &field, &data))
        return NULL;
 
-    if (PyBytes_Check(data)) {
+    if (PyString_Check(data)) {
        status = MsiSummaryInfoSetProperty(si->h, field, VT_LPSTR,
-           0, NULL, PyBytes_AsString(data));
+           0, NULL, PyString_AsString(data));
     } else if (PyInt_Check(data)) {
        status = MsiSummaryInfoSetProperty(si->h, field, VT_I4,
            PyInt_AsLong(data), NULL, NULL);
index 60f3bfe85973d0170d3af2c1bf365bae3445b765..c93f84bd1fe78216701ed3c6582b2746d66b99c7 100644 (file)
@@ -304,42 +304,42 @@ getenvironment(PyObject* environment)
        if (!keys || !values)
                goto error;
 
-       out = PyBytes_FromStringAndSize(NULL, 2048);
+       out = PyString_FromStringAndSize(NULL, 2048);
        if (! out)
                goto error;
 
-       p = PyBytes_AS_STRING(out);
+       p = PyString_AS_STRING(out);
 
        for (i = 0; i < envsize; i++) {
                int ksize, vsize, totalsize;
                PyObject* key = PyList_GET_ITEM(keys, i);
                PyObject* value = PyList_GET_ITEM(values, i);
 
-               if (! PyBytes_Check(key) || ! PyBytes_Check(value)) {
+               if (! PyString_Check(key) || ! PyString_Check(value)) {
                        PyErr_SetString(PyExc_TypeError,
                                "environment can only contain strings");
                        goto error;
                }
-               ksize = PyBytes_GET_SIZE(key);
-               vsize = PyBytes_GET_SIZE(value);
-               totalsize = (p - PyBytes_AS_STRING(out)) + ksize + 1 +
+               ksize = PyString_GET_SIZE(key);
+               vsize = PyString_GET_SIZE(value);
+               totalsize = (p - PyString_AS_STRING(out)) + ksize + 1 +
                                                             vsize + 1 + 1;
-               if (totalsize > PyBytes_GET_SIZE(out)) {
-                       int offset = p - PyBytes_AS_STRING(out);
-                       _PyBytes_Resize(&out, totalsize + 1024);
-                       p = PyBytes_AS_STRING(out) + offset;
+               if (totalsize > PyString_GET_SIZE(out)) {
+                       int offset = p - PyString_AS_STRING(out);
+                       _PyString_Resize(&out, totalsize + 1024);
+                       p = PyString_AS_STRING(out) + offset;
                }
-               memcpy(p, PyBytes_AS_STRING(key), ksize);
+               memcpy(p, PyString_AS_STRING(key), ksize);
                p += ksize;
                *p++ = '=';
-               memcpy(p, PyBytes_AS_STRING(value), vsize);
+               memcpy(p, PyString_AS_STRING(value), vsize);
                p += vsize;
                *p++ = '\0';
        }
 
        /* add trailing null byte */
        *p++ = '\0';
-       _PyBytes_Resize(&out, p - PyBytes_AS_STRING(out));
+       _PyString_Resize(&out, p - PyString_AS_STRING(out));
 
        /* PyObject_Print(out, stdout, 0); */
 
@@ -413,7 +413,7 @@ sp_CreateProcess(PyObject* self, PyObject* args)
                               NULL,
                               inherit_handles,
                               creation_flags,
-                              environment ? PyBytes_AS_STRING(environment) : NULL,
+                              environment ? PyString_AS_STRING(environment) : NULL,
                               current_directory,
                               &si,
                               &pi);
@@ -516,7 +516,7 @@ sp_GetModuleFileName(PyObject* self, PyObject* args)
        if (! result)
                return PyErr_SetFromWindowsErr(GetLastError());
 
-       return PyBytes_FromString(filename);
+       return PyString_FromString(filename);
 }
 
 static PyMethodDef sp_functions[] = {
index edf2897bda9ce641ae5af621e6e39d57c9035c27..74d33437bc802f65f626e094caca569314867017 100644 (file)
@@ -424,7 +424,7 @@ PyHKEY_strFunc(PyObject *ob)
        PyHKEYObject *pyhkey = (PyHKEYObject *)ob;
        char resBuf[160];
        wsprintf(resBuf, "<PyHKEY:%p>", pyhkey->hkey);
-       return PyBytes_FromString(resBuf);
+       return PyString_FromString(resBuf);
 }
 
 static int
@@ -767,11 +767,11 @@ Py2Reg(PyObject *value, DWORD typ, BYTE **retDataBuf, DWORD *retDataSize)
                                                return FALSE;
                                        need_decref = 1;
                                }
-                               if (!PyBytes_Check(value))
+                               if (!PyString_Check(value))
                                        return FALSE;
                                *retDataSize = 1 + strlen(
-                                       PyBytes_AS_STRING(
-                                               (PyBytesObject *)value));
+                                       PyString_AS_STRING(
+                                               (PyStringObject *)value));
                        }
                        *retDataBuf = (BYTE *)PyMem_NEW(DWORD, *retDataSize);
                        if (*retDataBuf==NULL){
@@ -782,8 +782,8 @@ Py2Reg(PyObject *value, DWORD typ, BYTE **retDataBuf, DWORD *retDataSize)
                                strcpy((char *)*retDataBuf, "");
                        else
                                strcpy((char *)*retDataBuf,
-                                      PyBytes_AS_STRING(
-                                               (PyBytesObject *)value));
+                                      PyString_AS_STRING(
+                                               (PyStringObject *)value));
                        if (need_decref)
                                Py_DECREF(value);
                        break;
@@ -808,7 +808,7 @@ Py2Reg(PyObject *value, DWORD typ, BYTE **retDataBuf, DWORD *retDataSize)
                                        PyObject *t;
                                        t = PyList_GET_ITEM(
                                                (PyListObject *)value,j);
-                                       if (PyBytes_Check(t)) {
+                                       if (PyString_Check(t)) {
                                                obs[j] = t;
                                                Py_INCREF(t);
                                        } else if (PyUnicode_Check(t)) {
@@ -821,8 +821,8 @@ Py2Reg(PyObject *value, DWORD typ, BYTE **retDataBuf, DWORD *retDataSize)
                                        } else
                                                goto reg_multi_fail;
                                        size += 1 + strlen(
-                                               PyBytes_AS_STRING(
-                                                       (PyBytesObject *)obs[j]));
+                                               PyString_AS_STRING(
+                                                       (PyStringObject *)obs[j]));
                                }
 
                                *retDataSize = size + 1;
@@ -839,11 +839,11 @@ Py2Reg(PyObject *value, DWORD typ, BYTE **retDataBuf, DWORD *retDataSize)
                                        PyObject *t;
                                        t = obs[j];
                                        strcpy(P,
-                                              PyBytes_AS_STRING(
-                                                       (PyBytesObject *)t));
+                                              PyString_AS_STRING(
+                                                       (PyStringObject *)t));
                                        P += 1 + strlen(
-                                               PyBytes_AS_STRING(
-                                                       (PyBytesObject *)t));
+                                               PyString_AS_STRING(
+                                                       (PyStringObject *)t));
                                        Py_DECREF(obs[j]);
                                }
                                /* And doubly-terminate the list... */
@@ -1085,7 +1085,7 @@ PyEnumKey(PyObject *self, PyObject *args)
        if (rc != ERROR_SUCCESS)
                return PyErr_SetFromWindowsErrWithFunction(rc, "RegEnumKeyEx");
 
-       retStr = PyBytes_FromStringAndSize(tmpbuf, len);
+       retStr = PyString_FromStringAndSize(tmpbuf, len);
        return retStr;  /* can be NULL */
 }
 
@@ -1303,17 +1303,17 @@ PyQueryValue(PyObject *self, PyObject *args)
            != ERROR_SUCCESS)
                return PyErr_SetFromWindowsErrWithFunction(rc,
                                                           "RegQueryValue");
-       retStr = PyBytes_FromStringAndSize(NULL, bufSize);
+       retStr = PyString_FromStringAndSize(NULL, bufSize);
        if (retStr == NULL)
                return NULL;
-       retBuf = PyBytes_AS_STRING(retStr);
+       retBuf = PyString_AS_STRING(retStr);
        if ((rc = RegQueryValue(hKey, subKey, retBuf, &bufSize))
            != ERROR_SUCCESS) {
                Py_DECREF(retStr);
                return PyErr_SetFromWindowsErrWithFunction(rc,
                                                           "RegQueryValue");
        }
-       _PyBytes_Resize(&retStr, strlen(retBuf));
+       _PyString_Resize(&retStr, strlen(retBuf));
        return retStr;
 }
 
@@ -1414,14 +1414,14 @@ PySetValue(PyObject *self, PyObject *args)
                return NULL;
        }
        /* XXX - need Unicode support */
-       str = PyBytes_AsString(obStrVal);
+       str = PyString_AsString(obStrVal);
        if (str == NULL)
                return NULL;
-       len = PyBytes_Size(obStrVal);
+       len = PyString_Size(obStrVal);
        if (obSubKey == Py_None)
                subKey = NULL;
        else {
-               subKey = PyBytes_AsString(obSubKey);
+               subKey = PyString_AsString(obSubKey);
                if (subKey == NULL)
                        return NULL;
        }
index 757d85ef43383b7273972e0edc249048199e5b58..e110ed8b091c4a13dcb93b7b1c49c272e8b1fcd9 100755 (executable)
@@ -140,7 +140,7 @@ msvcrt_getch(PyObject *self, PyObject *args)
        ch = _getch();
        Py_END_ALLOW_THREADS
        s[0] = ch;
-       return PyBytes_FromStringAndSize(s, 1);
+       return PyString_FromStringAndSize(s, 1);
 }
 
 static PyObject *
@@ -172,7 +172,7 @@ msvcrt_getche(PyObject *self, PyObject *args)
        ch = _getche();
        Py_END_ALLOW_THREADS
        s[0] = ch;
-       return PyBytes_FromStringAndSize(s, 1);
+       return PyString_FromStringAndSize(s, 1);
 }
 
 static PyObject *
index 4caadb3310a3e399b7940a4de4fdb134e01337e6..e6ff2269ee7f68d42303438501a42c9a3ad08a3e 100644 (file)
@@ -151,7 +151,7 @@ static struct PyMethodDef sound_methods[] =
 static void
 add_define(PyObject *dict, const char *key, long value)
 {
-    PyObject *k=PyBytes_FromString(key);
+    PyObject *k=PyString_FromString(key);
     PyObject *v=PyLong_FromLong(value);
     if(v&&k)
     {
index 0d6c5c00a84f7a7a61446648c37b5a459949e662..25ff424408a38120c786afa8b9bf599dccfb3af7 100755 (executable)
@@ -375,7 +375,7 @@ class Obj2ModVisitor(PickleVisitor):
         # there's really nothing more we can do if this fails ...
         self.emit("if (tmp == NULL) goto failed;", 1)
         error = "expected some sort of %s, but got %%.400s" % name
-        format = "PyErr_Format(PyExc_TypeError, \"%s\", PyBytes_AS_STRING(tmp));"
+        format = "PyErr_Format(PyExc_TypeError, \"%s\", PyString_AS_STRING(tmp));"
         self.emit(format % error, 1, reflow=False)
         self.emit("failed:", 0)
         self.emit("Py_XDECREF(tmp);", 1)
@@ -704,7 +704,7 @@ static PyTypeObject* make_type(char *type, PyTypeObject* base, char**fields, int
     fnames = PyTuple_New(num_fields);
     if (!fnames) return NULL;
     for (i = 0; i < num_fields; i++) {
-        PyObject *field = PyBytes_FromString(fields[i]);
+        PyObject *field = PyString_FromString(fields[i]);
         if (!field) {
             Py_DECREF(fnames);
             return NULL;
@@ -723,7 +723,7 @@ static int add_attributes(PyTypeObject* type, char**attrs, int num_fields)
     PyObject *s, *l = PyTuple_New(num_fields);
     if (!l) return 0;
     for(i = 0; i < num_fields; i++) {
-        s = PyBytes_FromString(attrs[i]);
+        s = PyString_FromString(attrs[i]);
         if (!s) {
             Py_DECREF(l);
             return 0;
@@ -797,7 +797,7 @@ static int obj2ast_int(PyObject* obj, int* out, PyArena* arena)
         PyObject *s = PyObject_Repr(obj);
         if (s == NULL) return 1;
         PyErr_Format(PyExc_ValueError, "invalid integer value: %.400s",
-                     PyBytes_AS_STRING(s));
+                     PyString_AS_STRING(s));
         Py_DECREF(s);
         return 1;
     }
@@ -815,7 +815,7 @@ static int obj2ast_bool(PyObject* obj, bool* out, PyArena* arena)
         PyObject *s = PyObject_Repr(obj);
         if (s == NULL) return 1;
         PyErr_Format(PyExc_ValueError, "invalid boolean value: %.400s",
-                     PyBytes_AS_STRING(s));
+                     PyString_AS_STRING(s));
         Py_DECREF(s);
         return 1;
     }
index bce2bdaa0233aa8a59e6c8e44dbd2250987285fc..1d0a4aa3f23b438dc5c17185bbd973130582f436 100644 (file)
@@ -12,7 +12,7 @@
 
 #ifndef PGEN
 #include "unicodeobject.h"
-#include "bytesobject.h"
+#include "stringobject.h"
 #include "fileobject.h"
 #include "codecs.h"
 #include "abstract.h"
@@ -344,7 +344,7 @@ check_bom(int get_char(struct tok_state *),
      1) NULL: need to call tok->decoding_readline to get a new line
      2) PyUnicodeObject *: decoding_feof has called tok->decoding_readline and
            stored the result in tok->decoding_buffer
-     3) PyBytesObject *: previous call to fp_readl did not have enough room
+     3) PyStringObject *: previous call to fp_readl did not have enough room
            (in the s buffer) to copy entire contents of the line read
            by tok->decoding_readline.  tok->decoding_buffer has the overflow.
            In this case, fp_readl is called in a loop (with an expanded buffer)
@@ -375,7 +375,7 @@ fp_readl(char *s, int size, struct tok_state *tok)
                        return error_ret(tok);
        } else {
                tok->decoding_buffer = NULL;
-               if (PyBytes_CheckExact(buf))
+               if (PyString_CheckExact(buf))
                        utf8 = buf;
        }
        if (utf8 == NULL) {
@@ -384,10 +384,10 @@ fp_readl(char *s, int size, struct tok_state *tok)
                if (utf8 == NULL)
                        return error_ret(tok);
        }
-       str = PyBytes_AsString(utf8);
-       utf8len = PyBytes_GET_SIZE(utf8);
+       str = PyString_AsString(utf8);
+       utf8len = PyString_GET_SIZE(utf8);
        if (utf8len > size) {
-               tok->decoding_buffer = PyBytes_FromStringAndSize(str+size, utf8len-size);
+               tok->decoding_buffer = PyString_FromStringAndSize(str+size, utf8len-size);
                if (tok->decoding_buffer == NULL) {
                        Py_DECREF(utf8);
                        return error_ret(tok);
@@ -591,7 +591,7 @@ decode_str(const char *str, struct tok_state *tok)
                utf8 = translate_into_utf8(str, tok->enc);
                if (utf8 == NULL)
                        return error_ret(tok);
-               str = PyBytes_AsString(utf8);
+               str = PyString_AsString(utf8);
        }
 #endif
        for (s = str;; s++) {
@@ -624,7 +624,7 @@ decode_str(const char *str, struct tok_state *tok)
                                "unknown encoding: %s", tok->enc);
                        return error_ret(tok);
                }
-               str = PyBytes_AsString(utf8);
+               str = PyString_AsString(utf8);
        }
 #endif
        assert(tok->decoding_buffer == NULL);
@@ -706,11 +706,11 @@ tok_stdin_decode(struct tok_state *tok, char **inp)
                return 0;
 
        enc = ((PyFileObject *)sysstdin)->f_encoding;
-       if (enc == NULL || !PyBytes_Check(enc))
+       if (enc == NULL || !PyString_Check(enc))
                return 0;
        Py_INCREF(enc);
 
-       encoding = PyBytes_AsString(enc);
+       encoding = PyString_AsString(enc);
        decoded = PyUnicode_Decode(*inp, strlen(*inp), encoding, NULL);
        if (decoded == NULL)
                goto error_clear;
@@ -720,9 +720,9 @@ tok_stdin_decode(struct tok_state *tok, char **inp)
        if (utf8 == NULL)
                goto error_clear;
 
-       assert(PyBytes_Check(utf8));
-       converted = new_string(PyBytes_AS_STRING(utf8),
-                              PyBytes_GET_SIZE(utf8));
+       assert(PyString_Check(utf8));
+       converted = new_string(PyString_AS_STRING(utf8),
+                              PyString_GET_SIZE(utf8));
        Py_DECREF(utf8);
        if (converted == NULL)
                goto error_nomem;
@@ -1609,8 +1609,8 @@ PyTokenizer_RestoreEncoding(struct tok_state* tok, int len, int *offset)
                /* convert source to original encondig */
                PyObject *lineobj = dec_utf8(tok->encoding, tok->buf, len);
                if (lineobj != NULL) {
-                       int linelen = PyBytes_Size(lineobj);
-                       const char *line = PyBytes_AsString(lineobj);
+                       int linelen = PyString_Size(lineobj);
+                       const char *line = PyString_AsString(lineobj);
                        text = PyObject_MALLOC(linelen + 1);
                        if (text != NULL && line != NULL) {
                                if (linelen)
@@ -1624,7 +1624,7 @@ PyTokenizer_RestoreEncoding(struct tok_state* tok, int len, int *offset)
                                PyObject *offsetobj = dec_utf8(tok->encoding, 
                                                               tok->buf, *offset-1);
                                if (offsetobj) {
-                                       *offset = PyBytes_Size(offsetobj) + 1;
+                                       *offset = PyString_Size(offsetobj) + 1;
                                        Py_DECREF(offsetobj);
                                }
                        }
index 35a3d27ef33c8e8176c426e562d3ee4ef891f0e8..f958145a23317903b2cdab062b85c47b4fb368b5 100644 (file)
@@ -495,7 +495,7 @@ static PyTypeObject* make_type(char *type, PyTypeObject* base, char**fields, int
     fnames = PyTuple_New(num_fields);
     if (!fnames) return NULL;
     for (i = 0; i < num_fields; i++) {
-        PyObject *field = PyBytes_FromString(fields[i]);
+        PyObject *field = PyString_FromString(fields[i]);
         if (!field) {
             Py_DECREF(fnames);
             return NULL;
@@ -514,7 +514,7 @@ static int add_attributes(PyTypeObject* type, char**attrs, int num_fields)
     PyObject *s, *l = PyTuple_New(num_fields);
     if (!l) return 0;
     for(i = 0; i < num_fields; i++) {
-        s = PyBytes_FromString(attrs[i]);
+        s = PyString_FromString(attrs[i]);
         if (!s) {
             Py_DECREF(l);
             return 0;
@@ -588,7 +588,7 @@ static int obj2ast_int(PyObject* obj, int* out, PyArena* arena)
         PyObject *s = PyObject_Repr(obj);
         if (s == NULL) return 1;
         PyErr_Format(PyExc_ValueError, "invalid integer value: %.400s",
-                     PyBytes_AS_STRING(s));
+                     PyString_AS_STRING(s));
         Py_DECREF(s);
         return 1;
     }
@@ -606,7 +606,7 @@ static int obj2ast_bool(PyObject* obj, bool* out, PyArena* arena)
         PyObject *s = PyObject_Repr(obj);
         if (s == NULL) return 1;
         PyErr_Format(PyExc_ValueError, "invalid boolean value: %.400s",
-                     PyBytes_AS_STRING(s));
+                     PyString_AS_STRING(s));
         Py_DECREF(s);
         return 1;
     }
@@ -3286,7 +3286,7 @@ obj2ast_mod(PyObject* obj, mod_ty* out, PyArena* arena)
 
         tmp = PyObject_Repr(obj);
         if (tmp == NULL) goto failed;
-        PyErr_Format(PyExc_TypeError, "expected some sort of mod, but got %.400s", PyBytes_AS_STRING(tmp));
+        PyErr_Format(PyExc_TypeError, "expected some sort of mod, but got %.400s", PyString_AS_STRING(tmp));
 failed:
         Py_XDECREF(tmp);
         return 1;
@@ -4414,7 +4414,7 @@ obj2ast_stmt(PyObject* obj, stmt_ty* out, PyArena* arena)
 
         tmp = PyObject_Repr(obj);
         if (tmp == NULL) goto failed;
-        PyErr_Format(PyExc_TypeError, "expected some sort of stmt, but got %.400s", PyBytes_AS_STRING(tmp));
+        PyErr_Format(PyExc_TypeError, "expected some sort of stmt, but got %.400s", PyString_AS_STRING(tmp));
 failed:
         Py_XDECREF(tmp);
         return 1;
@@ -5261,7 +5261,7 @@ obj2ast_expr(PyObject* obj, expr_ty* out, PyArena* arena)
 
         tmp = PyObject_Repr(obj);
         if (tmp == NULL) goto failed;
-        PyErr_Format(PyExc_TypeError, "expected some sort of expr, but got %.400s", PyBytes_AS_STRING(tmp));
+        PyErr_Format(PyExc_TypeError, "expected some sort of expr, but got %.400s", PyString_AS_STRING(tmp));
 failed:
         Py_XDECREF(tmp);
         return 1;
@@ -5299,7 +5299,7 @@ obj2ast_expr_context(PyObject* obj, expr_context_ty* out, PyArena* arena)
 
         tmp = PyObject_Repr(obj);
         if (tmp == NULL) goto failed;
-        PyErr_Format(PyExc_TypeError, "expected some sort of expr_context, but got %.400s", PyBytes_AS_STRING(tmp));
+        PyErr_Format(PyExc_TypeError, "expected some sort of expr_context, but got %.400s", PyString_AS_STRING(tmp));
 failed:
         Py_XDECREF(tmp);
         return 1;
@@ -5417,7 +5417,7 @@ obj2ast_slice(PyObject* obj, slice_ty* out, PyArena* arena)
 
         tmp = PyObject_Repr(obj);
         if (tmp == NULL) goto failed;
-        PyErr_Format(PyExc_TypeError, "expected some sort of slice, but got %.400s", PyBytes_AS_STRING(tmp));
+        PyErr_Format(PyExc_TypeError, "expected some sort of slice, but got %.400s", PyString_AS_STRING(tmp));
 failed:
         Py_XDECREF(tmp);
         return 1;
@@ -5439,7 +5439,7 @@ obj2ast_boolop(PyObject* obj, boolop_ty* out, PyArena* arena)
 
         tmp = PyObject_Repr(obj);
         if (tmp == NULL) goto failed;
-        PyErr_Format(PyExc_TypeError, "expected some sort of boolop, but got %.400s", PyBytes_AS_STRING(tmp));
+        PyErr_Format(PyExc_TypeError, "expected some sort of boolop, but got %.400s", PyString_AS_STRING(tmp));
 failed:
         Py_XDECREF(tmp);
         return 1;
@@ -5501,7 +5501,7 @@ obj2ast_operator(PyObject* obj, operator_ty* out, PyArena* arena)
 
         tmp = PyObject_Repr(obj);
         if (tmp == NULL) goto failed;
-        PyErr_Format(PyExc_TypeError, "expected some sort of operator, but got %.400s", PyBytes_AS_STRING(tmp));
+        PyErr_Format(PyExc_TypeError, "expected some sort of operator, but got %.400s", PyString_AS_STRING(tmp));
 failed:
         Py_XDECREF(tmp);
         return 1;
@@ -5531,7 +5531,7 @@ obj2ast_unaryop(PyObject* obj, unaryop_ty* out, PyArena* arena)
 
         tmp = PyObject_Repr(obj);
         if (tmp == NULL) goto failed;
-        PyErr_Format(PyExc_TypeError, "expected some sort of unaryop, but got %.400s", PyBytes_AS_STRING(tmp));
+        PyErr_Format(PyExc_TypeError, "expected some sort of unaryop, but got %.400s", PyString_AS_STRING(tmp));
 failed:
         Py_XDECREF(tmp);
         return 1;
@@ -5585,7 +5585,7 @@ obj2ast_cmpop(PyObject* obj, cmpop_ty* out, PyArena* arena)
 
         tmp = PyObject_Repr(obj);
         if (tmp == NULL) goto failed;
-        PyErr_Format(PyExc_TypeError, "expected some sort of cmpop, but got %.400s", PyBytes_AS_STRING(tmp));
+        PyErr_Format(PyExc_TypeError, "expected some sort of cmpop, but got %.400s", PyString_AS_STRING(tmp));
 failed:
         Py_XDECREF(tmp);
         return 1;
@@ -5751,7 +5751,7 @@ obj2ast_excepthandler(PyObject* obj, excepthandler_ty* out, PyArena* arena)
 
         tmp = PyObject_Repr(obj);
         if (tmp == NULL) goto failed;
-        PyErr_Format(PyExc_TypeError, "expected some sort of excepthandler, but got %.400s", PyBytes_AS_STRING(tmp));
+        PyErr_Format(PyExc_TypeError, "expected some sort of excepthandler, but got %.400s", PyString_AS_STRING(tmp));
 failed:
         Py_XDECREF(tmp);
         return 1;
index 0adb0c8f96a5aac4bf6a1e3b5bd26ac4a29cf6df..e3daf77b97d0715cd540806a66666c09441ed5f2 100644 (file)
@@ -44,7 +44,7 @@ get_warnings_attr(const char *attr)
     int result;
 
     if (warnings_str == NULL) {
-        warnings_str = PyBytes_InternFromString("warnings");
+        warnings_str = PyString_InternFromString("warnings");
         if (warnings_str == NULL)
             return NULL;
     }
@@ -132,7 +132,7 @@ get_filter(PyObject *category, PyObject *text, Py_ssize_t lineno,
             return NULL;
 
         if (good_msg && is_subclass && good_mod && (ln == 0 || lineno == ln))
-            return PyBytes_AsString(action);
+            return PyString_AsString(action);
     }
 
     m = PyImport_ImportModule(MODULE_NAME);
@@ -144,7 +144,7 @@ get_filter(PyObject *category, PyObject *text, Py_ssize_t lineno,
         return NULL;
     action = PyDict_GetItemString(d, DEFAULT_ACTION_NAME);
     if (action != NULL)
-        return PyBytes_AsString(action);
+        return PyString_AsString(action);
 
     PyErr_SetString(PyExc_ValueError,
                     MODULE_NAME "." DEFAULT_ACTION_NAME " not found");
@@ -184,17 +184,17 @@ normalize_module(PyObject *filename)
     if (rc == -1)
         return NULL;
     else if (rc == 0)
-        return PyBytes_FromString("<unknown>");
+        return PyString_FromString("<unknown>");
 
-    mod_str = PyBytes_AsString(filename);
+    mod_str = PyString_AsString(filename);
     if (mod_str == NULL)
            return NULL;
-    len = PyBytes_Size(filename);
+    len = PyString_Size(filename);
     if (len < 0)
         return NULL;
     if (len >= 3 &&
        strncmp(mod_str + (len - 3), ".py", 3) == 0) {
-        module = PyBytes_FromStringAndSize(mod_str, len-3);
+        module = PyString_FromStringAndSize(mod_str, len-3);
     }
     else {
         module = filename;
@@ -258,7 +258,7 @@ show_warning(PyObject *filename, int lineno, PyObject *text, PyObject
     /* Print "  source_line\n" */
     PyFile_WriteString("  ", f_stderr);
     if (sourceline) {
-        char *source_line_str = PyBytes_AS_STRING(sourceline);
+        char *source_line_str = PyString_AS_STRING(sourceline);
         while (*source_line_str == ' ' || *source_line_str == '\t' ||
                 *source_line_str == '\014')
             source_line_str++;
@@ -267,7 +267,7 @@ show_warning(PyObject *filename, int lineno, PyObject *text, PyObject
         PyFile_WriteString("\n", f_stderr);
     }
     else
-        Py_DisplaySourceLine(f_stderr, PyBytes_AS_STRING(filename), lineno);
+        Py_DisplaySourceLine(f_stderr, PyString_AS_STRING(filename), lineno);
     PyErr_Clear();
 }
 
@@ -359,7 +359,7 @@ warn_explicit(PyObject *category, PyObject *message,
             const char *err_str = "???";
 
             if (to_str != NULL)
-                err_str = PyBytes_AS_STRING(to_str);
+                err_str = PyString_AS_STRING(to_str);
             PyErr_Format(PyExc_RuntimeError,
                         "Unrecognized action (%s) in warnings.filters:\n %s",
                         action, err_str);
@@ -380,7 +380,7 @@ warn_explicit(PyObject *category, PyObject *message,
         else {
             const char *msg = "functions overriding warnings.showwarning() "
                                 "must support the 'line' argument";
-            const char *text_char = PyBytes_AS_STRING(text);
+            const char *text_char = PyString_AS_STRING(text);
 
             if (strcmp(msg, text_char) == 0) {
                 /* Prevent infinite recursion by using built-in implementation
@@ -484,7 +484,7 @@ setup_context(Py_ssize_t stack_level, PyObject **filename, int *lineno,
     /* Setup module. */
     *module = PyDict_GetItemString(globals, "__name__");
     if (*module == NULL) {
-        *module = PyBytes_FromString("<string>");
+        *module = PyString_FromString("<string>");
         if (*module == NULL)
             goto handle_error;
     }
@@ -494,8 +494,8 @@ setup_context(Py_ssize_t stack_level, PyObject **filename, int *lineno,
     /* Setup filename. */
     *filename = PyDict_GetItemString(globals, "__file__");
     if (*filename != NULL) {
-           Py_ssize_t len = PyBytes_Size(*filename);
-        const char *file_str = PyBytes_AsString(*filename);
+           Py_ssize_t len = PyString_Size(*filename);
+        const char *file_str = PyString_AsString(*filename);
            if (file_str == NULL || (len < 0 && PyErr_Occurred()))
             goto handle_error;
 
@@ -507,7 +507,7 @@ setup_context(Py_ssize_t stack_level, PyObject **filename, int *lineno,
             (tolower(file_str[len-1]) == 'c' ||
                 tolower(file_str[len-1]) == 'o'))
         {
-            *filename = PyBytes_FromStringAndSize(file_str, len-1);
+            *filename = PyString_FromStringAndSize(file_str, len-1);
                if (*filename == NULL)
                        goto handle_error;
            }
@@ -515,7 +515,7 @@ setup_context(Py_ssize_t stack_level, PyObject **filename, int *lineno,
             Py_INCREF(*filename);
     }
     else {
-        const char *module_str = PyBytes_AsString(*module);
+        const char *module_str = PyString_AsString(*module);
         if (module_str && strcmp(module_str, "__main__") == 0) {
             PyObject *argv = PySys_GetObject("argv");
             if (argv != NULL && PyList_Size(argv) > 0) {
@@ -530,14 +530,14 @@ setup_context(Py_ssize_t stack_level, PyObject **filename, int *lineno,
                 }
                 else if (!is_true) {
                     Py_DECREF(*filename);
-                    *filename = PyBytes_FromString("__main__");
+                    *filename = PyString_FromString("__main__");
                     if (*filename == NULL)
                         goto handle_error;
                 }
             }
             else {
                 /* embedded interpreters don't have sys.argv, see bug #839151 */
-                *filename = PyBytes_FromString("__main__");
+                *filename = PyString_FromString("__main__");
                    if (*filename == NULL)
                        goto handle_error;
             }
@@ -649,12 +649,12 @@ warnings_warn_explicit(PyObject *self, PyObject *args, PyObject *kwds)
         PyObject *returned;
 
         if (get_source_name == NULL) {
-            get_source_name = PyBytes_InternFromString("get_source");
+            get_source_name = PyString_InternFromString("get_source");
             if (!get_source_name)
                 return NULL;
         }
         if (splitlines_name == NULL) {
-            splitlines_name = PyBytes_InternFromString("splitlines");
+            splitlines_name = PyString_InternFromString("splitlines");
             if (!splitlines_name)
                 return NULL;
         }
@@ -711,7 +711,7 @@ int
 PyErr_WarnEx(PyObject *category, const char *text, Py_ssize_t stack_level)
 {
     PyObject *res;
-    PyObject *message = PyBytes_FromString(text);
+    PyObject *message = PyString_FromString(text);
     if (message == NULL)
         return -1;
 
@@ -745,15 +745,15 @@ PyErr_WarnExplicit(PyObject *category, const char *text,
                    const char *module_str, PyObject *registry)
 {
     PyObject *res;
-    PyObject *message = PyBytes_FromString(text);
-    PyObject *filename = PyBytes_FromString(filename_str);
+    PyObject *message = PyString_FromString(text);
+    PyObject *filename = PyString_FromString(filename_str);
     PyObject *module = NULL;
     int ret = -1;
 
     if (message == NULL || filename == NULL)
         goto exit;
     if (module_str != NULL) {
-        module = PyBytes_FromString(module_str);
+        module = PyString_FromString(module_str);
             if (module == NULL)
                 goto exit;
     }
@@ -803,7 +803,7 @@ create_filter(PyObject *category, const char *action)
 
     if (!strcmp(action, "ignore")) {
         if (ignore_str == NULL) {
-            ignore_str = PyBytes_InternFromString("ignore");
+            ignore_str = PyString_InternFromString("ignore");
             if (ignore_str == NULL)
                 return NULL;
         }
@@ -811,7 +811,7 @@ create_filter(PyObject *category, const char *action)
     }
     else if (!strcmp(action, "error")) {
         if (error_str == NULL) {
-            error_str = PyBytes_InternFromString("error");
+            error_str = PyString_InternFromString("error");
             if (error_str == NULL)
                 return NULL;
         }
@@ -819,7 +819,7 @@ create_filter(PyObject *category, const char *action)
     }
     else if (!strcmp(action, "default")) {
         if (default_str == NULL) {
-            default_str = PyBytes_InternFromString("default");
+            default_str = PyString_InternFromString("default");
             if (default_str == NULL)
                 return NULL;
         }
@@ -892,7 +892,7 @@ _PyWarnings_Init(void)
     if (PyModule_AddObject(m, "once_registry", _once_registry) < 0)
         return;
 
-    default_action = PyBytes_InternFromString("default");
+    default_action = PyString_InternFromString("default");
     if (default_action == NULL)
         return;
     if (PyModule_AddObject(m, DEFAULT_ACTION_NAME, default_action) < 0)
index ef0d8bedcf15660e8535eb1d23eccdcfabaf2622..a6bb1b73df775152a9068d4255316b5fee968584 100644 (file)
@@ -46,7 +46,7 @@ static PyObject *parsestrplus(struct compiling *, const node *n);
 
 static identifier
 new_identifier(const char* n, PyArena *arena) {
-    PyObject* id = PyBytes_InternFromString(n);
+    PyObject* id = PyString_InternFromString(n);
     PyArena_AddPyObject(arena, id);
     return id;
 }
@@ -1291,7 +1291,7 @@ ast_for_atom(struct compiling *c, const node *n)
                 if (errstr) {
                     char *s = "";
                     char buf[128];
-                    s = PyBytes_AsString(errstr);
+                    s = PyString_AsString(errstr);
                     PyOS_snprintf(buf, sizeof(buf), "(unicode error) %s", s);
                     ast_error(n, buf);
                 } else {
@@ -2333,10 +2333,10 @@ alias_for_import_name(struct compiling *c, const node *n)
                     /* length of string plus one for the dot */
                     len += strlen(STR(CHILD(n, i))) + 1;
                 len--; /* the last name doesn't have a dot */
-                str = PyBytes_FromStringAndSize(NULL, len);
+                str = PyString_FromStringAndSize(NULL, len);
                 if (!str)
                     return NULL;
-                s = PyBytes_AS_STRING(str);
+                s = PyString_AS_STRING(str);
                 if (!s)
                     return NULL;
                 for (i = 0; i < NCH(n); i += 2) {
@@ -2347,13 +2347,13 @@ alias_for_import_name(struct compiling *c, const node *n)
                 }
                 --s;
                 *s = '\0';
-                PyBytes_InternInPlace(&str);
+                PyString_InternInPlace(&str);
                 PyArena_AddPyObject(c->c_arena, str);
                 return alias(str, NULL, c->c_arena);
             }
             break;
         case STAR:
-            str = PyBytes_InternFromString("*");
+            str = PyString_InternFromString("*");
             PyArena_AddPyObject(c->c_arena, str);
             return alias(str, NULL, c->c_arena);
         default:
@@ -3201,10 +3201,10 @@ decode_unicode(struct compiling *c, const char *s, size_t len, int rawmode, cons
                 u = NULL;
         } else {
                 /* "\XX" may become "\u005c\uHHLL" (12 bytes) */
-                u = PyBytes_FromStringAndSize((char *)NULL, len * 4);
+                u = PyString_FromStringAndSize((char *)NULL, len * 4);
                 if (u == NULL)
                         return NULL;
-                p = buf = PyBytes_AsString(u);
+                p = buf = PyString_AsString(u);
                 end = s + len;
                 while (s < end) {
                         if (*s == '\\') {
@@ -3223,8 +3223,8 @@ decode_unicode(struct compiling *c, const char *s, size_t len, int rawmode, cons
                                         Py_DECREF(u);
                                         return NULL;
                                 }
-                                r = PyBytes_AsString(w);
-                                rn = PyBytes_Size(w);
+                                r = PyString_AsString(w);
+                                rn = PyString_Size(w);
                                 assert(rn % 2 == 0);
                                 for (i = 0; i < rn; i += 2) {
                                         sprintf(p, "\\u%02x%02x",
@@ -3323,11 +3323,11 @@ parsestr(struct compiling *c, const char *s)
                         return v;
 #endif
                 } else {
-                        return PyBytes_FromStringAndSize(s, len);
+                        return PyString_FromStringAndSize(s, len);
                 }
         }
 
-        return PyBytes_DecodeEscape(s, len, NULL, unicode,
+        return PyString_DecodeEscape(s, len, NULL, unicode,
                                      need_encoding ? c->c_encoding : NULL);
 }
 
@@ -3348,8 +3348,8 @@ parsestrplus(struct compiling *c, const node *n)
                         s = parsestr(c, STR(CHILD(n, i)));
                         if (s == NULL)
                                 goto onError;
-                        if (PyBytes_Check(v) && PyBytes_Check(s)) {
-                                PyBytes_ConcatAndDel(&v, s);
+                        if (PyString_Check(v) && PyString_Check(s)) {
+                                PyString_ConcatAndDel(&v, s);
                                 if (v == NULL)
                                     goto onError;
                         }
index 715a10870cfb5f57d5059f4b612d6e033fed9b81..a2ebb4aae192188b52594a06557b6d45ac6aa9cb 100644 (file)
@@ -247,7 +247,7 @@ builtin_filter(PyObject *self, PyObject *args)
                return NULL;
 
        /* Strings and tuples return a result of the same type. */
-       if (PyBytes_Check(seq))
+       if (PyString_Check(seq))
                return filterstring(func, seq);
 #ifdef Py_USING_UNICODE
        if (PyUnicode_Check(seq))
@@ -381,7 +381,7 @@ builtin_chr(PyObject *self, PyObject *args)
                return NULL;
        }
        s[0] = (char)x;
-       return PyBytes_FromStringAndSize(s, 1);
+       return PyString_FromStringAndSize(s, 1);
 }
 
 PyDoc_STRVAR(chr_doc,
@@ -652,7 +652,7 @@ builtin_eval(PyObject *self, PyObject *args)
                return PyEval_EvalCode((PyCodeObject *) cmd, globals, locals);
        }
 
-       if (!PyBytes_Check(cmd) &&
+       if (!PyString_Check(cmd) &&
            !PyUnicode_Check(cmd)) {
                PyErr_SetString(PyExc_TypeError,
                           "eval() arg 1 must be a string or code object");
@@ -669,7 +669,7 @@ builtin_eval(PyObject *self, PyObject *args)
                cf.cf_flags |= PyCF_SOURCE_IS_UTF8;
        }
 #endif
-       if (PyBytes_AsStringAndSize(cmd, &str, NULL)) {
+       if (PyString_AsStringAndSize(cmd, &str, NULL)) {
                Py_XDECREF(tmp);
                return NULL;
        }
@@ -814,7 +814,7 @@ builtin_getattr(PyObject *self, PyObject *args)
        }
 #endif
 
-       if (!PyBytes_Check(name)) {
+       if (!PyString_Check(name)) {
                PyErr_SetString(PyExc_TypeError,
                                "getattr(): attribute name must be string");
                return NULL;
@@ -870,7 +870,7 @@ builtin_hasattr(PyObject *self, PyObject *args)
        }
 #endif
 
-       if (!PyBytes_Check(name)) {
+       if (!PyString_Check(name)) {
                PyErr_SetString(PyExc_TypeError,
                                "hasattr(): attribute name must be string");
                return NULL;
@@ -1189,7 +1189,7 @@ builtin_hex(PyObject *self, PyObject *v)
                return NULL;
        }
        res = (*nb->nb_hex)(v);
-       if (res && !PyBytes_Check(res)) {
+       if (res && !PyString_Check(res)) {
                PyErr_Format(PyExc_TypeError,
                             "__hex__ returned non-string (type %.200s)",
                             res->ob_type->tp_name);
@@ -1249,13 +1249,13 @@ builtin_intern(PyObject *self, PyObject *args)
        PyObject *s;
        if (!PyArg_ParseTuple(args, "S:intern", &s))
                return NULL;
-       if (!PyBytes_CheckExact(s)) {
+       if (!PyString_CheckExact(s)) {
                PyErr_SetString(PyExc_TypeError,
                                "can't intern subclass of string");
                return NULL;
        }
        Py_INCREF(s);
-       PyBytes_InternInPlace(&s);
+       PyString_InternInPlace(&s);
        return s;
 }
 
@@ -1457,7 +1457,7 @@ builtin_oct(PyObject *self, PyObject *v)
                return NULL;
        }
        res = (*nb->nb_oct)(v);
-       if (res && !PyBytes_Check(res)) {
+       if (res && !PyString_Check(res)) {
                PyErr_Format(PyExc_TypeError,
                             "__oct__ returned non-string (type %.200s)",
                             res->ob_type->tp_name);
@@ -1492,10 +1492,10 @@ builtin_ord(PyObject *self, PyObject* obj)
        long ord;
        Py_ssize_t size;
 
-       if (PyBytes_Check(obj)) {
-               size = PyBytes_GET_SIZE(obj);
+       if (PyString_Check(obj)) {
+               size = PyString_GET_SIZE(obj);
                if (size == 1) {
-                       ord = (long)((unsigned char)*PyBytes_AS_STRING(obj));
+                       ord = (long)((unsigned char)*PyString_AS_STRING(obj));
                        return PyInt_FromLong(ord);
                }
        } else if (PyByteArray_Check(obj)) {
@@ -1572,14 +1572,14 @@ builtin_print(PyObject *self, PyObject *args, PyObject *kwds)
                        Py_RETURN_NONE;
        }
 
-       if (sep && sep != Py_None && !PyBytes_Check(sep) &&
+       if (sep && sep != Py_None && !PyString_Check(sep) &&
             !PyUnicode_Check(sep)) {
                PyErr_Format(PyExc_TypeError,
                             "sep must be None, str or unicode, not %.200s",
                             sep->ob_type->tp_name);
                return NULL;
        }
-       if (end && end != Py_None && !PyBytes_Check(end) &&
+       if (end && end != Py_None && !PyString_Check(end) &&
            !PyUnicode_Check(end)) {
                PyErr_Format(PyExc_TypeError,
                             "end must be None, str or unicode, not %.200s",
@@ -1948,7 +1948,7 @@ builtin_raw_input(PyObject *self, PyObject *args)
                        po = PyObject_Str(v);
                        if (po == NULL)
                                return NULL;
-                       prompt = PyBytes_AsString(po);
+                       prompt = PyString_AsString(po);
                        if (prompt == NULL)
                                return NULL;
                }
@@ -1976,7 +1976,7 @@ builtin_raw_input(PyObject *self, PyObject *args)
                                result = NULL;
                        }
                        else {
-                               result = PyBytes_FromStringAndSize(s, len-1);
+                               result = PyString_FromStringAndSize(s, len-1);
                        }
                }
                PyMem_FREE(s);
@@ -2619,7 +2619,7 @@ _PyBuiltin_Init(void)
        SETBUILTIN("bool",              &PyBool_Type);
        /*      SETBUILTIN("memoryview",        &PyMemoryView_Type); */
        SETBUILTIN("bytearray",         &PyByteArray_Type);
-       SETBUILTIN("bytes",             &PyBytes_Type);
+       SETBUILTIN("bytes",             &PyString_Type);
        SETBUILTIN("buffer",            &PyBuffer_Type);
        SETBUILTIN("classmethod",       &PyClassMethod_Type);
 #ifndef WITHOUT_COMPLEX
@@ -2639,7 +2639,7 @@ _PyBuiltin_Init(void)
        SETBUILTIN("set",               &PySet_Type);
        SETBUILTIN("slice",             &PySlice_Type);
        SETBUILTIN("staticmethod",      &PyStaticMethod_Type);
-       SETBUILTIN("str",               &PyBytes_Type);
+       SETBUILTIN("str",               &PyString_Type);
        SETBUILTIN("super",             &PySuper_Type);
        SETBUILTIN("tuple",             &PyTuple_Type);
        SETBUILTIN("type",              &PyType_Type);
@@ -2737,7 +2737,7 @@ filterstring(PyObject *func, PyObject *strobj)
 {
        PyObject *result;
        Py_ssize_t i, j;
-       Py_ssize_t len = PyBytes_Size(strobj);
+       Py_ssize_t len = PyString_Size(strobj);
        Py_ssize_t outlen = len;
 
        if (func == Py_None) {
@@ -2745,12 +2745,12 @@ filterstring(PyObject *func, PyObject *strobj)
                 * as no character is ever false and __getitem__
                 * does return this character. If it's a subclass
                 * we must go through the __getitem__ loop */
-               if (PyBytes_CheckExact(strobj)) {
+               if (PyString_CheckExact(strobj)) {
                        Py_INCREF(strobj);
                        return strobj;
                }
        }
-       if ((result = PyBytes_FromStringAndSize(NULL, len)) == NULL)
+       if ((result = PyString_FromStringAndSize(NULL, len)) == NULL)
                return NULL;
 
        for (i = j = 0; i < len; ++i) {
@@ -2780,16 +2780,16 @@ filterstring(PyObject *func, PyObject *strobj)
                }
                if (ok) {
                        Py_ssize_t reslen;
-                       if (!PyBytes_Check(item)) {
+                       if (!PyString_Check(item)) {
                                PyErr_SetString(PyExc_TypeError, "can't filter str to str:"
                                        " __getitem__ returned different type");
                                Py_DECREF(item);
                                goto Fail_1;
                        }
-                       reslen = PyBytes_GET_SIZE(item);
+                       reslen = PyString_GET_SIZE(item);
                        if (reslen == 1) {
-                               PyBytes_AS_STRING(result)[j++] =
-                                       PyBytes_AS_STRING(item)[0];
+                               PyString_AS_STRING(result)[j++] =
+                                       PyString_AS_STRING(item)[0];
                        } else {
                                /* do we need more space? */
                                Py_ssize_t need = j + reslen + len-i-1;
@@ -2797,15 +2797,15 @@ filterstring(PyObject *func, PyObject *strobj)
                                        /* overallocate, to avoid reallocations */
                                        if (need<2*outlen)
                                                need = 2*outlen;
-                                       if (_PyBytes_Resize(&result, need)) {
+                                       if (_PyString_Resize(&result, need)) {
                                                Py_DECREF(item);
                                                return NULL;
                                        }
                                        outlen = need;
                                }
                                memcpy(
-                                       PyBytes_AS_STRING(result) + j,
-                                       PyBytes_AS_STRING(item),
+                                       PyString_AS_STRING(result) + j,
+                                       PyString_AS_STRING(item),
                                        reslen
                                );
                                j += reslen;
@@ -2815,7 +2815,7 @@ filterstring(PyObject *func, PyObject *strobj)
        }
 
        if (j < outlen)
-               _PyBytes_Resize(&result, j);
+               _PyString_Resize(&result, j);
 
        return result;
 
index bf48255b1db4aa33135ec6622b2407a4cb5e67a8..0cff157662fe78ffefe785a84c4c2a4b4a6de537 100644 (file)
@@ -739,7 +739,7 @@ PyEval_EvalFrameEx(PyFrameObject *f, int throwflag)
        consts = co->co_consts;
        fastlocals = f->f_localsplus;
        freevars = f->f_localsplus + co->co_nlocals;
-       first_instr = (unsigned char*) PyBytes_AS_STRING(co->co_code);
+       first_instr = (unsigned char*) PyString_AS_STRING(co->co_code);
        /* An explanation is in order for the next line.
 
           f->f_lasti now refers to the index of the last instruction
@@ -766,7 +766,7 @@ PyEval_EvalFrameEx(PyFrameObject *f, int throwflag)
        lltrace = PyDict_GetItemString(f->f_globals, "__lltrace__") != NULL;
 #endif
 #if defined(Py_DEBUG) || defined(LLTRACE)
-       filename = PyBytes_AsString(co->co_filename);
+       filename = PyString_AsString(co->co_filename);
 #endif
 
        why = WHY_NOT;
@@ -1147,8 +1147,8 @@ PyEval_EvalFrameEx(PyFrameObject *f, int throwflag)
                                        goto slow_add;
                                x = PyInt_FromLong(i);
                        }
-                       else if (PyBytes_CheckExact(v) &&
-                                PyBytes_CheckExact(w)) {
+                       else if (PyString_CheckExact(v) &&
+                                PyString_CheckExact(w)) {
                                x = string_concatenate(v, w, f, next_instr);
                                /* string_concatenate consumed the ref to v */
                                goto skip_decref_vx;
@@ -1349,8 +1349,8 @@ PyEval_EvalFrameEx(PyFrameObject *f, int throwflag)
                                        goto slow_iadd;
                                x = PyInt_FromLong(i);
                        }
-                       else if (PyBytes_CheckExact(v) &&
-                                PyBytes_CheckExact(w)) {
+                       else if (PyString_CheckExact(v) &&
+                                PyString_CheckExact(w)) {
                                x = string_concatenate(v, w, f, next_instr);
                                /* string_concatenate consumed the ref to v */
                                goto skip_decref_v;
@@ -1576,9 +1576,9 @@ PyEval_EvalFrameEx(PyFrameObject *f, int throwflag)
                                err = PyFile_WriteObject(v, w, Py_PRINT_RAW);
                        if (err == 0) {
                            /* XXX move into writeobject() ? */
-                           if (PyBytes_Check(v)) {
-                               char *s = PyBytes_AS_STRING(v);
-                               Py_ssize_t len = PyBytes_GET_SIZE(v);
+                           if (PyString_Check(v)) {
+                               char *s = PyString_AS_STRING(v);
+                               Py_ssize_t len = PyString_GET_SIZE(v);
                                if (len == 0 ||
                                    !isspace(Py_CHARMASK(s[len-1])) ||
                                    s[len-1] == ' ')
@@ -1705,7 +1705,7 @@ PyEval_EvalFrameEx(PyFrameObject *f, int throwflag)
                                        retval = POP();
                        }
                        else if (PyExceptionClass_Check(v) ||
-                                PyBytes_Check(v)) {
+                                PyString_Check(v)) {
                                w = POP();
                                u = POP();
                                PyErr_Restore(v, w, u);
@@ -1869,11 +1869,11 @@ PyEval_EvalFrameEx(PyFrameObject *f, int throwflag)
 
                case LOAD_GLOBAL:
                        w = GETITEM(names, oparg);
-                       if (PyBytes_CheckExact(w)) {
+                       if (PyString_CheckExact(w)) {
                                /* Inline the PyDict_GetItem() calls.
                                   WARNING: this is an extreme speed hack.
                                   Do not try this at home. */
-                               long hash = ((PyBytesObject *)w)->ob_shash;
+                               long hash = ((PyStringObject *)w)->ob_shash;
                                if (hash != -1) {
                                        PyDictObject *d;
                                        PyDictEntry *e;
@@ -2726,7 +2726,7 @@ PyEval_EvalCodeEx(PyCodeObject *co, PyObject *globals, PyObject *locals,
                                PyErr_Format(PyExc_TypeError,
                                    "%.200s() takes %s %d "
                                    "%sargument%s (%d given)",
-                                   PyBytes_AsString(co->co_name),
+                                   PyString_AsString(co->co_name),
                                    defcount ? "at most" : "exactly",
                                    co->co_argcount,
                                    kwcount ? "non-keyword " : "",
@@ -2756,10 +2756,10 @@ PyEval_EvalCodeEx(PyCodeObject *co, PyObject *globals, PyObject *locals,
                        PyObject *keyword = kws[2*i];
                        PyObject *value = kws[2*i + 1];
                        int j;
-                       if (keyword == NULL || !PyBytes_Check(keyword)) {
+                       if (keyword == NULL || !PyString_Check(keyword)) {
                                PyErr_Format(PyExc_TypeError,
                                    "%.200s() keywords must be strings",
-                                   PyBytes_AsString(co->co_name));
+                                   PyString_AsString(co->co_name));
                                goto fail;
                        }
                        /* XXX slow -- speed up using dictionary? */
@@ -2781,8 +2781,8 @@ PyEval_EvalCodeEx(PyCodeObject *co, PyObject *globals, PyObject *locals,
                                        PyErr_Format(PyExc_TypeError,
                                            "%.200s() got an unexpected "
                                            "keyword argument '%.400s'",
-                                           PyBytes_AsString(co->co_name),
-                                           PyBytes_AsString(keyword));
+                                           PyString_AsString(co->co_name),
+                                           PyString_AsString(keyword));
                                        goto fail;
                                }
                                PyDict_SetItem(kwdict, keyword, value);
@@ -2793,8 +2793,8 @@ PyEval_EvalCodeEx(PyCodeObject *co, PyObject *globals, PyObject *locals,
                                             "%.200s() got multiple "
                                             "values for keyword "
                                             "argument '%.400s'",
-                                            PyBytes_AsString(co->co_name),
-                                            PyBytes_AsString(keyword));
+                                            PyString_AsString(co->co_name),
+                                            PyString_AsString(keyword));
                                        goto fail;
                                }
                                Py_INCREF(value);
@@ -2808,7 +2808,7 @@ PyEval_EvalCodeEx(PyCodeObject *co, PyObject *globals, PyObject *locals,
                                        PyErr_Format(PyExc_TypeError,
                                            "%.200s() takes %s %d "
                                            "%sargument%s (%d given)",
-                                           PyBytes_AsString(co->co_name),
+                                           PyString_AsString(co->co_name),
                                            ((co->co_flags & CO_VARARGS) ||
                                             defcount) ? "at least"
                                                       : "exactly",
@@ -2834,7 +2834,7 @@ PyEval_EvalCodeEx(PyCodeObject *co, PyObject *globals, PyObject *locals,
                if (argcount > 0 || kwcount > 0) {
                        PyErr_Format(PyExc_TypeError,
                                     "%.200s() takes no arguments (%d given)",
-                                    PyBytes_AsString(co->co_name),
+                                    PyString_AsString(co->co_name),
                                     argcount + kwcount);
                        goto fail;
                }
@@ -2860,11 +2860,11 @@ PyEval_EvalCodeEx(PyCodeObject *co, PyObject *globals, PyObject *locals,
                   list so that we can march over it more efficiently?
                */
                for (i = 0; i < PyTuple_GET_SIZE(co->co_cellvars); ++i) {
-                       cellname = PyBytes_AS_STRING(
+                       cellname = PyString_AS_STRING(
                                PyTuple_GET_ITEM(co->co_cellvars, i));
                        found = 0;
                        for (j = 0; j < nargs; j++) {
-                               argname = PyBytes_AS_STRING(
+                               argname = PyString_AS_STRING(
                                        PyTuple_GET_ITEM(co->co_varnames, j));
                                if (strcmp(cellname, argname) == 0) {
                                        c = PyCell_New(GETLOCAL(j));
@@ -3522,13 +3522,13 @@ PyEval_GetFuncName(PyObject *func)
        if (PyMethod_Check(func))
                return PyEval_GetFuncName(PyMethod_GET_FUNCTION(func));
        else if (PyFunction_Check(func))
-               return PyBytes_AsString(((PyFunctionObject*)func)->func_name);
+               return PyString_AsString(((PyFunctionObject*)func)->func_name);
        else if (PyCFunction_Check(func))
                return ((PyCFunctionObject*)func)->m_ml->ml_name;
        else if (PyClass_Check(func))
-               return PyBytes_AsString(((PyClassObject*)func)->cl_name);
+               return PyString_AsString(((PyClassObject*)func)->cl_name);
        else if (PyInstance_Check(func)) {
-               return PyBytes_AsString(
+               return PyString_AsString(
                        ((PyInstanceObject*)func)->in_class->cl_name);
        } else {
                return func->ob_type->tp_name;
@@ -3767,7 +3767,7 @@ update_keyword_args(PyObject *orig_kwdict, int nk, PyObject ***pp_stack,
                                     "for keyword argument '%.200s'",
                                     PyEval_GetFuncName(func),
                                     PyEval_GetFuncDesc(func),
-                                    PyBytes_AsString(key));
+                                    PyString_AsString(key));
                        Py_DECREF(key);
                        Py_DECREF(value);
                        Py_DECREF(kwdict);
@@ -4086,7 +4086,7 @@ cmp_outcome(int op, register PyObject *v, register PyObject *w)
                        length = PyTuple_Size(w);
                        for (i = 0; i < length; i += 1) {
                                PyObject *exc = PyTuple_GET_ITEM(w, i);
-                               if (PyBytes_Check(exc)) {
+                               if (PyString_Check(exc)) {
                                        int ret_val;
                                        ret_val = PyErr_WarnEx(
                                                PyExc_DeprecationWarning,
@@ -4109,7 +4109,7 @@ cmp_outcome(int op, register PyObject *v, register PyObject *w)
                        }
                }
                else {
-                       if (PyBytes_Check(w)) {
+                       if (PyString_Check(w)) {
                                int ret_val;
                                ret_val = PyErr_WarnEx(
                                                PyExc_DeprecationWarning,
@@ -4149,7 +4149,7 @@ import_from(PyObject *v, PyObject *name)
        if (x == NULL && PyErr_ExceptionMatches(PyExc_AttributeError)) {
                PyErr_Format(PyExc_ImportError,
                             "cannot import name %.230s",
-                            PyBytes_AsString(name));
+                            PyString_AsString(name));
        }
        return x;
 }
@@ -4191,8 +4191,8 @@ import_all_from(PyObject *locals, PyObject *v)
                        break;
                }
                if (skip_leading_underscores &&
-                   PyBytes_Check(name) &&
-                   PyBytes_AS_STRING(name)[0] == '_')
+                   PyString_Check(name) &&
+                   PyString_AS_STRING(name)[0] == '_')
                {
                        Py_DECREF(name);
                        continue;
@@ -4251,12 +4251,12 @@ build_class(PyObject *methods, PyObject *bases, PyObject *name)
                PyObject *ptype, *pvalue, *ptraceback;
 
                PyErr_Fetch(&ptype, &pvalue, &ptraceback);
-               if (PyBytes_Check(pvalue)) {
+               if (PyString_Check(pvalue)) {
                        PyObject *newmsg;
-                       newmsg = PyBytes_FromFormat(
+                       newmsg = PyString_FromFormat(
                                "Error when calling the metaclass bases\n"
                                "    %s",
-                               PyBytes_AS_STRING(pvalue));
+                               PyString_AS_STRING(pvalue));
                        if (newmsg != NULL) {
                                Py_DECREF(pvalue);
                                pvalue = newmsg;
@@ -4297,7 +4297,7 @@ exec_statement(PyFrameObject *f, PyObject *prog, PyObject *globals,
        }
        else if (locals == Py_None)
                locals = globals;
-       if (!PyBytes_Check(prog) &&
+       if (!PyString_Check(prog) &&
            !PyUnicode_Check(prog) &&
            !PyCode_Check(prog) &&
            !PyFile_Check(prog)) {
@@ -4327,7 +4327,7 @@ exec_statement(PyFrameObject *f, PyObject *prog, PyObject *globals,
        }
        else if (PyFile_Check(prog)) {
                FILE *fp = PyFile_AsFile(prog);
-               char *name = PyBytes_AsString(PyFile_Name(prog));
+               char *name = PyString_AsString(PyFile_Name(prog));
                PyCompilerFlags cf;
                if (name == NULL)
                        return -1;
@@ -4353,7 +4353,7 @@ exec_statement(PyFrameObject *f, PyObject *prog, PyObject *globals,
                        cf.cf_flags |= PyCF_SOURCE_IS_UTF8;
                }
 #endif
-               if (PyBytes_AsStringAndSize(prog, &str, NULL))
+               if (PyString_AsStringAndSize(prog, &str, NULL))
                        return -1;
                if (PyEval_MergeCompilerFlags(&cf))
                        v = PyRun_StringFlags(str, Py_file_input, globals,
@@ -4378,7 +4378,7 @@ format_exc_check_arg(PyObject *exc, char *format_str, PyObject *obj)
        if (!obj)
                return;
 
-       obj_str = PyBytes_AsString(obj);
+       obj_str = PyString_AsString(obj);
        if (!obj_str)
                return;
 
@@ -4391,8 +4391,8 @@ string_concatenate(PyObject *v, PyObject *w,
 {
        /* This function implements 'variable += expr' when both arguments
           are strings. */
-       Py_ssize_t v_len = PyBytes_GET_SIZE(v);
-       Py_ssize_t w_len = PyBytes_GET_SIZE(w);
+       Py_ssize_t v_len = PyString_GET_SIZE(v);
+       Py_ssize_t w_len = PyString_GET_SIZE(w);
        Py_ssize_t new_len = v_len + w_len;
        if (new_len < 0) {
                PyErr_SetString(PyExc_OverflowError,
@@ -4441,12 +4441,12 @@ string_concatenate(PyObject *v, PyObject *w,
                }
        }
 
-       if (v->ob_refcnt == 1 && !PyBytes_CHECK_INTERNED(v)) {
+       if (v->ob_refcnt == 1 && !PyString_CHECK_INTERNED(v)) {
                /* Now we own the last reference to 'v', so we can resize it
                 * in-place.
                 */
-               if (_PyBytes_Resize(&v, new_len) != 0) {
-                       /* XXX if _PyBytes_Resize() fails, 'v' has been
+               if (_PyString_Resize(&v, new_len) != 0) {
+                       /* XXX if _PyString_Resize() fails, 'v' has been
                         * deallocated so it cannot be put back into
                         * 'variable'.  The MemoryError is raised when there
                         * is no value in 'variable', which might (very
@@ -4455,13 +4455,13 @@ string_concatenate(PyObject *v, PyObject *w,
                        return NULL;
                }
                /* copy 'w' into the newly allocated area of 'v' */
-               memcpy(PyBytes_AS_STRING(v) + v_len,
-                      PyBytes_AS_STRING(w), w_len);
+               memcpy(PyString_AS_STRING(v) + v_len,
+                      PyString_AS_STRING(w), w_len);
                return v;
        }
        else {
                /* When in-place resizing is not an option. */
-               PyBytes_Concat(&v, w);
+               PyString_Concat(&v, w);
                return v;
        }
 }
index 0e8cdc74d77f419740241819baa25aec254318ce..4b0f4cb0d04f91771d4ee617f2f0a4e380321fe2 100644 (file)
@@ -61,10 +61,10 @@ PyObject *normalizestring(const char *string)
        return NULL;
     }
        
-    v = PyBytes_FromStringAndSize(NULL, len);
+    v = PyString_FromStringAndSize(NULL, len);
     if (v == NULL)
        return NULL;
-    p = PyBytes_AS_STRING(v);
+    p = PyString_AS_STRING(v);
     for (i = 0; i < len; i++) {
         register char ch = string[i];
         if (ch == ' ')
@@ -112,7 +112,7 @@ PyObject *_PyCodec_Lookup(const char *encoding)
     v = normalizestring(encoding);
     if (v == NULL)
        goto onError;
-    PyBytes_InternInPlace(&v);
+    PyString_InternInPlace(&v);
 
     /* First, try to lookup the name in the registry dictionary */
     result = PyDict_GetItem(interp->codec_search_cache, v);
@@ -190,7 +190,7 @@ PyObject *args_tuple(PyObject *object,
     if (errors) {
        PyObject *v;
        
-       v = PyBytes_FromString(errors);
+       v = PyString_FromString(errors);
        if (v == NULL) {
            Py_DECREF(args);
            return NULL;
@@ -451,7 +451,7 @@ static void wrong_exception_type(PyObject *exc)
            if (string != NULL) {
                PyErr_Format(PyExc_TypeError,
                    "don't know how to handle %.400s in error callback",
-                   PyBytes_AS_STRING(string));
+                   PyString_AS_STRING(string));
                Py_DECREF(string);
            }
        }
index 5092acc141289d92d4a975f19713474820fdc1b0..c81218d0326cb647897ae35f657ba942c506cc8e 100644 (file)
@@ -184,15 +184,15 @@ _Py_Mangle(PyObject *privateobj, PyObject *ident)
 {
        /* Name mangling: __private becomes _classname__private.
           This is independent from how the name is used. */
-       const char *p, *name = PyBytes_AsString(ident);
+       const char *p, *name = PyString_AsString(ident);
        char *buffer;
        size_t nlen, plen;
-       if (privateobj == NULL || !PyBytes_Check(privateobj) ||
+       if (privateobj == NULL || !PyString_Check(privateobj) ||
            name == NULL || name[0] != '_' || name[1] != '_') {
                Py_INCREF(ident);
                return ident;
        }
-       p = PyBytes_AsString(privateobj);
+       p = PyString_AsString(privateobj);
        nlen = strlen(name);
        /* Don't mangle __id__ or names with dots.
 
@@ -216,11 +216,11 @@ _Py_Mangle(PyObject *privateobj, PyObject *ident)
                return ident; /* Don't mangle if class is just underscores */
        }
        plen = strlen(p);
-       ident = PyBytes_FromStringAndSize(NULL, 1 + nlen + plen);
+       ident = PyString_FromStringAndSize(NULL, 1 + nlen + plen);
        if (!ident)
                return 0;
        /* ident = "_" + p[:plen] + name # i.e. 1+plen+nlen bytes */
-       buffer = PyBytes_AS_STRING(ident);
+       buffer = PyString_AS_STRING(ident);
        buffer[0] = '_';
        strncpy(buffer+1, p, plen);
        strcpy(buffer+1+plen, name);
@@ -249,7 +249,7 @@ PyAST_Compile(mod_ty mod, const char *filename, PyCompilerFlags *flags,
        int merged;
 
        if (!__doc__) {
-               __doc__ = PyBytes_InternFromString("__doc__");
+               __doc__ = PyString_InternFromString("__doc__");
                if (!__doc__)
                        return NULL;
        }
@@ -540,7 +540,7 @@ compiler_new_tmpname(struct compiler *c)
 {
        char tmpname[256];
        PyOS_snprintf(tmpname, sizeof(tmpname), "_[%d]", ++c->u->u_tmpname);
-       return PyBytes_FromString(tmpname);
+       return PyString_FromString(tmpname);
 }
 
 /* Allocate a new block and return a pointer to it.
@@ -1193,7 +1193,7 @@ compiler_mod(struct compiler *c, mod_ty mod)
        int addNone = 1;
        static PyObject *module;
        if (!module) {
-               module = PyBytes_InternFromString("<module>");
+               module = PyString_InternFromString("<module>");
                if (!module)
                        return NULL;
        }
@@ -1245,8 +1245,8 @@ get_ref_type(struct compiler *c, PyObject *name)
            PyOS_snprintf(buf, sizeof(buf),
                          "unknown scope for %.100s in %.100s(%s) in %s\n"
                          "symbols: %s\nlocals: %s\nglobals: %s\n",
-                         PyBytes_AS_STRING(name), 
-                         PyBytes_AS_STRING(c->u->u_name), 
+                         PyString_AS_STRING(name), 
+                         PyString_AS_STRING(c->u->u_name), 
                          PyObject_REPR(c->u->u_ste->ste_id),
                          c->c_filename,
                          PyObject_REPR(c->u->u_ste->ste_symbols),
@@ -1304,9 +1304,9 @@ compiler_make_closure(struct compiler *c, PyCodeObject *co, int args)
                        printf("lookup %s in %s %d %d\n"
                                "freevars of %s: %s\n",
                                PyObject_REPR(name), 
-                               PyBytes_AS_STRING(c->u->u_name), 
+                               PyString_AS_STRING(c->u->u_name), 
                                reftype, arg,
-                               PyBytes_AS_STRING(co->co_name),
+                               PyString_AS_STRING(co->co_name),
                                PyObject_REPR(co->co_freevars));
                        Py_FatalError("compiler_make_closure()");
                }
@@ -1341,7 +1341,7 @@ compiler_arguments(struct compiler *c, arguments_ty args)
        for (i = 0; i < n; i++) {
                expr_ty arg = (expr_ty)asdl_seq_GET(args->args, i);
                if (arg->kind == Tuple_kind) {
-                       PyObject *id = PyBytes_FromFormat(".%d", i);
+                       PyObject *id = PyString_FromFormat(".%d", i);
                        if (id == NULL) {
                                return 0;
                        }
@@ -1434,7 +1434,7 @@ compiler_class(struct compiler *c, stmt_ty s)
        Py_XDECREF(c->u->u_private);
        c->u->u_private = s->v.ClassDef.name;
        Py_INCREF(c->u->u_private);
-       str = PyBytes_InternFromString("__name__");
+       str = PyString_InternFromString("__name__");
        if (!str || !compiler_nameop(c, str, Load)) {
                Py_XDECREF(str);
                compiler_exit_scope(c);
@@ -1442,7 +1442,7 @@ compiler_class(struct compiler *c, stmt_ty s)
        }
        
        Py_DECREF(str);
-       str = PyBytes_InternFromString("__module__");
+       str = PyString_InternFromString("__module__");
        if (!str || !compiler_nameop(c, str, Store)) {
                Py_XDECREF(str);
                compiler_exit_scope(c);
@@ -1509,7 +1509,7 @@ compiler_lambda(struct compiler *c, expr_ty e)
        assert(e->kind == Lambda_kind);
 
        if (!name) {
-               name = PyBytes_InternFromString("<lambda>");
+               name = PyString_InternFromString("<lambda>");
                if (!name)
                        return 0;
        }
@@ -1899,7 +1899,7 @@ compiler_import_as(struct compiler *c, identifier name, identifier asname)
           If there is a dot in name, we need to split it and emit a 
           LOAD_ATTR for each name.
        */
-       const char *src = PyBytes_AS_STRING(name);
+       const char *src = PyString_AS_STRING(name);
        const char *dot = strchr(src, '.');
        if (dot) {
                /* Consume the base module name to get the first attribute */
@@ -1908,7 +1908,7 @@ compiler_import_as(struct compiler *c, identifier name, identifier asname)
                        /* NB src is only defined when dot != NULL */
                        PyObject *attr;
                        dot = strchr(src, '.');
-                       attr = PyBytes_FromStringAndSize(src, 
+                       attr = PyString_FromStringAndSize(src, 
                                            dot ? dot - src : strlen(src));
                        if (!attr)
                                return -1;
@@ -1957,10 +1957,10 @@ compiler_import(struct compiler *c, stmt_ty s)
                }
                else {
                        identifier tmp = alias->name;
-                       const char *base = PyBytes_AS_STRING(alias->name);
+                       const char *base = PyString_AS_STRING(alias->name);
                        char *dot = strchr(base, '.');
                        if (dot)
-                               tmp = PyBytes_FromStringAndSize(base, 
+                               tmp = PyString_FromStringAndSize(base, 
                                                                 dot - base);
                        r = compiler_nameop(c, tmp, Store);
                        if (dot) {
@@ -2003,7 +2003,7 @@ compiler_from_import(struct compiler *c, stmt_ty s)
        }
 
        if (s->lineno > c->c_future->ff_lineno) {
-               if (!strcmp(PyBytes_AS_STRING(s->v.ImportFrom.module),
+               if (!strcmp(PyString_AS_STRING(s->v.ImportFrom.module),
                            "__future__")) {
                        Py_DECREF(level);
                        Py_DECREF(names);
@@ -2023,7 +2023,7 @@ compiler_from_import(struct compiler *c, stmt_ty s)
                alias_ty alias = (alias_ty)asdl_seq_GET(s->v.ImportFrom.names, i);
                identifier store_name;
 
-               if (i == 0 && *PyBytes_AS_STRING(alias->name) == '*') {
+               if (i == 0 && *PyString_AS_STRING(alias->name) == '*') {
                        assert(n == 1);
                        ADDOP(c, IMPORT_STAR);
                        return 1;
@@ -2053,7 +2053,7 @@ compiler_assert(struct compiler *c, stmt_ty s)
        if (Py_OptimizeFlag)
                return 1;
        if (assertion_error == NULL) {
-               assertion_error = PyBytes_InternFromString("AssertionError");
+               assertion_error = PyString_InternFromString("AssertionError");
                if (assertion_error == NULL)
                        return 0;
        }
@@ -2336,7 +2336,7 @@ compiler_nameop(struct compiler *c, identifier name, expr_context_ty ctx)
 
        /* First check for assignment to __debug__. Param? */
        if ((ctx == Store || ctx == AugStore || ctx == Del)
-           && !strcmp(PyBytes_AS_STRING(name), "__debug__")) {
+           && !strcmp(PyString_AS_STRING(name), "__debug__")) {
                return compiler_error(c, "can not assign to __debug__");
        }
 
@@ -2374,7 +2374,7 @@ compiler_nameop(struct compiler *c, identifier name, expr_context_ty ctx)
        }
 
        /* XXX Leave assert here, but handle __doc__ and the like better */
-       assert(scope || PyBytes_AS_STRING(name)[0] == '_');
+       assert(scope || PyString_AS_STRING(name)[0] == '_');
 
        switch (optype) {
        case OP_DEREF:
@@ -2388,7 +2388,7 @@ compiler_nameop(struct compiler *c, identifier name, expr_context_ty ctx)
                        PyErr_Format(PyExc_SyntaxError,
                                     "can not delete variable '%s' referenced "
                                     "in nested scope",
-                                    PyBytes_AS_STRING(name));
+                                    PyString_AS_STRING(name));
                        Py_DECREF(mangled);
                        return 0;
                case Param:
@@ -2773,7 +2773,7 @@ compiler_genexp(struct compiler *c, expr_ty e)
                                               0)))->iter;
 
        if (!name) {
-               name = PyBytes_FromString("<genexpr>");
+               name = PyString_FromString("<genexpr>");
                if (!name)
                        return 0;
        }
@@ -2822,7 +2822,7 @@ expr_constant(expr_ty e)
        case Name_kind:
                /* __debug__ is not assignable, so we can optimize
                 * it away in if and while statements */
-               if (strcmp(PyBytes_AS_STRING(e->v.Name.id),
+               if (strcmp(PyString_AS_STRING(e->v.Name.id),
                           "__debug__") == 0)
                           return ! Py_OptimizeFlag;
                /* fall through */
@@ -2864,12 +2864,12 @@ compiler_with(struct compiler *c, stmt_ty s)
     assert(s->kind == With_kind);
 
     if (!enter_attr) {
-       enter_attr = PyBytes_InternFromString("__enter__");
+       enter_attr = PyString_InternFromString("__enter__");
        if (!enter_attr)
            return 0;
     }
     if (!exit_attr) {
-       exit_attr = PyBytes_InternFromString("__exit__");
+       exit_attr = PyString_InternFromString("__exit__");
        if (!exit_attr)
            return 0;
     }
@@ -3472,10 +3472,10 @@ assemble_init(struct assembler *a, int nblocks, int firstlineno)
 {
        memset(a, 0, sizeof(struct assembler));
        a->a_lineno = firstlineno;
-       a->a_bytecode = PyBytes_FromStringAndSize(NULL, DEFAULT_CODE_SIZE);
+       a->a_bytecode = PyString_FromStringAndSize(NULL, DEFAULT_CODE_SIZE);
        if (!a->a_bytecode)
                return 0;
-       a->a_lnotab = PyBytes_FromStringAndSize(NULL, DEFAULT_LNOTAB_SIZE);
+       a->a_lnotab = PyString_FromStringAndSize(NULL, DEFAULT_LNOTAB_SIZE);
        if (!a->a_lnotab)
                return 0;
        a->a_postorder = (basicblock **)PyObject_Malloc(
@@ -3584,17 +3584,17 @@ assemble_lnotab(struct assembler *a, struct instr *i)
        if (d_bytecode > 255) {
                int j, nbytes, ncodes = d_bytecode / 255;
                nbytes = a->a_lnotab_off + 2 * ncodes;
-               len = PyBytes_GET_SIZE(a->a_lnotab);
+               len = PyString_GET_SIZE(a->a_lnotab);
                if (nbytes >= len) {
                        if (len * 2 < nbytes)
                                len = nbytes;
                        else
                                len *= 2;
-                       if (_PyBytes_Resize(&a->a_lnotab, len) < 0)
+                       if (_PyString_Resize(&a->a_lnotab, len) < 0)
                                return 0;
                }
                lnotab = (unsigned char *)
-                          PyBytes_AS_STRING(a->a_lnotab) + a->a_lnotab_off;
+                          PyString_AS_STRING(a->a_lnotab) + a->a_lnotab_off;
                for (j = 0; j < ncodes; j++) {
                        *lnotab++ = 255;
                        *lnotab++ = 0;
@@ -3606,17 +3606,17 @@ assemble_lnotab(struct assembler *a, struct instr *i)
        if (d_lineno > 255) {
                int j, nbytes, ncodes = d_lineno / 255;
                nbytes = a->a_lnotab_off + 2 * ncodes;
-               len = PyBytes_GET_SIZE(a->a_lnotab);
+               len = PyString_GET_SIZE(a->a_lnotab);
                if (nbytes >= len) {
                        if (len * 2 < nbytes)
                                len = nbytes;
                        else
                                len *= 2;
-                       if (_PyBytes_Resize(&a->a_lnotab, len) < 0)
+                       if (_PyString_Resize(&a->a_lnotab, len) < 0)
                                return 0;
                }
                lnotab = (unsigned char *)
-                          PyBytes_AS_STRING(a->a_lnotab) + a->a_lnotab_off;
+                          PyString_AS_STRING(a->a_lnotab) + a->a_lnotab_off;
                *lnotab++ = d_bytecode;
                *lnotab++ = 255;
                d_bytecode = 0;
@@ -3628,13 +3628,13 @@ assemble_lnotab(struct assembler *a, struct instr *i)
                a->a_lnotab_off += ncodes * 2;
        }
 
-       len = PyBytes_GET_SIZE(a->a_lnotab);
+       len = PyString_GET_SIZE(a->a_lnotab);
        if (a->a_lnotab_off + 2 >= len) {
-               if (_PyBytes_Resize(&a->a_lnotab, len * 2) < 0)
+               if (_PyString_Resize(&a->a_lnotab, len * 2) < 0)
                        return 0;
        }
        lnotab = (unsigned char *)
-                       PyBytes_AS_STRING(a->a_lnotab) + a->a_lnotab_off;
+                       PyString_AS_STRING(a->a_lnotab) + a->a_lnotab_off;
 
        a->a_lnotab_off += 2;
        if (d_bytecode) {
@@ -3659,7 +3659,7 @@ static int
 assemble_emit(struct assembler *a, struct instr *i)
 {
        int size, arg = 0, ext = 0;
-       Py_ssize_t len = PyBytes_GET_SIZE(a->a_bytecode);
+       Py_ssize_t len = PyString_GET_SIZE(a->a_bytecode);
        char *code;
 
        size = instrsize(i);
@@ -3670,10 +3670,10 @@ assemble_emit(struct assembler *a, struct instr *i)
        if (i->i_lineno && !assemble_lnotab(a, i))
                return 0;
        if (a->a_offset + size >= len) {
-               if (_PyBytes_Resize(&a->a_bytecode, len * 2) < 0)
+               if (_PyString_Resize(&a->a_bytecode, len * 2) < 0)
                    return 0;
        }
-       code = PyBytes_AS_STRING(a->a_bytecode) + a->a_offset;
+       code = PyString_AS_STRING(a->a_bytecode) + a->a_offset;
        a->a_offset += size;
        if (size == 6) {
                assert(i->i_hasarg);
@@ -3846,7 +3846,7 @@ makecode(struct compiler *c, struct assembler *a)
        freevars = dict_keys_inorder(c->u->u_freevars, PyTuple_Size(cellvars));
        if (!freevars)
            goto error;
-       filename = PyBytes_FromString(c->c_filename);
+       filename = PyString_FromString(c->c_filename);
        if (!filename)
                goto error;
 
@@ -3966,9 +3966,9 @@ assemble(struct compiler *c, int addNone)
                                goto error;
        }
 
-       if (_PyBytes_Resize(&a.a_lnotab, a.a_lnotab_off) < 0)
+       if (_PyString_Resize(&a.a_lnotab, a.a_lnotab_off) < 0)
                goto error;
-       if (_PyBytes_Resize(&a.a_bytecode, a.a_offset) < 0)
+       if (_PyString_Resize(&a.a_bytecode, a.a_offset) < 0)
                goto error;
 
        co = makecode(c, &a);
index 8b04c34b06c56e356024aed9560b6a1a624d5238..8951d5793548573a2ed7a9c7fc2ee407a8a2b83c 100644 (file)
@@ -66,7 +66,7 @@ PyErr_SetNone(PyObject *exception)
 void
 PyErr_SetString(PyObject *exception, const char *string)
 {
-       PyObject *value = PyBytes_FromString(string);
+       PyObject *value = PyString_FromString(string);
        PyErr_SetObject(exception, value);
        Py_XDECREF(value);
 }
@@ -351,7 +351,7 @@ PyErr_SetFromErrnoWithFilenameObject(PyObject *exc, PyObject *filenameObject)
 PyObject *
 PyErr_SetFromErrnoWithFilename(PyObject *exc, char *filename)
 {
-       PyObject *name = filename ? PyBytes_FromString(filename) : NULL;
+       PyObject *name = filename ? PyString_FromString(filename) : NULL;
        PyObject *result = PyErr_SetFromErrnoWithFilenameObject(exc, name);
        Py_XDECREF(name);
        return result;
@@ -430,7 +430,7 @@ PyObject *PyErr_SetExcFromWindowsErrWithFilename(
        int ierr,
        const char *filename)
 {
-       PyObject *name = filename ? PyBytes_FromString(filename) : NULL;
+       PyObject *name = filename ? PyString_FromString(filename) : NULL;
        PyObject *ret = PyErr_SetExcFromWindowsErrWithFilenameObject(exc,
                                                                     ierr,
                                                                     name);
@@ -469,7 +469,7 @@ PyObject *PyErr_SetFromWindowsErrWithFilename(
        int ierr,
        const char *filename)
 {
-       PyObject *name = filename ? PyBytes_FromString(filename) : NULL;
+       PyObject *name = filename ? PyString_FromString(filename) : NULL;
        PyObject *result = PyErr_SetExcFromWindowsErrWithFilenameObject(
                                                      PyExc_WindowsError,
                                                      ierr, name);
@@ -527,7 +527,7 @@ PyErr_Format(PyObject *exception, const char *format, ...)
        va_start(vargs);
 #endif
 
-       string = PyBytes_FromFormatV(format, vargs);
+       string = PyString_FromFormatV(format, vargs);
        PyErr_SetObject(exception, string);
        Py_XDECREF(string);
        va_end(vargs);
@@ -559,7 +559,7 @@ PyErr_NewException(char *name, PyObject *base, PyObject *dict)
                        goto failure;
        }
        if (PyDict_GetItemString(dict, "__module__") == NULL) {
-               modulename = PyBytes_FromStringAndSize(name,
+               modulename = PyString_FromStringAndSize(name,
                                                     (Py_ssize_t)(dot-name));
                if (modulename == NULL)
                        goto failure;
@@ -611,7 +611,7 @@ PyErr_WriteUnraisable(PyObject *obj)
                        if (moduleName == NULL)
                                PyFile_WriteString("<unknown>", f);
                        else {
-                               char* modstr = PyBytes_AsString(moduleName);
+                               char* modstr = PyString_AsString(moduleName);
                                if (modstr &&
                                    strcmp(modstr, "exceptions") != 0)
                                {
@@ -665,7 +665,7 @@ PyErr_SyntaxLocation(const char *filename, int lineno)
                Py_DECREF(tmp);
        }
        if (filename != NULL) {
-               tmp = PyBytes_FromString(filename);
+               tmp = PyString_FromString(filename);
                if (tmp == NULL)
                        PyErr_Clear();
                else {
@@ -742,7 +742,7 @@ PyErr_ProgramText(const char *filename, int lineno)
                char *p = linebuf;
                while (*p == ' ' || *p == '\t' || *p == '\014')
                        p++;
-               return PyBytes_FromString(p);
+               return PyString_FromString(p);
        }
        return NULL;
 }
index ba058b83cef3899e235d4f201ef6943b88ea976f..2c6aaa2294819e5875a57e83708c893502c836c4 100644 (file)
@@ -20,7 +20,7 @@ future_check_features(PyFutureFeatures *ff, stmt_ty s, const char *filename)
        names = s->v.ImportFrom.names;
        for (i = 0; i < asdl_seq_LEN(names); i++) {
                 alias_ty name = (alias_ty)asdl_seq_GET(names, i);
-               const char *feature = PyBytes_AsString(name->name);
+               const char *feature = PyString_AsString(name->name);
                if (!feature)
                        return 0;
                if (strcmp(feature, FUTURE_NESTED_SCOPES) == 0) {
@@ -59,7 +59,7 @@ future_parse(PyFutureFeatures *ff, mod_ty mod, const char *filename)
 
        static PyObject *future;
        if (!future) {
-               future = PyBytes_InternFromString("__future__");
+               future = PyString_InternFromString("__future__");
                if (!future)
                        return 0;
        }
index 3b8950c0ba7f556d6bca2e81c4c5f7c02fa2997b..162cf6fa98acaca1e93628e7ebc7bbfc021fd169 100644 (file)
@@ -418,7 +418,7 @@ converttuple(PyObject *arg, const char **p_format, va_list *p_va, int flags,
                        n++;
        }
        
-       if (!PySequence_Check(arg) || PyBytes_Check(arg)) {
+       if (!PySequence_Check(arg) || PyString_Check(arg)) {
                levels[0] = 0;
                PyOS_snprintf(msgbuf, bufsize,
                              toplevel ? "expected %d arguments, not %.50s" :
@@ -765,8 +765,8 @@ convertsimple(PyObject *arg, const char **p_format, va_list *p_va, int flags,
        
        case 'c': {/* char */
                char *p = va_arg(*p_va, char *);
-               if (PyBytes_Check(arg) && PyBytes_Size(arg) == 1)
-                       *p = PyBytes_AS_STRING(arg)[0];
+               if (PyString_Check(arg) && PyString_Size(arg) == 1)
+                       *p = PyString_AS_STRING(arg)[0];
                else
                        return converterr("char", arg, msgbuf, bufsize);
                break;
@@ -777,9 +777,9 @@ convertsimple(PyObject *arg, const char **p_format, va_list *p_va, int flags,
                        void **p = (void **)va_arg(*p_va, char **);
                        FETCH_SIZE;
                        
-                       if (PyBytes_Check(arg)) {
-                               *p = PyBytes_AS_STRING(arg);
-                               STORE_SIZE(PyBytes_GET_SIZE(arg));
+                       if (PyString_Check(arg)) {
+                               *p = PyString_AS_STRING(arg);
+                               STORE_SIZE(PyString_GET_SIZE(arg));
                        }
 #ifdef Py_USING_UNICODE
                        else if (PyUnicode_Check(arg)) {
@@ -787,8 +787,8 @@ convertsimple(PyObject *arg, const char **p_format, va_list *p_va, int flags,
                                if (uarg == NULL)
                                        return converterr(CONV_UNICODE,
                                                          arg, msgbuf, bufsize);
-                               *p = PyBytes_AS_STRING(uarg);
-                               STORE_SIZE(PyBytes_GET_SIZE(uarg));
+                               *p = PyString_AS_STRING(uarg);
+                               STORE_SIZE(PyString_GET_SIZE(uarg));
                        }
 #endif
                        else { /* any buffer-like object */
@@ -802,20 +802,20 @@ convertsimple(PyObject *arg, const char **p_format, va_list *p_va, int flags,
                } else {
                        char **p = va_arg(*p_va, char **);
                        
-                       if (PyBytes_Check(arg))
-                               *p = PyBytes_AS_STRING(arg);
+                       if (PyString_Check(arg))
+                               *p = PyString_AS_STRING(arg);
 #ifdef Py_USING_UNICODE
                        else if (PyUnicode_Check(arg)) {
                                uarg = UNICODE_DEFAULT_ENCODING(arg);
                                if (uarg == NULL)
                                        return converterr(CONV_UNICODE,
                                                          arg, msgbuf, bufsize);
-                               *p = PyBytes_AS_STRING(uarg);
+                               *p = PyString_AS_STRING(uarg);
                        }
 #endif
                        else
                                return converterr("string", arg, msgbuf, bufsize);
-                       if ((Py_ssize_t)strlen(*p) != PyBytes_Size(arg))
+                       if ((Py_ssize_t)strlen(*p) != PyString_Size(arg))
                                return converterr("string without null bytes",
                                                  arg, msgbuf, bufsize);
                }
@@ -831,9 +831,9 @@ convertsimple(PyObject *arg, const char **p_format, va_list *p_va, int flags,
                                *p = 0;
                                STORE_SIZE(0);
                        }
-                       else if (PyBytes_Check(arg)) {
-                               *p = PyBytes_AS_STRING(arg);
-                               STORE_SIZE(PyBytes_GET_SIZE(arg));
+                       else if (PyString_Check(arg)) {
+                               *p = PyString_AS_STRING(arg);
+                               STORE_SIZE(PyString_GET_SIZE(arg));
                        }
 #ifdef Py_USING_UNICODE
                        else if (PyUnicode_Check(arg)) {
@@ -841,8 +841,8 @@ convertsimple(PyObject *arg, const char **p_format, va_list *p_va, int flags,
                                if (uarg == NULL)
                                        return converterr(CONV_UNICODE,
                                                          arg, msgbuf, bufsize);
-                               *p = PyBytes_AS_STRING(uarg);
-                               STORE_SIZE(PyBytes_GET_SIZE(uarg));
+                               *p = PyString_AS_STRING(uarg);
+                               STORE_SIZE(PyString_GET_SIZE(uarg));
                        }
 #endif
                        else { /* any buffer-like object */
@@ -858,15 +858,15 @@ convertsimple(PyObject *arg, const char **p_format, va_list *p_va, int flags,
                        
                        if (arg == Py_None)
                                *p = 0;
-                       else if (PyBytes_Check(arg))
-                               *p = PyBytes_AS_STRING(arg);
+                       else if (PyString_Check(arg))
+                               *p = PyString_AS_STRING(arg);
 #ifdef Py_USING_UNICODE
                        else if (PyUnicode_Check(arg)) {
                                uarg = UNICODE_DEFAULT_ENCODING(arg);
                                if (uarg == NULL)
                                        return converterr(CONV_UNICODE,
                                                          arg, msgbuf, bufsize);
-                               *p = PyBytes_AS_STRING(uarg);
+                               *p = PyString_AS_STRING(uarg);
                        }
 #endif
                        else
@@ -878,11 +878,11 @@ convertsimple(PyObject *arg, const char **p_format, va_list *p_va, int flags,
                                if (arg == Py_None)
                                        *q = 0;
                                else
-                                       *q = PyBytes_Size(arg);
+                                       *q = PyString_Size(arg);
                                format++;
                        }
                        else if (*p != NULL &&
-                                (Py_ssize_t)strlen(*p) != PyBytes_Size(arg))
+                                (Py_ssize_t)strlen(*p) != PyString_Size(arg))
                                return converterr(
                                        "string without null bytes or None", 
                                        arg, msgbuf, bufsize);
@@ -923,7 +923,7 @@ convertsimple(PyObject *arg, const char **p_format, va_list *p_va, int flags,
                                          arg, msgbuf, bufsize);
                        
                /* Encode object */
-               if (!recode_strings && PyBytes_Check(arg)) {
+               if (!recode_strings && PyString_Check(arg)) {
                        s = arg;
                        Py_INCREF(s);
                }
@@ -946,7 +946,7 @@ convertsimple(PyObject *arg, const char **p_format, va_list *p_va, int flags,
                        if (s == NULL)
                                return converterr("(encoding failed)",
                                                  arg, msgbuf, bufsize);
-                       if (!PyBytes_Check(s)) {
+                       if (!PyString_Check(s)) {
                                Py_DECREF(s);
                                return converterr(
                                        "(encoder failed to return a string)",
@@ -956,7 +956,7 @@ convertsimple(PyObject *arg, const char **p_format, va_list *p_va, int flags,
                        return converterr("string<e>", arg, msgbuf, bufsize);
 #endif
                }
-               size = PyBytes_GET_SIZE(s);
+               size = PyString_GET_SIZE(s);
 
                /* Write output; output is guaranteed to be 0-terminated */
                if (*format == '#') { 
@@ -1013,7 +1013,7 @@ convertsimple(PyObject *arg, const char **p_format, va_list *p_va, int flags,
                                }
                        }
                        memcpy(*buffer,
-                              PyBytes_AS_STRING(s),
+                              PyString_AS_STRING(s),
                               size + 1);
                        STORE_SIZE(size);
                } else {
@@ -1030,7 +1030,7 @@ convertsimple(PyObject *arg, const char **p_format, va_list *p_va, int flags,
                           PyMem_Free()ing it after usage
 
                        */
-                       if ((Py_ssize_t)strlen(PyBytes_AS_STRING(s))
+                       if ((Py_ssize_t)strlen(PyString_AS_STRING(s))
                                                                != size) {
                                Py_DECREF(s);
                                return converterr(
@@ -1049,7 +1049,7 @@ convertsimple(PyObject *arg, const char **p_format, va_list *p_va, int flags,
                                                arg, msgbuf, bufsize);
                        }
                        memcpy(*buffer,
-                              PyBytes_AS_STRING(s),
+                              PyString_AS_STRING(s),
                               size + 1);
                }
                Py_DECREF(s);
@@ -1083,7 +1083,7 @@ convertsimple(PyObject *arg, const char **p_format, va_list *p_va, int flags,
 
        case 'S': { /* string object */
                PyObject **p = va_arg(*p_va, PyObject **);
-               if (PyBytes_Check(arg))
+               if (PyString_Check(arg))
                        *p = arg;
                else
                        return converterr("string", arg, msgbuf, bufsize);
@@ -1473,12 +1473,12 @@ vgetargskeywords(PyObject *args, PyObject *keywords, const char *format,
                while (PyDict_Next(keywords, &pos, &key, &value)) {
                        int match = 0;
                        char *ks;
-                       if (!PyBytes_Check(key)) {
+                       if (!PyString_Check(key)) {
                                PyErr_SetString(PyExc_TypeError, 
                                                "keywords must be strings");
                                return cleanreturn(0, freelist);
                        }
-                       ks = PyBytes_AsString(key);
+                       ks = PyString_AsString(key);
                        for (i = 0; i < len; i++) {
                                if (!strcmp(ks, kwlist[i])) {
                                        match = 1;
index ffaaca57790b272594a7d5c6865e6e81356b576a..b65ed0e86afac150956a7d952c1e0d555ecba686 100644 (file)
@@ -467,8 +467,8 @@ PyImport_Cleanup(void)
                while (PyDict_Next(modules, &pos, &key, &value)) {
                        if (value->ob_refcnt != 1)
                                continue;
-                       if (PyBytes_Check(key) && PyModule_Check(value)) {
-                               name = PyBytes_AS_STRING(key);
+                       if (PyString_Check(key) && PyModule_Check(value)) {
+                               name = PyString_AS_STRING(key);
                                if (strcmp(name, "__builtin__") == 0)
                                        continue;
                                if (strcmp(name, "sys") == 0)
@@ -486,8 +486,8 @@ PyImport_Cleanup(void)
        /* Next, delete all modules (still skipping __builtin__ and sys) */
        pos = 0;
        while (PyDict_Next(modules, &pos, &key, &value)) {
-               if (PyBytes_Check(key) && PyModule_Check(value)) {
-                       name = PyBytes_AS_STRING(key);
+               if (PyString_Check(key) && PyModule_Check(value)) {
+                       name = PyString_AS_STRING(key);
                        if (strcmp(name, "__builtin__") == 0)
                                continue;
                        if (strcmp(name, "sys") == 0)
@@ -665,7 +665,7 @@ PyImport_ExecCodeModuleEx(char *name, PyObject *co, char *pathname)
        /* Remember the filename as the __file__ attribute */
        v = NULL;
        if (pathname != NULL) {
-               v = PyBytes_FromString(pathname);
+               v = PyString_FromString(pathname);
                if (v == NULL)
                        PyErr_Clear();
        }
@@ -1002,7 +1002,7 @@ load_package(char *name, char *pathname)
                PySys_WriteStderr("import %s # directory %s\n",
                        name, pathname);
        d = PyModule_GetDict(m);
-       file = PyBytes_FromString(pathname);
+       file = PyString_FromString(pathname);
        if (file == NULL)
                goto error;
        path = Py_BuildValue("[O]", file);
@@ -1214,15 +1214,15 @@ find_module(char *fullname, char *subname, PyObject *path, char *buf,
                Py_DECREF(meta_path);
        }
 
-       if (path != NULL && PyBytes_Check(path)) {
+       if (path != NULL && PyString_Check(path)) {
                /* The only type of submodule allowed inside a "frozen"
                   package are other frozen modules or packages. */
-               if (PyBytes_Size(path) + 1 + strlen(name) >= (size_t)buflen) {
+               if (PyString_Size(path) + 1 + strlen(name) >= (size_t)buflen) {
                        PyErr_SetString(PyExc_ImportError,
                                        "full frozen module name too long");
                        return NULL;
                }
-               strcpy(buf, PyBytes_AsString(path));
+               strcpy(buf, PyString_AsString(path));
                strcat(buf, ".");
                strcat(buf, name);
                strcpy(name, buf);
@@ -1291,14 +1291,14 @@ find_module(char *fullname, char *subname, PyObject *path, char *buf,
                }
                else
 #endif
-               if (!PyBytes_Check(v))
+               if (!PyString_Check(v))
                        continue;
-               len = PyBytes_GET_SIZE(v);
+               len = PyString_GET_SIZE(v);
                if (len + 2 + namelen + MAXSUFFIXSIZE >= buflen) {
                        Py_XDECREF(copy);
                        continue; /* Too long */
                }
-               strcpy(buf, PyBytes_AS_STRING(v));
+               strcpy(buf, PyString_AS_STRING(v));
                if (strlen(buf) != len) {
                        Py_XDECREF(copy);
                        continue; /* v contains '\0' */
@@ -1963,7 +1963,7 @@ PyImport_ImportFrozenModule(char *name)
                if (m == NULL)
                        goto err_return;
                d = PyModule_GetDict(m);
-               s = PyBytes_InternFromString(name);
+               s = PyString_InternFromString(name);
                if (s == NULL)
                        goto err_return;
                err = PyDict_SetItemString(d, "__path__", s);
@@ -1992,7 +1992,7 @@ PyImport_ImportModule(const char *name)
        PyObject *pname;
        PyObject *result;
 
-       pname = PyBytes_FromString(name);
+       pname = PyString_FromString(name);
        if (pname == NULL)
                return NULL;
        result = PyImport_Import(pname);
@@ -2165,17 +2165,17 @@ get_parent(PyObject *globals, char *buf, Py_ssize_t *p_buflen, int level)
                return Py_None;
 
        if (namestr == NULL) {
-               namestr = PyBytes_InternFromString("__name__");
+               namestr = PyString_InternFromString("__name__");
                if (namestr == NULL)
                        return NULL;
        }
        if (pathstr == NULL) {
-               pathstr = PyBytes_InternFromString("__path__");
+               pathstr = PyString_InternFromString("__path__");
                if (pathstr == NULL)
                        return NULL;
        }
        if (pkgstr == NULL) {
-               pkgstr = PyBytes_InternFromString("__package__");
+               pkgstr = PyString_InternFromString("__package__");
                if (pkgstr == NULL)
                        return NULL;
        }
@@ -2187,12 +2187,12 @@ get_parent(PyObject *globals, char *buf, Py_ssize_t *p_buflen, int level)
        if ((pkgname != NULL) && (pkgname != Py_None)) {
                /* __package__ is set, so use it */
                Py_ssize_t len;
-               if (!PyBytes_Check(pkgname)) {
+               if (!PyString_Check(pkgname)) {
                        PyErr_SetString(PyExc_ValueError,
                                        "__package__ set to non-string");
                        return NULL;
                }
-               len = PyBytes_GET_SIZE(pkgname);
+               len = PyString_GET_SIZE(pkgname);
                if (len == 0) {
                        if (level > 0) {
                                PyErr_SetString(PyExc_ValueError,
@@ -2206,24 +2206,24 @@ get_parent(PyObject *globals, char *buf, Py_ssize_t *p_buflen, int level)
                                        "Package name too long");
                        return NULL;
                }
-               strcpy(buf, PyBytes_AS_STRING(pkgname));
+               strcpy(buf, PyString_AS_STRING(pkgname));
        } else {
                /* __package__ not set, so figure it out and set it */
                modname = PyDict_GetItem(globals, namestr);
-               if (modname == NULL || !PyBytes_Check(modname))
+               if (modname == NULL || !PyString_Check(modname))
                        return Py_None;
        
                modpath = PyDict_GetItem(globals, pathstr);
                if (modpath != NULL) {
                        /* __path__ is set, so modname is already the package name */
-                       Py_ssize_t len = PyBytes_GET_SIZE(modname);
+                       Py_ssize_t len = PyString_GET_SIZE(modname);
                        int error;
                        if (len > MAXPATHLEN) {
                                PyErr_SetString(PyExc_ValueError,
                                                "Module name too long");
                                return NULL;
                        }
-                       strcpy(buf, PyBytes_AS_STRING(modname));
+                       strcpy(buf, PyString_AS_STRING(modname));
                        error = PyDict_SetItem(globals, pkgstr, modname);
                        if (error) {
                                PyErr_SetString(PyExc_ValueError,
@@ -2232,7 +2232,7 @@ get_parent(PyObject *globals, char *buf, Py_ssize_t *p_buflen, int level)
                        }
                } else {
                        /* Normal module, so work out the package name if any */
-                       char *start = PyBytes_AS_STRING(modname);
+                       char *start = PyString_AS_STRING(modname);
                        char *lastdot = strrchr(start, '.');
                        size_t len;
                        int error;
@@ -2258,7 +2258,7 @@ get_parent(PyObject *globals, char *buf, Py_ssize_t *p_buflen, int level)
                        }
                        strncpy(buf, start, len);
                        buf[len] = '\0';
-                       pkgname = PyBytes_FromString(buf);
+                       pkgname = PyString_FromString(buf);
                        if (pkgname == NULL) {
                                return NULL;
                        }
@@ -2394,13 +2394,13 @@ ensure_fromlist(PyObject *mod, PyObject *fromlist, char *buf, Py_ssize_t buflen,
                        }
                        return 0;
                }
-               if (!PyBytes_Check(item)) {
+               if (!PyString_Check(item)) {
                        PyErr_SetString(PyExc_TypeError,
                                        "Item in ``from list'' not a string");
                        Py_DECREF(item);
                        return 0;
                }
-               if (PyBytes_AS_STRING(item)[0] == '*') {
+               if (PyString_AS_STRING(item)[0] == '*') {
                        PyObject *all;
                        Py_DECREF(item);
                        /* See if the package defines __all__ */
@@ -2419,7 +2419,7 @@ ensure_fromlist(PyObject *mod, PyObject *fromlist, char *buf, Py_ssize_t buflen,
                }
                hasit = PyObject_HasAttr(mod, item);
                if (!hasit) {
-                       char *subname = PyBytes_AS_STRING(item);
+                       char *subname = PyString_AS_STRING(item);
                        PyObject *submod;
                        char *p;
                        if (buflen + strlen(subname) >= MAXPATHLEN) {
@@ -2585,7 +2585,7 @@ PyImport_ReloadModule(PyObject *m)
                subname = name;
        else {
                PyObject *parentname, *parent;
-               parentname = PyBytes_FromStringAndSize(name, (subname-name));
+               parentname = PyString_FromStringAndSize(name, (subname-name));
                if (parentname == NULL) {
                        imp_modules_reloading_clear();
                        return NULL;
@@ -2594,7 +2594,7 @@ PyImport_ReloadModule(PyObject *m)
                if (parent == NULL) {
                        PyErr_Format(PyExc_ImportError,
                            "reload(): parent %.200s not in sys.modules",
-                           PyBytes_AS_STRING(parentname));
+                           PyString_AS_STRING(parentname));
                        Py_DECREF(parentname);
                        imp_modules_reloading_clear();
                        return NULL;
@@ -2639,7 +2639,7 @@ PyImport_ReloadModule(PyObject *m)
    done using whatever import hooks are installed in the current
    environment, e.g. by "rexec".
    A dummy list ["__doc__"] is passed as the 4th argument so that
-   e.g. PyImport_Import(PyBytes_FromString("win32com.client.gencache"))
+   e.g. PyImport_Import(PyString_FromString("win32com.client.gencache"))
    will return <module "gencache"> instead of <module "win32com">. */
 
 PyObject *
@@ -2655,10 +2655,10 @@ PyImport_Import(PyObject *module_name)
 
        /* Initialize constant string objects */
        if (silly_list == NULL) {
-               import_str = PyBytes_InternFromString("__import__");
+               import_str = PyString_InternFromString("__import__");
                if (import_str == NULL)
                        return NULL;
-               builtins_str = PyBytes_InternFromString("__builtins__");
+               builtins_str = PyString_InternFromString("__builtins__");
                if (builtins_str == NULL)
                        return NULL;
                silly_list = Py_BuildValue("[s]", "__doc__");
@@ -2726,7 +2726,7 @@ imp_get_magic(PyObject *self, PyObject *noargs)
        buf[2] = (char) ((pyc_magic >> 16) & 0xff);
        buf[3] = (char) ((pyc_magic >> 24) & 0xff);
 
-       return PyBytes_FromStringAndSize(buf, 4);
+       return PyString_FromStringAndSize(buf, 4);
 }
 
 static PyObject *
index 19ec4cf47632e50263568861840ed4ab2f4d6c28..4037d4708393974b89c64be3e2aa0391305219ad 100644 (file)
@@ -52,7 +52,7 @@ PyMac_StrError(int err)
                buf[0] = '\0';
        }
        else {
-               char *input = PyBytes_AsString(rv);
+               char *input = PyString_AsString(rv);
                if (!input) {
                        PyErr_Clear();
                        buf[0] = '\0';
@@ -125,7 +125,7 @@ PyMac_GetFullPathname(FSSpec *fss, char *path, int len)
        if (!rv)
                goto error;
 
-       input = PyBytes_AsString(rv);
+       input = PyString_AsString(rv);
        if (!input)
                goto error;
 
@@ -161,12 +161,12 @@ int
 PyMac_GetOSType(PyObject *v, OSType *pr)
 {
        uint32_t tmp;
-       if (!PyBytes_Check(v) || PyBytes_Size(v) != 4) {
+       if (!PyString_Check(v) || PyString_Size(v) != 4) {
                PyErr_SetString(PyExc_TypeError,
                        "OSType arg must be string of 4 chars");
                return 0;
        }
-       memcpy((char *)&tmp, PyBytes_AsString(v), 4);
+       memcpy((char *)&tmp, PyString_AsString(v), 4);
        *pr = (OSType)ntohl(tmp);
        return 1;
 }
@@ -176,7 +176,7 @@ PyObject *
 PyMac_BuildOSType(OSType t)
 {
        uint32_t tmp = htonl((uint32_t)t);
-       return PyBytes_FromStringAndSize((char *)&tmp, 4);
+       return PyString_FromStringAndSize((char *)&tmp, 4);
 }
 
 /* Convert an NumVersion value to a 4-element tuple */
@@ -192,13 +192,13 @@ int
 PyMac_GetStr255(PyObject *v, Str255 pbuf)
 {
        int len;
-       if (!PyBytes_Check(v) || (len = PyBytes_Size(v)) > 255) {
+       if (!PyString_Check(v) || (len = PyString_Size(v)) > 255) {
                PyErr_SetString(PyExc_TypeError,
                        "Str255 arg must be string of at most 255 chars");
                return 0;
        }
        pbuf[0] = len;
-       memcpy((char *)(pbuf+1), PyBytes_AsString(v), len);
+       memcpy((char *)(pbuf+1), PyString_AsString(v), len);
        return 1;
 }
 
@@ -210,7 +210,7 @@ PyMac_BuildStr255(Str255 s)
                PyErr_SetString(PyExc_SystemError, "Str255 pointer is NULL");
                return NULL;
        }
-       return PyBytes_FromStringAndSize((char *)&s[1], (int)s[0]);
+       return PyString_FromStringAndSize((char *)&s[1], (int)s[0]);
 }
 
 PyObject *
@@ -220,7 +220,7 @@ PyMac_BuildOptStr255(Str255 s)
                Py_INCREF(Py_None);
                return Py_None;
        }
-       return PyBytes_FromStringAndSize((char *)&s[1], (int)s[0]);
+       return PyString_FromStringAndSize((char *)&s[1], (int)s[0]);
 }
 
 
index 1cc222c6613b3c25b5fe505b320894a1a5578c20..6db46e4f6382b7ace855f326785f364cddf15c87 100644 (file)
@@ -64,18 +64,18 @@ w_more(int c, WFILE *p)
        Py_ssize_t size, newsize;
        if (p->str == NULL)
                return; /* An error already occurred */
-       size = PyBytes_Size(p->str);
+       size = PyString_Size(p->str);
        newsize = size + size + 1024;
        if (newsize > 32*1024*1024) {
                newsize = size + 1024*1024;
        }
-       if (_PyBytes_Resize(&p->str, newsize) != 0) {
+       if (_PyString_Resize(&p->str, newsize) != 0) {
                p->ptr = p->end = NULL;
        }
        else {
-               p->ptr = PyBytes_AS_STRING((PyBytesObject *)p->str) + size;
+               p->ptr = PyString_AS_STRING((PyStringObject *)p->str) + size;
                p->end =
-                       PyBytes_AS_STRING((PyBytesObject *)p->str) + newsize;
+                       PyString_AS_STRING((PyStringObject *)p->str) + newsize;
                *p->ptr++ = Py_SAFE_DOWNCAST(c, int, char);
        }
 }
@@ -239,8 +239,8 @@ w_object(PyObject *v, WFILE *p)
                }
        }
 #endif
-       else if (PyBytes_CheckExact(v)) {
-               if (p->strings && PyBytes_CHECK_INTERNED(v)) {
+       else if (PyString_CheckExact(v)) {
+               if (p->strings && PyString_CHECK_INTERNED(v)) {
                        PyObject *o = PyDict_GetItem(p->strings, v);
                        if (o) {
                                long w = PyInt_AsLong(o);
@@ -265,7 +265,7 @@ w_object(PyObject *v, WFILE *p)
                else {
                        w_byte(TYPE_STRING, p);
                }
-               n = PyBytes_GET_SIZE(v);
+               n = PyString_GET_SIZE(v);
                if (n > INT_MAX) {
                        /* huge strings are not supported */
                        p->depth--;
@@ -273,7 +273,7 @@ w_object(PyObject *v, WFILE *p)
                        return;
                }
                w_long((long)n, p);
-               w_string(PyBytes_AS_STRING(v), (int)n, p);
+               w_string(PyString_AS_STRING(v), (int)n, p);
        }
 #ifdef Py_USING_UNICODE
        else if (PyUnicode_CheckExact(v)) {
@@ -285,14 +285,14 @@ w_object(PyObject *v, WFILE *p)
                        return;
                }
                w_byte(TYPE_UNICODE, p);
-               n = PyBytes_GET_SIZE(utf8);
+               n = PyString_GET_SIZE(utf8);
                if (n > INT_MAX) {
                        p->depth--;
                        p->error = 1;
                        return;
                }
                w_long((long)n, p);
-               w_string(PyBytes_AS_STRING(utf8), (int)n, p);
+               w_string(PyString_AS_STRING(utf8), (int)n, p);
                Py_DECREF(utf8);
        }
 #endif
@@ -713,12 +713,12 @@ r_object(RFILE *p)
                        retval = NULL;
                        break;
                }
-               v = PyBytes_FromStringAndSize((char *)NULL, n);
+               v = PyString_FromStringAndSize((char *)NULL, n);
                if (v == NULL) {
                        retval = NULL;
                        break;
                }
-               if (r_string(PyBytes_AS_STRING(v), (int)n, p) != n) {
+               if (r_string(PyString_AS_STRING(v), (int)n, p) != n) {
                        Py_DECREF(v);
                        PyErr_SetString(PyExc_EOFError,
                                        "EOF read where object expected");
@@ -726,7 +726,7 @@ r_object(RFILE *p)
                        break;
                }
                if (type == TYPE_INTERNED) {
-                       PyBytes_InternInPlace(&v);
+                       PyString_InternInPlace(&v);
                        if (PyList_Append(p->strings, v) < 0) {
                                retval = NULL;
                                break;
@@ -1113,11 +1113,11 @@ PyMarshal_WriteObjectToString(PyObject *x, int version)
 {
        WFILE wf;
        wf.fp = NULL;
-       wf.str = PyBytes_FromStringAndSize((char *)NULL, 50);
+       wf.str = PyString_FromStringAndSize((char *)NULL, 50);
        if (wf.str == NULL)
                return NULL;
-       wf.ptr = PyBytes_AS_STRING((PyBytesObject *)wf.str);
-       wf.end = wf.ptr + PyBytes_Size(wf.str);
+       wf.ptr = PyString_AS_STRING((PyStringObject *)wf.str);
+       wf.end = wf.ptr + PyString_Size(wf.str);
        wf.error = 0;
        wf.depth = 0;
        wf.version = version;
@@ -1125,14 +1125,14 @@ PyMarshal_WriteObjectToString(PyObject *x, int version)
        w_object(x, &wf);
        Py_XDECREF(wf.strings);
        if (wf.str != NULL) {
-               char *base = PyBytes_AS_STRING((PyBytesObject *)wf.str);
+               char *base = PyString_AS_STRING((PyStringObject *)wf.str);
                if (wf.ptr - base > PY_SSIZE_T_MAX) {
                        Py_DECREF(wf.str);
                        PyErr_SetString(PyExc_OverflowError,
                                        "too much marshall data for a string");
                        return NULL;
                }
-               _PyBytes_Resize(&wf.str, (Py_ssize_t)(wf.ptr - base));
+               _PyString_Resize(&wf.str, (Py_ssize_t)(wf.ptr - base));
        }
        if (wf.error) {
                Py_XDECREF(wf.str);
index b23749fbd3b66d961b83edbf93b252a865b6ad3c..d54158f212290e52e9bc31ba6d907b73cf9a3492 100644 (file)
@@ -65,7 +65,7 @@ Py_InitModule4(const char *name, PyMethodDef *methods, const char *doc,
                return NULL;
        d = PyModule_GetDict(m);
        if (methods != NULL) {
-               n = PyBytes_FromString(name);
+               n = PyString_FromString(name);
                if (n == NULL)
                        return NULL;
                for (ml = methods; ml->ml_name != NULL; ml++) {
@@ -92,7 +92,7 @@ Py_InitModule4(const char *name, PyMethodDef *methods, const char *doc,
                Py_DECREF(n);
        }
        if (doc != NULL) {
-               v = PyBytes_FromString(doc);
+               v = PyString_FromString(doc);
                if (v == NULL || PyDict_SetItemString(d, "__doc__", v) != 0) {
                        Py_XDECREF(v);
                        return NULL;
@@ -391,7 +391,7 @@ do_mkvalue(const char **p_format, va_list *p_va, int flags)
                {
                        char p[1];
                        p[0] = (char)va_arg(*p_va, int);
-                       return PyBytes_FromStringAndSize(p, 1);
+                       return PyString_FromStringAndSize(p, 1);
                }
 
                case 's':
@@ -423,7 +423,7 @@ do_mkvalue(const char **p_format, va_list *p_va, int flags)
                                        }
                                        n = (Py_ssize_t)m;
                                }
-                               v = PyBytes_FromStringAndSize(str, n);
+                               v = PyString_FromStringAndSize(str, n);
                        }
                        return v;
                }
@@ -633,7 +633,7 @@ PyModule_AddIntConstant(PyObject *m, const char *name, long value)
 int 
 PyModule_AddStringConstant(PyObject *m, const char *name, const char *value)
 {
-       PyObject *o = PyBytes_FromString(value);
+       PyObject *o = PyString_FromString(value);
        if (!o)
                return -1;
        if (PyModule_AddObject(m, name, o) == 0)
index df19726dc70703af160c7c69ddf5fe7cff1976a6..e9da377dc68f9a4a562793f048d044a1c9699aa9 100644 (file)
@@ -300,15 +300,15 @@ PyCode_Optimize(PyObject *code, PyObject* consts, PyObject *names,
                goto exitUnchanged;
 
        /* Bypass optimization when the lineno table is too complex */
-       assert(PyBytes_Check(lineno_obj));
-       lineno = (unsigned char*)PyBytes_AS_STRING(lineno_obj);
-       tabsiz = PyBytes_GET_SIZE(lineno_obj);
+       assert(PyString_Check(lineno_obj));
+       lineno = (unsigned char*)PyString_AS_STRING(lineno_obj);
+       tabsiz = PyString_GET_SIZE(lineno_obj);
        if (memchr(lineno, 255, tabsiz) != NULL)
                goto exitUnchanged;
 
        /* Avoid situations where jump retargeting could overflow */
-       assert(PyBytes_Check(code));
-       codelen = PyBytes_GET_SIZE(code);
+       assert(PyString_Check(code));
+       codelen = PyString_GET_SIZE(code);
        if (codelen > 32700)
                goto exitUnchanged;
 
@@ -317,7 +317,7 @@ PyCode_Optimize(PyObject *code, PyObject* consts, PyObject *names,
        if (codestr == NULL)
                goto exitUnchanged;
        codestr = (unsigned char *)memcpy(codestr, 
-                                         PyBytes_AS_STRING(code), codelen);
+                                         PyString_AS_STRING(code), codelen);
 
        /* Verify that RETURN_VALUE terminates the codestring.  This allows
           the various transformation patterns to look ahead several
@@ -382,7 +382,7 @@ PyCode_Optimize(PyObject *code, PyObject* consts, PyObject *names,
                        case LOAD_NAME:
                        case LOAD_GLOBAL:
                                j = GETARG(codestr, i);
-                               name = PyBytes_AsString(PyTuple_GET_ITEM(names, j));
+                               name = PyString_AsString(PyTuple_GET_ITEM(names, j));
                                if (name == NULL  ||  strcmp(name, "None") != 0)
                                        continue;
                                for (j=0 ; j < PyList_GET_SIZE(consts) ; j++) {
@@ -612,7 +612,7 @@ PyCode_Optimize(PyObject *code, PyObject* consts, PyObject *names,
        }
        assert(h + nops == codelen);
 
-       code = PyBytes_FromStringAndSize((char *)codestr, h);
+       code = PyString_FromStringAndSize((char *)codestr, h);
        PyMem_Free(addrmap);
        PyMem_Free(codestr);
        PyMem_Free(blocks);
index e7bc22c2433f854adf1bd7f300ca680dea68dd14..3f0328e06b31564e5d4eb2f744c50a8de7b245ae 100644 (file)
@@ -364,7 +364,7 @@ add_thousands_grouping(char* buffer, size_t buf_size)
        /* At this point, p points just past the right-most character we
           want to format.  We need to add the grouping string for the
           characters between buffer and p. */
-       return _PyBytes_InsertThousandsGrouping(buffer, len, p,
+       return _PyString_InsertThousandsGrouping(buffer, len, p,
                                                 buf_size, NULL, 1);
 }
 
index 26557caae40ba00db04427b6e0b75405da520fe3..785519bdc3600d7974132015fd8dec38afa7a2da 100644 (file)
@@ -495,7 +495,7 @@ Py_Finalize(void)
        PyTuple_Fini();
        PyList_Fini();
        PySet_Fini();
-       PyBytes_Fini();
+       PyString_Fini();
        PyByteArray_Fini();
        PyInt_Fini();
        PyFloat_Fini();
@@ -744,12 +744,12 @@ PyRun_InteractiveLoopFlags(FILE *fp, const char *filename, PyCompilerFlags *flag
        }
        v = PySys_GetObject("ps1");
        if (v == NULL) {
-               PySys_SetObject("ps1", v = PyBytes_FromString(">>> "));
+               PySys_SetObject("ps1", v = PyString_FromString(">>> "));
                Py_XDECREF(v);
        }
        v = PySys_GetObject("ps2");
        if (v == NULL) {
-               PySys_SetObject("ps2", v = PyBytes_FromString("... "));
+               PySys_SetObject("ps2", v = PyString_FromString("... "));
                Py_XDECREF(v);
        }
        for (;;) {
@@ -796,16 +796,16 @@ PyRun_InteractiveOneFlags(FILE *fp, const char *filename, PyCompilerFlags *flags
                v = PyObject_Str(v);
                if (v == NULL)
                        PyErr_Clear();
-               else if (PyBytes_Check(v))
-                       ps1 = PyBytes_AsString(v);
+               else if (PyString_Check(v))
+                       ps1 = PyString_AsString(v);
        }
        w = PySys_GetObject("ps2");
        if (w != NULL) {
                w = PyObject_Str(w);
                if (w == NULL)
                        PyErr_Clear();
-               else if (PyBytes_Check(w))
-                       ps2 = PyBytes_AsString(w);
+               else if (PyString_Check(w))
+                       ps2 = PyString_AsString(w);
        }
        arena = PyArena_New();
        if (arena == NULL) {
@@ -898,7 +898,7 @@ PyRun_SimpleFileExFlags(FILE *fp, const char *filename, int closeit,
                return -1;
        d = PyModule_GetDict(m);
        if (PyDict_GetItemString(d, "__file__") == NULL) {
-               PyObject *f = PyBytes_FromString(filename);
+               PyObject *f = PyString_FromString(filename);
                if (f == NULL)
                        return -1;
                if (PyDict_SetItemString(d, "__file__", f) < 0) {
@@ -982,7 +982,7 @@ parse_syntax_error(PyObject *err, PyObject **message, const char **filename,
                goto finally;
        if (v == Py_None)
                *filename = NULL;
-       else if (! (*filename = PyBytes_AsString(v)))
+       else if (! (*filename = PyString_AsString(v)))
                goto finally;
 
        Py_DECREF(v);
@@ -1014,7 +1014,7 @@ parse_syntax_error(PyObject *err, PyObject **message, const char **filename,
                goto finally;
        if (v == Py_None)
                *text = NULL;
-       else if (! (*text = PyBytes_AsString(v)))
+       else if (! (*text = PyString_AsString(v)))
                goto finally;
        Py_DECREF(v);
        return 1;
@@ -1237,7 +1237,7 @@ PyErr_Display(PyObject *exception, PyObject *value, PyObject *tb)
                        if (moduleName == NULL)
                                err = PyFile_WriteString("<unknown>", f);
                        else {
-                               char* modstr = PyBytes_AsString(moduleName);
+                               char* modstr = PyString_AsString(moduleName);
                                if (modstr && strcmp(modstr, "exceptions"))
                                {
                                        err = PyFile_WriteString(modstr, f);
@@ -1261,8 +1261,8 @@ PyErr_Display(PyObject *exception, PyObject *value, PyObject *tb)
                        */
                        if (s == NULL)
                                err = -1;
-                       else if (!PyBytes_Check(s) ||
-                                PyBytes_GET_SIZE(s) != 0)
+                       else if (!PyString_Check(s) ||
+                                PyString_GET_SIZE(s) != 0)
                                err = PyFile_WriteString(": ", f);
                        if (err == 0)
                          err = PyFile_WriteObject(s, f, Py_PRINT_RAW);
@@ -1581,7 +1581,7 @@ err_input(perrdetail *err)
                if (value != NULL) {
                        u = PyObject_Str(value);
                        if (u != NULL) {
-                               msg = PyBytes_AsString(u);
+                               msg = PyString_AsString(u);
                        }
                }
                if (msg == NULL)
index 5ebe28331f071f719a808eb09e1b9686e6e62e99..d2305903303f421e78240254ac0331c77ebaef3c 100644 (file)
@@ -16,7 +16,7 @@ listmembers(struct memberlist *mlist)
        if (v != NULL) {
                for (i = 0; i < n; i++)
                        PyList_SetItem(v, i,
-                                      PyBytes_FromString(mlist[i].name));
+                                      PyString_FromString(mlist[i].name));
                if (PyErr_Occurred()) {
                        Py_DECREF(v);
                        v = NULL;
@@ -103,13 +103,13 @@ PyMember_GetOne(const char *addr, PyMemberDef *l)
                        v = Py_None;
                }
                else
-                       v = PyBytes_FromString(*(char**)addr);
+                       v = PyString_FromString(*(char**)addr);
                break;
        case T_STRING_INPLACE:
-               v = PyBytes_FromString((char*)addr);
+               v = PyString_FromString((char*)addr);
                break;
        case T_CHAR:
-               v = PyBytes_FromStringAndSize((char*)addr, 1);
+               v = PyString_FromStringAndSize((char*)addr, 1);
                break;
        case T_OBJECT:
                v = *(PyObject **)addr;
@@ -310,8 +310,8 @@ PyMember_SetOne(char *addr, PyMemberDef *l, PyObject *v)
                Py_XDECREF(oldv);
                break;
        case T_CHAR:
-               if (PyBytes_Check(v) && PyBytes_Size(v) == 1) {
-                       *(char*)addr = PyBytes_AsString(v)[0];
+               if (PyString_Check(v) && PyString_Size(v) == 1) {
+                       *(char*)addr = PyString_AsString(v)[0];
                }
                else {
                        PyErr_BadArgument();
index c0201c368b5a190369adb8fcdfca993edbca79d1..cc3c774e6f6c859ea16aaa12b079af6404e5d081 100644 (file)
@@ -87,9 +87,9 @@ ste_repr(PySTEntryObject *ste)
 
        PyOS_snprintf(buf, sizeof(buf),
                      "<symtable entry %.100s(%ld), line %d>",
-                     PyBytes_AS_STRING(ste->ste_name),
+                     PyString_AS_STRING(ste->ste_name),
                      PyInt_AS_LONG(ste->ste_id), ste->ste_lineno);
-       return PyBytes_FromString(buf);
+       return PyString_FromString(buf);
 }
 
 static void
@@ -180,7 +180,7 @@ static int symtable_implicit_arg(struct symtable *st, int pos);
 static identifier top = NULL, lambda = NULL, genexpr = NULL;
 
 #define GET_IDENTIFIER(VAR) \
-       ((VAR) ? (VAR) : ((VAR) = PyBytes_InternFromString(# VAR)))
+       ((VAR) ? (VAR) : ((VAR) = PyString_InternFromString(# VAR)))
 
 #define DUPLICATE_ARGUMENT \
 "duplicate argument '%s' in function definition"
@@ -372,7 +372,7 @@ analyze_name(PySTEntryObject *ste, PyObject *dict, PyObject *name, long flags,
                if (flags & DEF_PARAM) {
                        PyErr_Format(PyExc_SyntaxError,
                                     "name '%s' is local and global",
-                                    PyBytes_AS_STRING(name));
+                                    PyString_AS_STRING(name));
                        return 0;
                }
                SET_SCOPE(dict, name, GLOBAL_EXPLICIT);
@@ -487,19 +487,19 @@ check_unoptimized(const PySTEntryObject* ste) {
                PyOS_snprintf(buf, sizeof(buf), 
                              "import * is not allowed in function '%.100s' "
                              "because it is %s",
-                             PyBytes_AS_STRING(ste->ste_name), trailer);
+                             PyString_AS_STRING(ste->ste_name), trailer);
                break;
        case OPT_BARE_EXEC:
                PyOS_snprintf(buf, sizeof(buf),
                              "unqualified exec is not allowed in function "
                              "'%.100s' it %s",
-                             PyBytes_AS_STRING(ste->ste_name), trailer);
+                             PyString_AS_STRING(ste->ste_name), trailer);
                break;
        default:
                PyOS_snprintf(buf, sizeof(buf), 
                              "function '%.100s' uses import * and bare exec, "
                              "which are illegal because it %s",
-                             PyBytes_AS_STRING(ste->ste_name), trailer);
+                             PyString_AS_STRING(ste->ste_name), trailer);
                break;
        }
 
@@ -800,7 +800,7 @@ symtable_add_def(struct symtable *st, PyObject *name, int flag)
            if ((flag & DEF_PARAM) && (val & DEF_PARAM)) {
                    /* Is it better to use 'mangled' or 'name' here? */
                    PyErr_Format(PyExc_SyntaxError, DUPLICATE_ARGUMENT,
-                                PyBytes_AsString(name));
+                                PyString_AsString(name));
                    PyErr_SyntaxLocation(st->st_filename,
                                       st->st_cur->ste_lineno);
                    goto error;
@@ -914,7 +914,7 @@ symtable_new_tmpname(struct symtable *st)
 
        PyOS_snprintf(tmpname, sizeof(tmpname), "_[%d]",
                      ++st->st_cur->ste_tmpname);
-       tmp = PyBytes_InternFromString(tmpname);
+       tmp = PyString_InternFromString(tmpname);
        if (!tmp)
                return 0;
        if (!symtable_add_def(st, tmp, DEF_LOCAL))
@@ -1065,7 +1065,7 @@ symtable_visit_stmt(struct symtable *st, stmt_ty s)
                asdl_seq *seq = s->v.Global.names;
                for (i = 0; i < asdl_seq_LEN(seq); i++) {
                        identifier name = (identifier)asdl_seq_GET(seq, i);
-                       char *c_name = PyBytes_AS_STRING(name);
+                       char *c_name = PyString_AS_STRING(name);
                        long cur = symtable_lookup(st, name);
                        if (cur < 0)
                                return 0;
@@ -1218,7 +1218,7 @@ symtable_visit_expr(struct symtable *st, expr_ty e)
 static int
 symtable_implicit_arg(struct symtable *st, int pos)
 {
-       PyObject *id = PyBytes_FromFormat(".%d", pos);
+       PyObject *id = PyString_FromFormat(".%d", pos);
        if (id == NULL)
                return 0;
        if (!symtable_add_def(st, id, DEF_PARAM)) {
@@ -1326,10 +1326,10 @@ symtable_visit_alias(struct symtable *st, alias_ty a)
        */
        PyObject *store_name;
        PyObject *name = (a->asname == NULL) ? a->name : a->asname;
-       const char *base = PyBytes_AS_STRING(name);
+       const char *base = PyString_AS_STRING(name);
        char *dot = strchr(base, '.');
        if (dot) {
-               store_name = PyBytes_FromStringAndSize(base, dot - base);
+               store_name = PyString_FromStringAndSize(base, dot - base);
                if (!store_name)
                        return 0;
        }
@@ -1337,7 +1337,7 @@ symtable_visit_alias(struct symtable *st, alias_ty a)
                store_name = name;
                Py_INCREF(store_name);
        }
-       if (strcmp(PyBytes_AS_STRING(name), "*")) {
+       if (strcmp(PyString_AS_STRING(name), "*")) {
                int r = symtable_add_def(st, store_name, DEF_IMPORT); 
                Py_DECREF(store_name);
                return r;
index 9564267dd6c919ba1d8ea52d87d748246e73b49d..64ea89fa6377ec356c4bf0115c638ba92f7a05ca 100644 (file)
@@ -229,7 +229,7 @@ exit status will be one (i.e., failure)."
 static PyObject *
 sys_getdefaultencoding(PyObject *self)
 {
-       return PyBytes_FromString(PyUnicode_GetDefaultEncoding());
+       return PyString_FromString(PyUnicode_GetDefaultEncoding());
 }
 
 PyDoc_STRVAR(getdefaultencoding_doc,
@@ -261,7 +261,7 @@ static PyObject *
 sys_getfilesystemencoding(PyObject *self)
 {
        if (Py_FileSystemDefaultEncoding)
-               return PyBytes_FromString(Py_FileSystemDefaultEncoding);
+               return PyString_FromString(Py_FileSystemDefaultEncoding);
        Py_INCREF(Py_None);
        return Py_None;
 }
@@ -290,7 +290,7 @@ trace_init(void)
        int i;
        for (i = 0; i < 7; ++i) {
                if (whatstrings[i] == NULL) {
-                       name = PyBytes_InternFromString(whatnames[i]);
+                       name = PyString_InternFromString(whatnames[i]);
                        if (name == NULL)
                                return -1;
                        whatstrings[i] = name;
@@ -931,7 +931,7 @@ list_builtin_module_names(void)
        if (list == NULL)
                return NULL;
        for (i = 0; PyImport_Inittab[i].name != NULL; i++) {
-               PyObject *name = PyBytes_FromString(
+               PyObject *name = PyString_FromString(
                        PyImport_Inittab[i].name);
                if (name == NULL)
                        break;
@@ -971,7 +971,7 @@ PySys_AddWarnOption(char *s)
                if (warnoptions == NULL)
                        return;
        }
-       str = PyBytes_FromString(s);
+       str = PyString_FromString(s);
        if (str != NULL) {
                PyList_Append(warnoptions, str);
                Py_DECREF(str);
@@ -1327,7 +1327,7 @@ _PySys_Init(void)
        Py_XDECREF(syserr);
 
        SET_SYS_FROM_STRING("version",
-                            PyBytes_FromString(Py_GetVersion()));
+                            PyString_FromString(Py_GetVersion()));
        SET_SYS_FROM_STRING("hexversion",
                             PyInt_FromLong(PY_VERSION_HEX));
        svnversion_init();
@@ -1358,15 +1358,15 @@ _PySys_Init(void)
        SET_SYS_FROM_STRING("api_version",
                            PyInt_FromLong(PYTHON_API_VERSION));
        SET_SYS_FROM_STRING("copyright",
-                           PyBytes_FromString(Py_GetCopyright()));
+                           PyString_FromString(Py_GetCopyright()));
        SET_SYS_FROM_STRING("platform",
-                           PyBytes_FromString(Py_GetPlatform()));
+                           PyString_FromString(Py_GetPlatform()));
        SET_SYS_FROM_STRING("executable",
-                           PyBytes_FromString(Py_GetProgramFullPath()));
+                           PyString_FromString(Py_GetProgramFullPath()));
        SET_SYS_FROM_STRING("prefix",
-                           PyBytes_FromString(Py_GetPrefix()));
+                           PyString_FromString(Py_GetPrefix()));
        SET_SYS_FROM_STRING("exec_prefix",
-                           PyBytes_FromString(Py_GetExecPrefix()));
+                           PyString_FromString(Py_GetExecPrefix()));
        SET_SYS_FROM_STRING("maxsize",
                            PyInt_FromSsize_t(PY_SSIZE_T_MAX));
        SET_SYS_FROM_STRING("maxint",
@@ -1393,13 +1393,13 @@ _PySys_Init(void)
                else
                        value = "little";
                SET_SYS_FROM_STRING("byteorder",
-                                   PyBytes_FromString(value));
+                                   PyString_FromString(value));
        }
 #ifdef MS_COREDLL
        SET_SYS_FROM_STRING("dllhandle",
                            PyLong_FromVoidPtr(PyWin_DLLhModule));
        SET_SYS_FROM_STRING("winver",
-                           PyBytes_FromString(PyWin_DLLVersionString));
+                           PyString_FromString(PyWin_DLLVersionString));
 #endif
        if (warnoptions == NULL) {
                warnoptions = PyList_New(0);
@@ -1444,7 +1444,7 @@ makepathobject(char *path, int delim)
                p = strchr(path, delim);
                if (p == NULL)
                        p = strchr(path, '\0'); /* End of string */
-               w = PyBytes_FromStringAndSize(path, (Py_ssize_t) (p - path));
+               w = PyString_FromStringAndSize(path, (Py_ssize_t) (p - path));
                if (w == NULL) {
                        Py_DECREF(v);
                        return NULL;
@@ -1489,14 +1489,14 @@ makeargvobject(int argc, char **argv)
                        if (i == 0) {
                                char* fn = decc$translate_vms(argv[0]);
                                if ((fn == (char *)0) || fn == (char *)-1)
-                                       v = PyBytes_FromString(argv[0]);
+                                       v = PyString_FromString(argv[0]);
                                else
-                                       v = PyBytes_FromString(
+                                       v = PyString_FromString(
                                                decc$translate_vms(argv[0]));
                        } else
-                               v = PyBytes_FromString(argv[i]);
+                               v = PyString_FromString(argv[i]);
 #else
-                       PyObject *v = PyBytes_FromString(argv[i]);
+                       PyObject *v = PyString_FromString(argv[i]);
 #endif
                        if (v == NULL) {
                                Py_DECREF(av);
@@ -1600,7 +1600,7 @@ PySys_SetArgv(int argc, char **argv)
 #endif /* Unix */
                }
 #endif /* All others */
-               a = PyBytes_FromStringAndSize(argv0, n);
+               a = PyString_FromStringAndSize(argv0, n);
                if (a == NULL)
                        Py_FatalError("no mem for sys.path insertion");
                if (PyList_Insert(path, 0, a) < 0)
index adf9a535522553b69ac33665a1573c87509872e0..a4819634d83642a67e7b44319f5c32973c779f75 100644 (file)
@@ -155,12 +155,12 @@ Py_DisplaySourceLine(PyObject *f, const char *filename, int lineno)
                                        PyErr_Clear();
                                        break;
                                }
-                               if (PyBytes_Check(v)) {
+                               if (PyString_Check(v)) {
                                        size_t len;
-                                       len = PyBytes_GET_SIZE(v);
+                                       len = PyString_GET_SIZE(v);
                                        if (len + 1 + taillen >= MAXPATHLEN)
                                                continue; /* Too long */
-                                       strcpy(namebuf, PyBytes_AsString(v));
+                                       strcpy(namebuf, PyString_AsString(v));
                                        if (strlen(namebuf) != len)
                                                continue; /* v contains '\0' */
                                        if (len > 0 && namebuf[len-1] != SEP)
@@ -238,10 +238,10 @@ tb_printinternal(PyTracebackObject *tb, PyObject *f, long limit)
        while (tb != NULL && err == 0) {
                if (depth <= limit) {
                        err = tb_displayline(f,
-                           PyBytes_AsString(
+                           PyString_AsString(
                                    tb->tb_frame->f_code->co_filename),
                            tb->tb_lineno,
-                           PyBytes_AsString(tb->tb_frame->f_code->co_name));
+                           PyString_AsString(tb->tb_frame->f_code->co_name));
                }
                depth--;
                tb = tb->tb_next;
index 61aadd397fbe98aaf361e82030eddb79d829b3e3..5f8dc3e95f38f5716f885c9dd35aca3f5d72dabe 100644 (file)
@@ -333,7 +333,7 @@ static PyObject *DrawF_FontTable(PyDrawFObject *self,PyObject *arg)
   char *dtable;
   if(!PyArg_ParseTuple(arg,"O!",&PyDict_Type,&d)) return NULL;
   while(PyDict_Next(d,&n,&key,&value))
-  { int m=PyBytes_Size(value);
+  { int m=PyString_Size(value);
     if(m<0||!PyInt_Check(key)) return NULL;
     size+=m+2;
   }
@@ -350,9 +350,9 @@ static PyObject *DrawF_FontTable(PyDrawFObject *self,PyObject *arg)
   memset(dtable,0,size-8);
   n=0;
   while(PyDict_Next(d,&n,&key,&value))
-  { int m=PyBytes_Size(value);
+  { int m=PyString_Size(value);
     *dtable=(char)PyInt_AsLong(key);
-    strcpy(dtable+1,PyBytes_AsString(value));
+    strcpy(dtable+1,PyString_AsString(value));
     dtable+=m+2;
   }
   Py_INCREF(Py_None);return Py_None;
@@ -609,8 +609,8 @@ static PyObject *PyDrawF_GetAttr(PyDrawFObject *s,char *name)
   if (!strcmp(name, "__members__"))
   { PyObject *list = PyList_New(2);
     if (list)
-    { PyList_SetItem(list, 0, PyBytes_FromString("size"));
-      PyList_SetItem(list, 1, PyBytes_FromString("start"));
+    { PyList_SetItem(list, 0, PyString_FromString("size"));
+      PyList_SetItem(list, 1, PyString_FromString("start"));
       if (PyErr_Occurred()) { Py_DECREF(list);list = NULL;}
     }
     return list;
@@ -659,6 +659,6 @@ void initdrawf()
 { PyObject *m, *d;
   m = Py_InitModule("drawf", DrawFMethods);
   d = PyModule_GetDict(m);
-  DrawFError=PyBytes_FromString("drawf.error");
+  DrawFError=PyString_FromString("drawf.error");
   PyDict_SetItemString(d,"error",DrawFError);
 }
index cf37e182c3f8af2d5cdd0151be24da7c4b9253d3..3dabb4d589413635f49cd0a3e9cb371a862d437b 100644 (file)
@@ -79,9 +79,9 @@ canon(char *path)
   char *buf;
   e=xosfscontrol_canonicalise_path(path,0,0,0,0,&len);
   if(e) return riscos_oserror();
-  obj=PyBytes_FromStringAndSize(NULL,-len);
+  obj=PyString_FromStringAndSize(NULL,-len);
   if(obj==NULL) return NULL;
-  buf=PyBytes_AsString(obj);
+  buf=PyString_AsString(obj);
   e=xosfscontrol_canonicalise_path(path,buf,0,0,1-len,&len);
   if(len!=1) return riscos_error("Error expanding path");
   if(!e) return obj;
@@ -131,7 +131,7 @@ riscos_listdir(PyObject *self, PyObject *args)
          { Py_DECREF(d);return riscos_oserror();
          }
          if(count)
-         { v=PyBytes_FromString(buf);
+         { v=PyString_FromString(buf);
            if(!v) { Py_DECREF(d);return 0;}
            if(PyList_Append(d,v)) {Py_DECREF(d);Py_DECREF(v);return 0;}
          }
@@ -320,7 +320,7 @@ riscos_getenv(PyObject *self, PyObject *args)
   char *name,*value;
   if(!PyArg_ParseTuple(args,"s:getenv",&name)) return NULL;
   value=getenv(name);
-  if(value) return PyBytes_FromString(value);
+  if(value) return PyString_FromString(value);
   Py_INCREF(Py_None);
   return Py_None;
 }
@@ -371,7 +371,7 @@ riscos_getenvdict(PyObject *self, PyObject *args)
          os_VARTYPE_EXPANDED,&size,(int *)&context,0))
   { PyObject *v;
     value[size]='\0';
-    v = PyBytes_FromString(value);
+    v = PyString_FromString(value);
     if (v == NULL) continue;
     PyDict_SetItemString(dict, context, v);
     Py_DECREF(v);
index 18be42e6f9f750c7f77c6ef9c6f09ef2afd31e23..b241276a18d5025b8e6ae23b2277ae54d9588f54 100644 (file)
@@ -66,10 +66,10 @@ static PyObject *PyBlock_New(PyObject *self,PyObject *args)
   b->length=4*size;
   b->heap=1;
   if(init)
-  { if(PyBytes_Check(init))
-    { int n=PyBytes_Size(init);
+  { if(PyString_Check(init))
+    { int n=PyString_Size(init);
       if (n>4*size) n=4*size;
-      memcpy(b->block,PyBytes_AsString(init),n);
+      memcpy(b->block,PyString_AsString(init),n);
       memset((char*)b->block+n,0,4*size-n);
     }
     else
@@ -113,7 +113,7 @@ static PyObject *PyBlock_ToString(PyBlockObject *self,PyObject *arg)
   { PyErr_SetString(PyExc_IndexError,"block index out of range");
     return NULL;
   }
-  return PyBytes_FromStringAndSize((char*)self->block+s,e-s);
+  return PyString_FromStringAndSize((char*)self->block+s,e-s);
 }
 
 static PyObject *PyBlock_NullString(PyBlockObject *self,PyObject *arg)
@@ -125,7 +125,7 @@ static PyObject *PyBlock_NullString(PyBlockObject *self,PyObject *arg)
     return NULL;
   }
   for(i=s;i<e;i++) if(p[i]==0) break;
-  return PyBytes_FromStringAndSize((char*)self->block+s,i-s);
+  return PyString_FromStringAndSize((char*)self->block+s,i-s);
 }
 
 static PyObject *PyBlock_CtrlString(PyBlockObject *self,PyObject *arg)
@@ -137,7 +137,7 @@ static PyObject *PyBlock_CtrlString(PyBlockObject *self,PyObject *arg)
     return NULL;
   }
   for(i=s;i<e;i++) if(p[i]<32) break;
-  return PyBytes_FromStringAndSize((char*)self->block+s,i-s);
+  return PyString_FromStringAndSize((char*)self->block+s,i-s);
 }
 
 static PyObject *PyBlock_PadString(PyBlockObject *self,PyObject *arg)
@@ -296,9 +296,9 @@ static PyObject *PyBlock_GetAttr(PyBlockObject *s,char *name)
   if (!strcmp(name, "__members__"))
   { PyObject *list = PyList_New(3);
     if (list)
-    { PyList_SetItem(list, 0, PyBytes_FromString("length"));
-      PyList_SetItem(list, 1, PyBytes_FromString("start"));
-      PyList_SetItem(list, 2, PyBytes_FromString("end"));
+    { PyList_SetItem(list, 0, PyString_FromString("length"));
+      PyList_SetItem(list, 1, PyString_FromString("start"));
+      PyList_SetItem(list, 2, PyString_FromString("end"));
       if (PyErr_Occurred()) { Py_DECREF(list);list = NULL;}
     }
     return list;
@@ -402,7 +402,7 @@ static PyObject *swi_swi(PyObject *self,PyObject *args)
   for(;*fmt;fmt++)
   {  switch(*fmt)
     { case 'i':v=PyInt_FromLong((long)r.r[rno++]); break;
-      case 's':v=PyBytes_FromString((char*)(r.r[rno++])); break;
+      case 's':v=PyString_FromString((char*)(r.r[rno++])); break;
       case '.':rno++; continue;
       case '*':v=PyInt_FromLong((long)carry); break;
     }
@@ -421,7 +421,7 @@ static PyObject *swi_string(PyObject *self, PyObject *arg)
   if(!PyArg_ParseTuple(arg,"i|i",(unsigned int *)&s, &l)) return NULL;
   if (l==-1)
     l = strlen(s);
-  return PyBytes_FromStringAndSize((char*)s, l);
+  return PyString_FromStringAndSize((char*)s, l);
 }
 
 static char swi_string__doc__[] =