py3.7 fix
PyUnicode_AsUTF8() returns const char* in py3.7 instead of char*. Making changes to reflect that which should also be safe in other Python versions.
This commit is contained in:
@@ -141,7 +141,7 @@ PyMethodDef PyObjectBase::Methods[] = {
|
||||
|
||||
PyObject* PyObjectBase::__getattro(PyObject * obj, PyObject *attro)
|
||||
{
|
||||
char *attr;
|
||||
const char *attr;
|
||||
#if PY_MAJOR_VERSION >= 3
|
||||
attr = PyUnicode_AsUTF8(attro);
|
||||
#else
|
||||
@@ -195,7 +195,7 @@ PyObject* PyObjectBase::__getattro(PyObject * obj, PyObject *attro)
|
||||
|
||||
int PyObjectBase::__setattro(PyObject *obj, PyObject *attro, PyObject *value)
|
||||
{
|
||||
char *attr;
|
||||
const char *attr;
|
||||
#if PY_MAJOR_VERSION >= 3
|
||||
attr = PyUnicode_AsUTF8(attro);
|
||||
#else
|
||||
@@ -236,7 +236,7 @@ int PyObjectBase::__setattro(PyObject *obj, PyObject *attro, PyObject *value)
|
||||
/*------------------------------
|
||||
* PyObjectBase attributes -- attributes
|
||||
------------------------------*/
|
||||
PyObject *PyObjectBase::_getattr(char *attr)
|
||||
PyObject *PyObjectBase::_getattr(const char *attr)
|
||||
{
|
||||
if (streq(attr, "__class__")) {
|
||||
// Note: We must return the type object here,
|
||||
@@ -279,7 +279,7 @@ PyObject *PyObjectBase::_getattr(char *attr)
|
||||
}
|
||||
}
|
||||
|
||||
int PyObjectBase::_setattr(char *attr, PyObject *value)
|
||||
int PyObjectBase::_setattr(const char *attr, PyObject *value)
|
||||
{
|
||||
if (streq(attr,"softspace"))
|
||||
return -1; // filter out softspace
|
||||
|
||||
@@ -231,7 +231,7 @@ public:
|
||||
* need to call the method of the base class! Otherwise even the
|
||||
* methods of the object will disappear!
|
||||
*/
|
||||
virtual PyObject *_getattr(char *attr);
|
||||
virtual PyObject *_getattr(const char *attr);
|
||||
/// static wrapper for pythons _getattro()
|
||||
static PyObject *__getattro(PyObject * PyObj, PyObject *attro);
|
||||
|
||||
@@ -241,7 +241,7 @@ public:
|
||||
* this method.
|
||||
* You have to call the method of the base class.
|
||||
*/
|
||||
virtual int _setattr(char *attro, PyObject *value); // _setattr method
|
||||
virtual int _setattr(const char *attro, PyObject *value); // _setattr method
|
||||
/// static wrapper for pythons _setattro(). // This should be the entry in Type.
|
||||
static int __setattro(PyObject *PyObj, PyObject *attro, PyObject *value);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user