diff --git libpyside/pysideqflags.cpp libpyside/pysideqflags.cpp
index d2382cd..b0f3570 100644
--- libpyside/pysideqflags.cpp
+++ libpyside/pysideqflags.cpp
@@ -118,7 +118,7 @@ namespace QFlags
     {
         PyTypeObject* type = reinterpret_cast<PyTypeObject*>(new PySideQFlagsType);
         ::memset(type, 0, sizeof(PySideQFlagsType));
-        Py_TYPE(type) = &PyType_Type;
+        Py_SET_TYPE(type, &PyType_Type);
         type->tp_basicsize = sizeof(PySideQFlagsObject);
         type->tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_CHECKTYPES;
         type->tp_name = name;
diff --git libpyside/pysideweakref.cpp libpyside/pysideweakref.cpp
index 3f4dfd7..8cab623 100644
--- libpyside/pysideweakref.cpp
+++ libpyside/pysideweakref.cpp
@@ -53,7 +53,7 @@ PyObject* create(PyObject* obj, PySideWeakRefFunction func, void* userData)
 
     if (Py_TYPE(&PySideCallableObjectType) == 0)
     {
-        Py_TYPE(&PySideCallableObjectType) = &PyType_Type;
+        Py_SET_TYPE(&PySideCallableObjectType, &PyType_Type);
         PyType_Ready(&PySideCallableObjectType);
     }
 
