Fixed python3 compatibility

git-svn-id: https://sfml.svn.sourceforge.net/svnroot/sfml/trunk@1041 4e206d99-4929-0410-ac5d-dfc041789085
This commit is contained in:
remi-k 2009-03-06 17:21:37 +00:00
parent bcbb754da9
commit 2c7c76a668

View File

@ -233,13 +233,22 @@ PySfDrawable_TransformToGlobal(PySfDrawable* self, PyObject *args)
int PySfDrawable_SetAttr(PyObject* self, PyObject *attr_name, PyObject *v) int PySfDrawable_SetAttr(PyObject* self, PyObject *attr_name, PyObject *v)
{ {
#ifdef IS_PY3K
PyObject *string = PyUnicode_AsUTF8String(attr_name);
if (string == NULL) return NULL;
std::string Name(PyBytes_AsString(string));
#else
std::string Name(PyString_AsString(attr_name)); std::string Name(PyString_AsString(attr_name));
#endif
if (Name == "Render") if (Name == "Render")
{ {
Py_CLEAR(((PySfDrawable*)self)->obj->RenderFunction); Py_CLEAR(((PySfDrawable*)self)->obj->RenderFunction);
Py_INCREF(v); Py_INCREF(v);
((PySfDrawable*)self)->obj->RenderFunction = v; ((PySfDrawable*)self)->obj->RenderFunction = v;
} }
#ifdef IS_PY3K
Py_DECREF(string);
#endif
return PyObject_GenericSetAttr(self, attr_name, v); return PyObject_GenericSetAttr(self, attr_name, v);
} }