aboutsummaryrefslogtreecommitdiffstats
path: root/libshiboken
diff options
context:
space:
mode:
authorHugo Parente Lima <hugo.pl@gmail.com>2011-09-14 15:25:11 -0300
committerHugo Parente Lima <hugo.pl@gmail.com>2012-03-08 16:17:14 -0300
commitdfd3c75a8ba6bc8a1ac42909d96bc6d4c11c6bd7 (patch)
treea4df32a57533616d7b7f975d23d0ca9d9cd0f3af /libshiboken
parent31c44fea50380513bdc16d58891ba9e5ba7ecc31 (diff)
Replaced all PyString_* by PyBytes_* as preparation for a Python 3.x port.
Diffstat (limited to 'libshiboken')
-rw-r--r--libshiboken/bindingmanager.cpp2
-rw-r--r--libshiboken/conversions.h22
-rw-r--r--libshiboken/helper.cpp8
-rw-r--r--libshiboken/sbkdbg.h2
-rw-r--r--libshiboken/sbkenum.cpp8
5 files changed, 21 insertions, 21 deletions
diff --git a/libshiboken/bindingmanager.cpp b/libshiboken/bindingmanager.cpp
index a8d4b0a06..09d6fc962 100644
--- a/libshiboken/bindingmanager.cpp
+++ b/libshiboken/bindingmanager.cpp
@@ -241,7 +241,7 @@ PyObject* BindingManager::getOverride(const void* cptr, const char* methodName)
}
}
- PyObject* pyMethodName = PyString_FromString(methodName);
+ PyObject* pyMethodName = PyBytes_FromString(methodName);
PyObject* method = PyObject_GetAttr((PyObject*)wrapper, pyMethodName);
if (method && PyMethod_Check(method)
diff --git a/libshiboken/conversions.h b/libshiboken/conversions.h
index e117dbe45..350ab9541 100644
--- a/libshiboken/conversions.h
+++ b/libshiboken/conversions.h
@@ -350,7 +350,7 @@ struct Converter_PyULongInt : Converter_PyInt<T>
/// Check if we can treat the pyobj as a char, i.e. it's a number or a string with just one character.
-#define SbkChar_Check(pyobj) (SbkNumber_Check(pyobj) || (PyString_Check(pyobj) && PyString_Size(pyobj) == 1))
+#define SbkChar_Check(pyobj) (SbkNumber_Check(pyobj) || (PyBytes_Check(pyobj) && PyBytes_GET_SIZE(pyobj) == 1))
/// Specialization to convert char and unsigned char, it accepts Python numbers and strings with just one character.
template <typename CharType>
@@ -362,9 +362,9 @@ struct CharConverter
static inline PyObject* toPython(const CharType& cppobj) { return PyInt_FromLong(cppobj); }
static CharType toCpp(PyObject* pyobj)
{
- if (PyString_Check(pyobj)) {
- assert(PyString_Size(pyobj) == 1); // This check is made on SbkChar_Check
- return PyString_AS_STRING(pyobj)[0];
+ if (PyBytes_Check(pyobj)) {
+ assert(PyBytes_GET_SIZE(pyobj) == 1); // This check is made on SbkChar_Check
+ return PyBytes_AS_STRING(pyobj)[0];
} else {
PY_LONG_LONG result = PyLong_AsLongLong(pyobj);
if (OverFlowChecker<CharType>::check(result))
@@ -380,7 +380,7 @@ template <> struct Converter<char> : CharConverter<char> {
// Should we really return a string?
using CharConverter<char>::toPython;
static inline PyObject* toPython(const char& cppObj) {
- return PyString_FromFormat("%c", cppObj);
+ return PyBytes_FromFormat("%c", cppObj);
}
};
template <> struct Converter<signed char> : CharConverter<signed char> {};
@@ -455,19 +455,19 @@ template <typename CString>
struct Converter_CString
{
// Note: 0 is also a const char* in C++, so None is accepted in checkType
- static inline bool checkType(PyObject* pyObj) { return pyObj == Py_None || PyString_Check(pyObj); }
- static inline bool isConvertible(PyObject* pyObj) { return pyObj == Py_None || PyString_Check(pyObj); }
+ static inline bool checkType(PyObject* pyObj) { return pyObj == Py_None || PyBytes_Check(pyObj); }
+ static inline bool isConvertible(PyObject* pyObj) { return pyObj == Py_None || PyBytes_Check(pyObj); }
static inline PyObject* toPython(void* cppobj) { return toPython(reinterpret_cast<CString>(cppobj)); }
static inline PyObject* toPython(CString cppobj)
{
if (!cppobj)
Py_RETURN_NONE;
- return PyString_FromString(cppobj);
+ return PyBytes_FromString(cppobj);
}
static inline CString toCpp(PyObject* pyobj) {
if (pyobj == Py_None)
return 0;
- return PyString_AsString(pyobj);
+ return PyBytes_AS_STRING(pyobj);
}
};
@@ -478,14 +478,14 @@ template <> struct Converter<std::string> : Converter_CString<std::string>
static inline PyObject* toPython(void* cppobj) { return toPython(*reinterpret_cast<std::string*>(cppobj)); }
static inline PyObject* toPython(std::string cppObj)
{
- return PyString_FromString(cppObj.c_str());
+ return PyBytes_FromString(cppObj.c_str());
}
static inline std::string toCpp(PyObject* pyobj)
{
if (pyobj == Py_None)
return 0;
- return std::string(PyString_AsString(pyobj));
+ return std::string(PyBytes_AS_STRING(pyobj));
}
};
diff --git a/libshiboken/helper.cpp b/libshiboken/helper.cpp
index 99b176447..4a7df66cd 100644
--- a/libshiboken/helper.cpp
+++ b/libshiboken/helper.cpp
@@ -39,7 +39,7 @@ bool sequenceToArgcArgv(PyObject* argList, int* argc, char*** argv, const char*
int numArgs = PySequence_Fast_GET_SIZE(argList);
for (int i = 0; i < numArgs; ++i) {
PyObject* item = PySequence_Fast_GET_ITEM(args.object(), i);
- if (!PyString_Check(item) && !PyUnicode_Check(item))
+ if (!PyBytes_Check(item) && !PyUnicode_Check(item))
return false;
}
@@ -54,16 +54,16 @@ bool sequenceToArgcArgv(PyObject* argList, int* argc, char*** argv, const char*
// Try to get the script name
PyObject* globals = PyEval_GetGlobals();
PyObject* appName = PyDict_GetItemString(globals, "__file__");
- (*argv)[0] = strdup(appName ? PyString_AS_STRING(appName) : defaultAppName);
+ (*argv)[0] = strdup(appName ? PyBytes_AS_STRING(appName) : defaultAppName);
} else {
for (int i = 0; i < numArgs; ++i) {
PyObject* item = PySequence_Fast_GET_ITEM(args.object(), i);
char* string;
if (PyUnicode_Check(item)) {
Shiboken::AutoDecRef utf8(PyUnicode_AsUTF8String(item));
- string = strdup(PyString_AS_STRING(utf8.object()));
+ string = strdup(PyBytes_AS_STRING(utf8.object()));
} else {
- string = strdup(PyString_AS_STRING(item));
+ string = strdup(PyBytes_AS_STRING(item));
}
(*argv)[i] = string;
}
diff --git a/libshiboken/sbkdbg.h b/libshiboken/sbkdbg.h
index 7c2bd6030..44d57baf4 100644
--- a/libshiboken/sbkdbg.h
+++ b/libshiboken/sbkdbg.h
@@ -71,7 +71,7 @@ inline std::ostream& operator<<(std::ostream& out, PyObject* obj)
{
PyObject* repr = Shiboken::Object::isValid(obj, false) ? PyObject_Repr(obj) : 0;
if (repr) {
- out << PyString_AS_STRING(repr);
+ out << PyBytes_AS_STRING(repr);
Py_DECREF(repr);
} else {
out << reinterpret_cast<void*>(obj);
diff --git a/libshiboken/sbkenum.cpp b/libshiboken/sbkenum.cpp
index 0c4a9b663..f8d284ed7 100644
--- a/libshiboken/sbkenum.cpp
+++ b/libshiboken/sbkenum.cpp
@@ -43,9 +43,9 @@ static PyObject* SbkEnumObject_repr(PyObject* self)
{
PyObject* enumName = ((SbkEnumObject*)self)->ob_name;
if (enumName)
- return PyString_FromFormat("%s.%s", self->ob_type->tp_name, PyString_AS_STRING(enumName));
+ return PyBytes_FromFormat("%s.%s", self->ob_type->tp_name, PyBytes_AS_STRING(enumName));
else
- return PyString_FromFormat("%s(%ld)", self->ob_type->tp_name, ((SbkEnumObject*)self)->ob_ival);
+ return PyBytes_FromFormat("%s(%ld)", self->ob_type->tp_name, ((SbkEnumObject*)self)->ob_ival);
}
static int SbkEnumObject_print(PyObject* self, FILE* fp, int)
@@ -53,7 +53,7 @@ static int SbkEnumObject_print(PyObject* self, FILE* fp, int)
Py_BEGIN_ALLOW_THREADS
PyObject* enumName = ((SbkEnumObject*)self)->ob_name;
if (enumName)
- fprintf(fp, "%s.%s", self->ob_type->tp_name, PyString_AS_STRING(enumName));
+ fprintf(fp, "%s.%s", self->ob_type->tp_name, PyBytes_AS_STRING(enumName));
else
fprintf(fp, "%s(%ld)", self->ob_type->tp_name, ((SbkEnumObject*)self)->ob_ival);
Py_END_ALLOW_THREADS
@@ -264,7 +264,7 @@ PyObject* newItem(PyTypeObject* enumType, long itemValue, const char* itemName)
if (!enumObj)
return 0;
- enumObj->ob_name = itemName ? PyString_FromString(itemName) : 0;
+ enumObj->ob_name = itemName ? PyBytes_FromString(itemName) : 0;
enumObj->ob_ival = itemValue;
if (newValue) {