From 2c7c76a668c967b63f0ade07e93d82854067f246 Mon Sep 17 00:00:00 2001 From: remi-k Date: Fri, 6 Mar 2009 17:21:37 +0000 Subject: [PATCH] Fixed python3 compatibility git-svn-id: https://sfml.svn.sourceforge.net/svnroot/sfml/trunk@1041 4e206d99-4929-0410-ac5d-dfc041789085 --- python/src/Drawable.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/python/src/Drawable.cpp b/python/src/Drawable.cpp index cedc38b43..99e6c419e 100644 --- a/python/src/Drawable.cpp +++ b/python/src/Drawable.cpp @@ -233,13 +233,22 @@ PySfDrawable_TransformToGlobal(PySfDrawable* self, PyObject *args) 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)); +#endif if (Name == "Render") { Py_CLEAR(((PySfDrawable*)self)->obj->RenderFunction); Py_INCREF(v); ((PySfDrawable*)self)->obj->RenderFunction = v; } +#ifdef IS_PY3K + Py_DECREF(string); +#endif return PyObject_GenericSetAttr(self, attr_name, v); }