Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2009-08-10 04:07:34 +0400
committerCampbell Barton <ideasman42@gmail.com>2009-08-10 04:07:34 +0400
commit7440fee85c6d2d4c5854337ae8bf3ed7aea91a50 (patch)
tree1fdb611fab96ba5e7af468233211722e0ca2bb58 /source/blender
parentf71ef0874413d30be6d6e74500aa0a45628b5188 (diff)
remove python2.x support
Diffstat (limited to 'source/blender')
-rw-r--r--source/blender/nodes/intern/SHD_nodes/SHD_dynamic.c2
-rw-r--r--source/blender/python/generic/BGL.c15
-rw-r--r--source/blender/python/generic/BGL.h3
-rw-r--r--source/blender/python/generic/Geometry.c8
-rw-r--r--source/blender/python/generic/Geometry.h2
-rw-r--r--source/blender/python/generic/Mathutils.c15
-rw-r--r--source/blender/python/generic/Mathutils.h6
-rw-r--r--source/blender/python/generic/bpy_internal_import.c8
-rw-r--r--source/blender/python/generic/bpy_internal_import.h1
-rw-r--r--source/blender/python/generic/euler.c6
-rw-r--r--source/blender/python/generic/euler.h1
-rw-r--r--source/blender/python/generic/matrix.c42
-rw-r--r--source/blender/python/generic/quat.c34
-rw-r--r--source/blender/python/generic/quat.h1
-rw-r--r--source/blender/python/generic/vector.c76
-rw-r--r--source/blender/python/generic/vector.h1
-rw-r--r--source/blender/python/intern/bpy_compat.h126
-rw-r--r--source/blender/python/intern/bpy_interface.c20
-rw-r--r--source/blender/python/intern/bpy_operator.c1
-rw-r--r--source/blender/python/intern/bpy_operator_wrap.c1
-rw-r--r--source/blender/python/intern/bpy_rna.c39
-rw-r--r--source/blender/python/intern/bpy_ui.c7
-rw-r--r--source/blender/python/intern/bpy_util.c4
-rw-r--r--source/blender/python/intern/bpy_util.h5
24 files changed, 21 insertions, 403 deletions
diff --git a/source/blender/nodes/intern/SHD_nodes/SHD_dynamic.c b/source/blender/nodes/intern/SHD_nodes/SHD_dynamic.c
index fbc56dfcc83..693a20b5b0f 100644
--- a/source/blender/nodes/intern/SHD_nodes/SHD_dynamic.c
+++ b/source/blender/nodes/intern/SHD_nodes/SHD_dynamic.c
@@ -34,9 +34,7 @@
#endif
/* TODO, support python3.x */
-#if PY_VERSION_HEX >= 0x03000000
#define DISABLE_PYTHON 1
-#endif
#include "DNA_text_types.h"
#include "BKE_text.h"
diff --git a/source/blender/python/generic/BGL.c b/source/blender/python/generic/BGL.c
index de82781cf3a..2fd9130857f 100644
--- a/source/blender/python/generic/BGL.c
+++ b/source/blender/python/generic/BGL.c
@@ -83,13 +83,7 @@ static PyObject *Buffer_getattr( PyObject * self, char *name );
static PyObject *Buffer_repr( PyObject * self );
PyTypeObject buffer_Type = {
-#if (PY_VERSION_HEX >= 0x02060000)
PyVarObject_HEAD_INIT(NULL, 0)
-#else
- /* python 2.5 and below */
- PyObject_HEAD_INIT( NULL ) /* required py macro */
- 0, /* ob_size */
-#endif
"buffer", /*tp_name */
sizeof( Buffer ), /*tp_basicsize */
0, /*tp_itemsize */
@@ -1090,7 +1084,6 @@ static struct PyMethodDef BGL_methods[] = {
{NULL, NULL, 0, NULL}
};
-#if (PY_VERSION_HEX >= 0x03000000)
static struct PyModuleDef BGL_module_def = {
PyModuleDef_HEAD_INIT,
"BGL", /* m_name */
@@ -1102,17 +1095,13 @@ static struct PyModuleDef BGL_module_def = {
0, /* m_clear */
0, /* m_free */
};
-#endif
-PyObject *BGL_Init(const char *from)
+
+PyObject *BGL_Init(void)
{
PyObject *mod, *dict, *item;
-#if (PY_VERSION_HEX >= 0x03000000)
mod = PyModule_Create(&BGL_module_def);
PyDict_SetItemString(PySys_GetObject("modules"), BGL_module_def.m_name, mod);
-#else
- mod= Py_InitModule(from, BGL_methods);
-#endif
dict= PyModule_GetDict(mod);
if( PyType_Ready( &buffer_Type) < 0)
diff --git a/source/blender/python/generic/BGL.h b/source/blender/python/generic/BGL.h
index 938c916bcea..a8c37bf3edd 100644
--- a/source/blender/python/generic/BGL.h
+++ b/source/blender/python/generic/BGL.h
@@ -42,9 +42,8 @@
#include <Python.h>
#include <GL/glew.h>
-#include "../intern/bpy_compat.h"
-PyObject *BGL_Init( const char *from );
+PyObject *BGL_Init(void);
/*@ Buffer Object */
/*@ For Python access to OpenGL functions requiring a pointer. */
diff --git a/source/blender/python/generic/Geometry.c b/source/blender/python/generic/Geometry.c
index b4a34d30051..70295d1c2d9 100644
--- a/source/blender/python/generic/Geometry.c
+++ b/source/blender/python/generic/Geometry.c
@@ -78,7 +78,6 @@ struct PyMethodDef M_Geometry_methods[] = {
{NULL, NULL, 0, NULL}
};
-#if (PY_VERSION_HEX >= 0x03000000)
static struct PyModuleDef M_Geometry_module_def = {
PyModuleDef_HEAD_INIT,
"Geometry", /* m_name */
@@ -90,19 +89,14 @@ static struct PyModuleDef M_Geometry_module_def = {
0, /* m_clear */
0, /* m_free */
};
-#endif
/*----------------------------MODULE INIT-------------------------*/
-PyObject *Geometry_Init(const char *from)
+PyObject *Geometry_Init(void)
{
PyObject *submodule;
-#if (PY_VERSION_HEX >= 0x03000000)
submodule = PyModule_Create(&M_Geometry_module_def);
PyDict_SetItemString(PySys_GetObject("modules"), M_Geometry_module_def.m_name, submodule);
-#else
- submodule = Py_InitModule3(from, M_Geometry_methods, M_Geometry_doc);
-#endif
return (submodule);
}
diff --git a/source/blender/python/generic/Geometry.h b/source/blender/python/generic/Geometry.h
index ebfb054c54a..0e46c0d18db 100644
--- a/source/blender/python/generic/Geometry.h
+++ b/source/blender/python/generic/Geometry.h
@@ -34,6 +34,6 @@
#include <Python.h>
#include "Mathutils.h"
-PyObject *Geometry_Init( const char *from );
+PyObject *Geometry_Init(void);
#endif /* EXPP_Geometry_H */
diff --git a/source/blender/python/generic/Mathutils.c b/source/blender/python/generic/Mathutils.c
index 53077659655..f53fd66ba99 100644
--- a/source/blender/python/generic/Mathutils.c
+++ b/source/blender/python/generic/Mathutils.c
@@ -94,7 +94,6 @@ struct PyMethodDef M_Mathutils_methods[] = {
/*----------------------------MODULE INIT-------------------------*/
/* from can be Blender.Mathutils or GameLogic.Mathutils for the BGE */
-#if (PY_VERSION_HEX >= 0x03000000)
static struct PyModuleDef M_Mathutils_module_def = {
PyModuleDef_HEAD_INIT,
"Mathutils", /* m_name */
@@ -106,21 +105,13 @@ static struct PyModuleDef M_Mathutils_module_def = {
0, /* m_clear */
0, /* m_free */
};
-#endif
-PyObject *Mathutils_Init(const char *from)
+PyObject *Mathutils_Init(void)
{
PyObject *submodule;
//seed the generator for the rand function
BLI_srand((unsigned int) (PIL_check_seconds_timer() * 0x7FFFFFFF));
-
-#if (PY_VERSION_HEX < 0x03000000)
- vector_Type.tp_flags |= Py_TPFLAGS_CHECKTYPES;
- matrix_Type.tp_flags |= Py_TPFLAGS_CHECKTYPES;
- euler_Type.tp_flags |= Py_TPFLAGS_CHECKTYPES;
- quaternion_Type.tp_flags |= Py_TPFLAGS_CHECKTYPES;
-#endif
if( PyType_Ready( &vector_Type ) < 0 )
return NULL;
@@ -131,12 +122,8 @@ PyObject *Mathutils_Init(const char *from)
if( PyType_Ready( &quaternion_Type ) < 0 )
return NULL;
-#if (PY_VERSION_HEX >= 0x03000000)
submodule = PyModule_Create(&M_Mathutils_module_def);
PyDict_SetItemString(PySys_GetObject("modules"), M_Mathutils_module_def.m_name, submodule);
-#else
- submodule = Py_InitModule3(from, M_Mathutils_methods, M_Mathutils_doc);
-#endif
/* each type has its own new() function */
PyModule_AddObject( submodule, "Vector", (PyObject *)&vector_Type );
diff --git a/source/blender/python/generic/Mathutils.h b/source/blender/python/generic/Mathutils.h
index 5bdd9d9cfe0..ad67d2e511e 100644
--- a/source/blender/python/generic/Mathutils.h
+++ b/source/blender/python/generic/Mathutils.h
@@ -32,7 +32,6 @@
#define EXPP_Mathutils_H
#include <Python.h>
-#include "../intern/bpy_compat.h"
#include "vector.h"
#include "matrix.h"
#include "quat.h"
@@ -55,10 +54,7 @@ PyObject *BaseMathObject_getOwner( BaseMathObject * self, void * );
PyObject *BaseMathObject_getWrapped( BaseMathObject *self, void * );
void BaseMathObject_dealloc(BaseMathObject * self);
-
-
-
-PyObject *Mathutils_Init( const char * from );
+PyObject *Mathutils_Init(void);
PyObject *quat_rotation(PyObject *arg1, PyObject *arg2);
diff --git a/source/blender/python/generic/bpy_internal_import.c b/source/blender/python/generic/bpy_internal_import.c
index 073cb58f1c8..05c846b16f5 100644
--- a/source/blender/python/generic/bpy_internal_import.c
+++ b/source/blender/python/generic/bpy_internal_import.c
@@ -179,20 +179,12 @@ static PyObject *blender_import( PyObject * self, PyObject * args, PyObject * k
PyObject *newmodule;
//PyObject_Print(args, stderr, 0);
-#if (PY_VERSION_HEX >= 0x02060000)
int dummy_val; /* what does this do?*/
static char *kwlist[] = {"name", "globals", "locals", "fromlist", "level", 0};
if( !PyArg_ParseTupleAndKeywords( args, kw, "s|OOOi:bpy_import_meth", kwlist,
&name, &globals, &locals, &fromlist, &dummy_val) )
return NULL;
-#else
- static char *kwlist[] = {"name", "globals", "locals", "fromlist", 0};
-
- if( !PyArg_ParseTupleAndKeywords( args, kw, "s|OOO:bpy_import_meth", kwlist,
- &name, &globals, &locals, &fromlist ) )
- return NULL;
-#endif
/* import existing builtin modules or modules that have been imported alredy */
newmodule = PyImport_ImportModuleEx( name, globals, locals, fromlist );
diff --git a/source/blender/python/generic/bpy_internal_import.h b/source/blender/python/generic/bpy_internal_import.h
index aeeafb7c1c4..c93d930dab0 100644
--- a/source/blender/python/generic/bpy_internal_import.h
+++ b/source/blender/python/generic/bpy_internal_import.h
@@ -32,7 +32,6 @@
#define EXPP_bpy_import_h
#include <Python.h>
-#include "../intern/bpy_compat.h"
#include "compile.h" /* for the PyCodeObject */
#include "eval.h" /* for PyEval_EvalCode */
diff --git a/source/blender/python/generic/euler.c b/source/blender/python/generic/euler.c
index 69373b1aa36..c6aaee64ebe 100644
--- a/source/blender/python/generic/euler.c
+++ b/source/blender/python/generic/euler.c
@@ -547,13 +547,7 @@ static PyGetSetDef Euler_getseters[] = {
//------------------PY_OBECT DEFINITION--------------------------
PyTypeObject euler_Type = {
-#if (PY_VERSION_HEX >= 0x02060000)
PyVarObject_HEAD_INIT(NULL, 0)
-#else
- /* python 2.5 and below */
- PyObject_HEAD_INIT( NULL ) /* required py macro */
- 0, /* ob_size */
-#endif
"euler", //tp_name
sizeof(EulerObject), //tp_basicsize
0, //tp_itemsize
diff --git a/source/blender/python/generic/euler.h b/source/blender/python/generic/euler.h
index a3706d53756..74d184fef81 100644
--- a/source/blender/python/generic/euler.h
+++ b/source/blender/python/generic/euler.h
@@ -32,7 +32,6 @@
#define EXPP_euler_h
#include <Python.h>
-#include "../intern/bpy_compat.h"
extern PyTypeObject euler_Type;
#define EulerObject_Check(_v) PyObject_TypeCheck((_v), &euler_Type)
diff --git a/source/blender/python/generic/matrix.c b/source/blender/python/generic/matrix.c
index 5bdbf804618..d4153243516 100644
--- a/source/blender/python/generic/matrix.c
+++ b/source/blender/python/generic/matrix.c
@@ -998,8 +998,6 @@ static PySequenceMethods Matrix_SeqMethods = {
};
-
-#if (PY_VERSION_HEX >= 0x03000000)
static PyObject *Matrix_subscript(MatrixObject* self, PyObject* item)
{
if (PyIndex_Check(item)) {
@@ -1071,11 +1069,8 @@ static PyMappingMethods Matrix_AsMapping = {
(binaryfunc)Matrix_subscript,
(objobjargproc)Matrix_ass_subscript
};
-#endif /* (PY_VERSION_HEX >= 0x03000000) */
-
-#if (PY_VERSION_HEX >= 0x03000000)
static PyNumberMethods Matrix_NumMethods = {
(binaryfunc) Matrix_add, /*nb_add*/
(binaryfunc) Matrix_sub, /*nb_subtract*/
@@ -1112,33 +1107,6 @@ static PyNumberMethods Matrix_NumMethods = {
0, /* nb_inplace_true_divide */
0, /* nb_index */
};
-#else
-static PyNumberMethods Matrix_NumMethods = {
- (binaryfunc) Matrix_add, /* __add__ */
- (binaryfunc) Matrix_sub, /* __sub__ */
- (binaryfunc) Matrix_mul, /* __mul__ */
- (binaryfunc) 0, /* __div__ */
- (binaryfunc) 0, /* __mod__ */
- (binaryfunc) 0, /* __divmod__ */
- (ternaryfunc) 0, /* __pow__ */
- (unaryfunc) 0, /* __neg__ */
- (unaryfunc) 0, /* __pos__ */
- (unaryfunc) 0, /* __abs__ */
- (inquiry) 0, /* __nonzero__ */
- (unaryfunc) Matrix_inv, /* __invert__ */
- (binaryfunc) 0, /* __lshift__ */
- (binaryfunc) 0, /* __rshift__ */
- (binaryfunc) 0, /* __and__ */
- (binaryfunc) 0, /* __xor__ */
- (binaryfunc) 0, /* __or__ */
- /*(coercion)*/ 0, /* __coerce__ */
- (unaryfunc) 0, /* __int__ */
- (unaryfunc) 0, /* __long__ */
- (unaryfunc) 0, /* __float__ */
- (unaryfunc) 0, /* __oct__ */
- (unaryfunc) 0, /* __hex__ */
-};
-#endif
static PyObject *Matrix_getRowSize( MatrixObject * self, void *type )
{
@@ -1164,13 +1132,7 @@ static PyGetSetDef Matrix_getseters[] = {
/*------------------PY_OBECT DEFINITION--------------------------*/
PyTypeObject matrix_Type = {
-#if (PY_VERSION_HEX >= 0x02060000)
PyVarObject_HEAD_INIT(NULL, 0)
-#else
- /* python 2.5 and below */
- PyObject_HEAD_INIT( NULL ) /* required py macro */
- 0, /* ob_size */
-#endif
"matrix", /*tp_name*/
sizeof(MatrixObject), /*tp_basicsize*/
0, /*tp_itemsize*/
@@ -1182,11 +1144,7 @@ PyTypeObject matrix_Type = {
(reprfunc) Matrix_repr, /*tp_repr*/
&Matrix_NumMethods, /*tp_as_number*/
&Matrix_SeqMethods, /*tp_as_sequence*/
-#if (PY_VERSION_HEX >= 0x03000000)
&Matrix_AsMapping, /*tp_as_mapping*/
-#else
- 0,
-#endif
0, /*tp_hash*/
0, /*tp_call*/
0, /*tp_str*/
diff --git a/source/blender/python/generic/quat.c b/source/blender/python/generic/quat.c
index a353f73c854..e06bee32031 100644
--- a/source/blender/python/generic/quat.c
+++ b/source/blender/python/generic/quat.c
@@ -620,7 +620,6 @@ static PySequenceMethods Quaternion_SeqMethods = {
(ssizessizeobjargproc) Quaternion_ass_slice, /* sq_ass_slice */
};
-#if (PY_VERSION_HEX >= 0x03000000)
static PyNumberMethods Quaternion_NumMethods = {
(binaryfunc) Quaternion_add, /*nb_add*/
(binaryfunc) Quaternion_sub, /*nb_subtract*/
@@ -657,33 +656,6 @@ static PyNumberMethods Quaternion_NumMethods = {
0, /* nb_inplace_true_divide */
0, /* nb_index */
};
-#else
-static PyNumberMethods Quaternion_NumMethods = {
- (binaryfunc) Quaternion_add, /* __add__ */
- (binaryfunc) Quaternion_sub, /* __sub__ */
- (binaryfunc) Quaternion_mul, /* __mul__ */
- (binaryfunc) 0, /* __div__ */
- (binaryfunc) 0, /* __mod__ */
- (binaryfunc) 0, /* __divmod__ */
- (ternaryfunc) 0, /* __pow__ */
- (unaryfunc) 0, /* __neg__ */
- (unaryfunc) 0, /* __pos__ */
- (unaryfunc) 0, /* __abs__ */
- (inquiry) 0, /* __nonzero__ */
- (unaryfunc) 0, /* __invert__ */
- (binaryfunc) 0, /* __lshift__ */
- (binaryfunc) 0, /* __rshift__ */
- (binaryfunc) 0, /* __and__ */
- (binaryfunc) 0, /* __xor__ */
- (binaryfunc) 0, /* __or__ */
- /*(coercion)*/ 0, /* __coerce__ */
- (unaryfunc) 0, /* __int__ */
- (unaryfunc) 0, /* __long__ */
- (unaryfunc) 0, /* __float__ */
- (unaryfunc) 0, /* __oct__ */
- (unaryfunc) 0, /* __hex__ */
-};
-#endif
static PyObject *Quaternion_getAxis( QuaternionObject * self, void *type )
{
@@ -778,13 +750,7 @@ static PyGetSetDef Quaternion_getseters[] = {
//------------------PY_OBECT DEFINITION--------------------------
PyTypeObject quaternion_Type = {
-#if (PY_VERSION_HEX >= 0x02060000)
PyVarObject_HEAD_INIT(NULL, 0)
-#else
- /* python 2.5 and below */
- PyObject_HEAD_INIT( NULL ) /* required py macro */
- 0, /* ob_size */
-#endif
"quaternion", //tp_name
sizeof(QuaternionObject), //tp_basicsize
0, //tp_itemsize
diff --git a/source/blender/python/generic/quat.h b/source/blender/python/generic/quat.h
index a7cfb7898b1..a1d01b4982d 100644
--- a/source/blender/python/generic/quat.h
+++ b/source/blender/python/generic/quat.h
@@ -32,7 +32,6 @@
#define EXPP_quat_h
#include <Python.h>
-#include "../intern/bpy_compat.h"
extern PyTypeObject quaternion_Type;
#define QuaternionObject_Check(_v) PyObject_TypeCheck((_v), &quaternion_Type)
diff --git a/source/blender/python/generic/vector.c b/source/blender/python/generic/vector.c
index cf2396b30d4..63bc2fbc7d1 100644
--- a/source/blender/python/generic/vector.c
+++ b/source/blender/python/generic/vector.c
@@ -1058,21 +1058,11 @@ static PySequenceMethods Vector_SeqMethods = {
(binaryfunc) 0, /* sq_concat */
(ssizeargfunc) 0, /* sq_repeat */
(ssizeargfunc) Vector_item, /* sq_item */
-#if (PY_VERSION_HEX < 0x03000000)
- (ssizessizeargfunc) Vector_slice, /* sq_slice */ /* PY2 ONLY */
-#else
- NULL,
-#endif
+ NULL, /* py3 deprecated slice func */
(ssizeobjargproc) Vector_ass_item, /* sq_ass_item */
-#if (PY_VERSION_HEX < 0x03000000)
- (ssizessizeobjargproc) Vector_ass_slice, /* sq_ass_slice */ /* PY2 ONLY */
-#else
- NULL,
-#endif
+ NULL, /* py3 deprecated slice assign func */
};
-
-#if (PY_VERSION_HEX >= 0x03000000)
static PyObject *Vector_subscript(VectorObject* self, PyObject* item)
{
if (PyIndex_Check(item)) {
@@ -1144,9 +1134,8 @@ static PyMappingMethods Vector_AsMapping = {
(binaryfunc)Vector_subscript,
(objobjargproc)Vector_ass_subscript
};
-#endif /* (PY_VERSION_HEX >= 0x03000000) */
-
-#if (PY_VERSION_HEX >= 0x03000000)
+
+
static PyNumberMethods Vector_NumMethods = {
(binaryfunc) Vector_add, /*nb_add*/
(binaryfunc) Vector_sub, /*nb_subtract*/
@@ -1183,53 +1172,6 @@ static PyNumberMethods Vector_NumMethods = {
Vector_idiv, /* nb_inplace_true_divide */
0, /* nb_index */
};
-#else
-static PyNumberMethods Vector_NumMethods = {
- (binaryfunc) Vector_add, /* __add__ */
- (binaryfunc) Vector_sub, /* __sub__ */
- (binaryfunc) Vector_mul, /* __mul__ */
- (binaryfunc) Vector_div, /* __div__ */
- (binaryfunc) NULL, /* __mod__ */
- (binaryfunc) NULL, /* __divmod__ */
- (ternaryfunc) NULL, /* __pow__ */
- (unaryfunc) Vector_neg, /* __neg__ */
- (unaryfunc) NULL, /* __pos__ */
- (unaryfunc) NULL, /* __abs__ */
- (inquiry) NULL, /* __nonzero__ */
- (unaryfunc) NULL, /* __invert__ */
- (binaryfunc) NULL, /* __lshift__ */
- (binaryfunc) NULL, /* __rshift__ */
- (binaryfunc) NULL, /* __and__ */
- (binaryfunc) NULL, /* __xor__ */
- (binaryfunc) NULL, /* __or__ */
- /*(coercion)*/ NULL, /* __coerce__ */
- (unaryfunc) NULL, /* __int__ */
- (unaryfunc) NULL, /* __long__ */
- (unaryfunc) NULL, /* __float__ */
- (unaryfunc) NULL, /* __oct__ */
- (unaryfunc) NULL, /* __hex__ */
-
- /* Added in release 2.0 */
- (binaryfunc) Vector_iadd, /*__iadd__*/
- (binaryfunc) Vector_isub, /*__isub__*/
- (binaryfunc) Vector_imul, /*__imul__*/
- (binaryfunc) Vector_idiv, /*__idiv__*/
- (binaryfunc) NULL, /*__imod__*/
- (ternaryfunc) NULL, /*__ipow__*/
- (binaryfunc) NULL, /*__ilshift__*/
- (binaryfunc) NULL, /*__irshift__*/
- (binaryfunc) NULL, /*__iand__*/
- (binaryfunc) NULL, /*__ixor__*/
- (binaryfunc) NULL, /*__ior__*/
-
- /* Added in release 2.2 */
- /* The following require the Py_TPFLAGS_HAVE_CLASS flag */
- (binaryfunc) NULL, /*__floordiv__ __rfloordiv__*/
- (binaryfunc) NULL, /*__truediv__ __rfloordiv__*/
- (binaryfunc) NULL, /*__ifloordiv__*/
- (binaryfunc) NULL, /*__itruediv__*/
-};
-#endif
/*------------------PY_OBECT DEFINITION--------------------------*/
@@ -1872,13 +1814,7 @@ if len(unique) != len(items):
*/
PyTypeObject vector_Type = {
-#if (PY_VERSION_HEX >= 0x02060000)
PyVarObject_HEAD_INIT(NULL, 0)
-#else
- /* python 2.5 and below */
- PyObject_HEAD_INIT( NULL ) /* required py macro */
- 0, /* ob_size */
-#endif
/* For printing, in format "<module>.<name>" */
"vector", /* char *tp_name; */
sizeof( VectorObject ), /* int tp_basicsize; */
@@ -1897,11 +1833,7 @@ PyTypeObject vector_Type = {
&Vector_NumMethods, /* PyNumberMethods *tp_as_number; */
&Vector_SeqMethods, /* PySequenceMethods *tp_as_sequence; */
-#if (PY_VERSION_HEX >= 0x03000000)
&Vector_AsMapping, /* PyMappingMethods *tp_as_mapping; */
-#else
- NULL,
-#endif
/* More standard operations (here for binary compatibility) */
diff --git a/source/blender/python/generic/vector.h b/source/blender/python/generic/vector.h
index f6babac7ed9..a13ec0f80f3 100644
--- a/source/blender/python/generic/vector.h
+++ b/source/blender/python/generic/vector.h
@@ -31,7 +31,6 @@
#define EXPP_vector_h
#include <Python.h>
-#include "../intern/bpy_compat.h"
extern PyTypeObject vector_Type;
#define VectorObject_Check(_v) PyObject_TypeCheck((_v), &vector_Type)
diff --git a/source/blender/python/intern/bpy_compat.h b/source/blender/python/intern/bpy_compat.h
deleted file mode 100644
index e999f57c733..00000000000
--- a/source/blender/python/intern/bpy_compat.h
+++ /dev/null
@@ -1,126 +0,0 @@
-/**
- * $Id$
- *
- * ***** BEGIN GPL LICENSE BLOCK *****
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- *
- * Contributor(s): Campbell Barton
- *
- * ***** END GPL LICENSE BLOCK *****
- */
-
-/* This file is only to contain definitions to functions that enable
- * the python api to compile with different python versions.
- * no utility functions please
- */
-
-#ifndef BPY_COMPAT_H__
-#define BPY_COMPAT_H__
-
-/* if you are NOT using python 3.0 - define these */
-#if PY_VERSION_HEX < 0x03000000
-#define _PyUnicode_AsString PyString_AsString
-
-#undef PyUnicode_Check
-#define PyUnicode_Check PyString_Check
-
-#define PyLong_FromSsize_t PyInt_FromLong
-#define PyLong_AsSsize_t PyInt_AsLong
-
-#undef PyLong_Check
-#define PyLong_Check PyInt_Check
-
-
-#ifdef PyUnicode_FromString
-#undef PyUnicode_FromString
-#endif
-#define PyUnicode_FromString PyString_FromString
-
-#ifdef PyUnicode_FromFormat
-#undef PyUnicode_FromFormat
-#endif
-#define PyUnicode_FromFormat PyString_FromFormat
-
-#endif
-
-#ifndef Py_REFCNT
-#define Py_REFCNT(ob) (((PyObject*)(ob))->ob_refcnt)
-#endif
-
-#ifndef Py_TYPE
-#define Py_TYPE(ob) (((PyObject*)(ob))->ob_type)
-#endif
-
-#ifndef Py_TYPE
-#define Py_SIZE(ob) (((PyVarObject*)(ob))->ob_size)
-#endif
-
-/* older then python 2.6 - define these */
-// #if (PY_VERSION_HEX < 0x02060000)
-// #endif
-
-/* older then python 2.5 - define these */
-#if (PY_VERSION_HEX < 0x02050000)
-#define Py_ssize_t ssize_t
-typedef Py_ssize_t (*lenfunc)(PyObject *);
-#ifndef Py_RETURN_NONE
-#define Py_RETURN_NONE return Py_BuildValue("O", Py_None)
-#endif
-#ifndef Py_RETURN_FALSE
-#define Py_RETURN_FALSE return PyBool_FromLong(0)
-#endif
-#ifndef Py_RETURN_TRUE
-#define Py_RETURN_TRUE return PyBool_FromLong(1)
-#endif
-
-#define PyInt_FromSsize_t PyInt_FromLong
-#define PyNumber_AsSsize_t(ob, exc) PyInt_AsLong(ob)
-#define PyIndex_Check(ob) PyInt_Check(ob)
-
-
-#endif
-
-
-#if PY_VERSION_HEX < 0x03000000
-#ifndef ssizeargfunc
-#define ssizeargfunc intargfunc
-#endif
-
-#ifndef ssizessizeargfunc
-#define ssizessizeargfunc intintargfunc
-#endif
-
-#ifndef ssizeobjargproc
-#define ssizeobjargproc intobjargproc
-#endif
-
-#ifndef ssizessizeobjargproc
-#define ssizessizeobjargproc intintobjargproc
-#endif
-#endif
-
-
-
-/* defined in bpy_util.c */
-#if PY_VERSION_HEX < 0x03000000
-PyObject *Py_CmpToRich(int op, int cmp);
-#endif
-
-#ifndef Py_CmpToRich
-PyObject *Py_CmpToRich(int op, int cmp); /* bpy_util.c */
-#endif
-
-#endif /* BPY_COMPAT_H__ */
diff --git a/source/blender/python/intern/bpy_interface.c b/source/blender/python/intern/bpy_interface.c
index 4fd4c9caf89..e37e75ab80d 100644
--- a/source/blender/python/intern/bpy_interface.c
+++ b/source/blender/python/intern/bpy_interface.c
@@ -14,8 +14,6 @@
#include "compile.h" /* for the PyCodeObject */
#include "eval.h" /* for PyEval_EvalCode */
-#include "bpy_compat.h"
-
#include "bpy_rna.h"
#include "bpy_operator.h"
#include "bpy_ui.h"
@@ -149,18 +147,11 @@ static void bpy_init_modules( void )
/* stand alone utility modules not related to blender directly */
- Geometry_Init("Geometry");
- Mathutils_Init("Mathutils");
- BGL_Init("BGL");
+ Geometry_Init();
+ Mathutils_Init();
+ BGL_Init();
}
-#if (PY_VERSION_HEX < 0x02050000)
-PyObject *PyImport_ImportModuleLevel(char *name, void *a, void *b, void *c, int d)
-{
- return PyImport_ImportModule(name);
-}
-#endif
-
void BPY_update_modules( void )
{
PyObject *mod= PyImport_ImportModuleLevel("bpy", NULL, NULL, NULL, 0);
@@ -244,9 +235,7 @@ void BPY_start_python( int argc, char **argv )
Py_Initialize( );
-#if (PY_VERSION_HEX < 0x03000000)
- PySys_SetArgv( argc, argv);
-#else
+ // PySys_SetArgv( argc, argv); // broken in py3, not a huge deal
/* sigh, why do python guys not have a char** version anymore? :( */
{
int i;
@@ -258,7 +247,6 @@ void BPY_start_python( int argc, char **argv )
PySys_SetObject("argv", py_argv);
Py_DECREF(py_argv);
}
-#endif
/* Initialize thread support (also acquires lock) */
PyEval_InitThreads();
diff --git a/source/blender/python/intern/bpy_operator.c b/source/blender/python/intern/bpy_operator.c
index 034440d77ac..e431f2a21e9 100644
--- a/source/blender/python/intern/bpy_operator.c
+++ b/source/blender/python/intern/bpy_operator.c
@@ -30,7 +30,6 @@
#include "bpy_operator.h"
#include "bpy_operator_wrap.h"
#include "bpy_rna.h" /* for setting arg props only - pyrna_py_to_prop() */
-#include "bpy_compat.h"
#include "bpy_util.h"
#include "WM_api.h"
diff --git a/source/blender/python/intern/bpy_operator_wrap.c b/source/blender/python/intern/bpy_operator_wrap.c
index a0cbc4637a4..9a74bf0aee8 100644
--- a/source/blender/python/intern/bpy_operator_wrap.c
+++ b/source/blender/python/intern/bpy_operator_wrap.c
@@ -37,7 +37,6 @@
#include "RNA_define.h"
#include "bpy_rna.h"
-#include "bpy_compat.h"
#include "bpy_util.h"
#include "../generic/bpy_internal_import.h" // our own imports
diff --git a/source/blender/python/intern/bpy_rna.c b/source/blender/python/intern/bpy_rna.c
index c3fcb9a6036..6c959b9f42c 100644
--- a/source/blender/python/intern/bpy_rna.c
+++ b/source/blender/python/intern/bpy_rna.c
@@ -23,7 +23,6 @@
*/
#include "bpy_rna.h"
-#include "bpy_compat.h"
#include "bpy_util.h"
//#include "blendef.h"
#include "BLI_dynstr.h"
@@ -904,10 +903,6 @@ static PyObject *prop_subscript_collection_str(BPy_PropertyRNA * self, char *key
}
/* static PyObject *prop_subscript_array_str(BPy_PropertyRNA * self, char *keyname) */
-
-
-
-#if PY_VERSION_HEX >= 0x03000000
static PyObject *prop_subscript_collection_slice(BPy_PropertyRNA * self, int start, int stop)
{
PointerRNA newptr;
@@ -942,7 +937,6 @@ static PyObject *prop_subscript_array_slice(BPy_PropertyRNA * self, int start, i
return list;
}
-#endif
static PyObject *prop_subscript_collection(BPy_PropertyRNA * self, PyObject *key)
{
@@ -956,7 +950,6 @@ static PyObject *prop_subscript_collection(BPy_PropertyRNA * self, PyObject *key
return prop_subscript_collection_int(self, i);
}
-#if PY_VERSION_HEX >= 0x03000000
else if (PySlice_Check(key)) {
int len= RNA_property_collection_length(&self->ptr, self->prop);
Py_ssize_t start, stop, step, slicelength;
@@ -975,7 +968,6 @@ static PyObject *prop_subscript_collection(BPy_PropertyRNA * self, PyObject *key
return NULL;
}
}
-#endif
else {
PyErr_Format(PyExc_TypeError, "invalid rna key, key must be a string or an int instead of %.200s instance.", Py_TYPE(key)->tp_name);
return NULL;
@@ -993,7 +985,6 @@ static PyObject *prop_subscript_array(BPy_PropertyRNA * self, PyObject *key)
return NULL;
return prop_subscript_array_int(self, PyLong_AsSsize_t(key));
}
-#if PY_VERSION_HEX >= 0x03000000
else if (PySlice_Check(key)) {
int len= RNA_property_array_length(self->prop);
Py_ssize_t start, stop, step, slicelength;
@@ -1012,7 +1003,6 @@ static PyObject *prop_subscript_array(BPy_PropertyRNA * self, PyObject *key)
return NULL;
}
}
-#endif
else {
PyErr_SetString(PyExc_AttributeError, "invalid key, key must be an int");
return NULL;
@@ -1032,7 +1022,6 @@ static PyObject *pyrna_prop_subscript( BPy_PropertyRNA * self, PyObject *key )
}
-#if PY_VERSION_HEX >= 0x03000000
static int prop_subscript_ass_array_slice(BPy_PropertyRNA * self, int begin, int end, PyObject *value)
{
int count;
@@ -1049,7 +1038,6 @@ static int prop_subscript_ass_array_slice(BPy_PropertyRNA * self, int begin, int
return 0;
}
-#endif
static int prop_subscript_ass_array_int(BPy_PropertyRNA * self, int keynum, PyObject *value)
{
@@ -1087,7 +1075,6 @@ static int pyrna_prop_ass_subscript( BPy_PropertyRNA * self, PyObject *key, PyOb
return prop_subscript_ass_array_int(self, i, value);
}
-#if PY_VERSION_HEX >= 0x03000000
else if (PySlice_Check(key)) {
int len= RNA_property_array_length(self->prop);
Py_ssize_t start, stop, step, slicelength;
@@ -1106,7 +1093,6 @@ static int pyrna_prop_ass_subscript( BPy_PropertyRNA * self, PyObject *key, PyOb
return -1;
}
}
-#endif
else {
PyErr_SetString(PyExc_AttributeError, "invalid key, key must be an int");
return -1;
@@ -1458,7 +1444,7 @@ static PyObject *pyrna_prop_get(BPy_PropertyRNA *self, PyObject *args)
}
-#if (PY_VERSION_HEX >= 0x03000000) /* foreach needs py3 */
+
static void foreach_attr_type( BPy_PropertyRNA *self, char *attr,
/* values to assign */
RawPropertyType *raw_type, int *attr_tot, int *attr_signed )
@@ -1693,7 +1679,6 @@ static PyObject *pyrna_prop_foreach_set(BPy_PropertyRNA *self, PyObject *args)
{
return foreach_getset(self, args, 1);
}
-#endif /* #if (PY_VERSION_HEX >= 0x03000000) */
/* A bit of a kludge, make a list out of a collection or array,
* then return the lists iter function, not especially fast but convenient for now */
@@ -1744,11 +1729,10 @@ static struct PyMethodDef pyrna_prop_methods[] = {
{"get", (PyCFunction)pyrna_prop_get, METH_VARARGS, NULL},
-#if (PY_VERSION_HEX >= 0x03000000)
/* array accessor function */
{"foreach_get", (PyCFunction)pyrna_prop_foreach_get, METH_VARARGS, NULL},
{"foreach_set", (PyCFunction)pyrna_prop_foreach_set, METH_VARARGS, NULL},
-#endif
+
{NULL, NULL, 0, NULL}
};
@@ -2112,13 +2096,7 @@ static PyObject * pyrna_func_call(PyObject * self, PyObject *args, PyObject *kw)
/*-----------------------BPy_StructRNA method def------------------------------*/
PyTypeObject pyrna_struct_Type = {
-#if (PY_VERSION_HEX >= 0x02060000)
PyVarObject_HEAD_INIT(NULL, 0)
-#else
- /* python 2.5 and below */
- PyObject_HEAD_INIT( NULL ) /* required py macro */
- 0, /* ob_size */
-#endif
"StructRNA", /* tp_name */
sizeof( BPy_StructRNA ), /* tp_basicsize */
0, /* tp_itemsize */
@@ -2197,14 +2175,7 @@ PyTypeObject pyrna_struct_Type = {
/*-----------------------BPy_PropertyRNA method def------------------------------*/
PyTypeObject pyrna_prop_Type = {
-#if (PY_VERSION_HEX >= 0x02060000)
PyVarObject_HEAD_INIT(NULL, 0)
-#else
- /* python 2.5 and below */
- PyObject_HEAD_INIT( NULL ) /* required py macro */
- 0, /* ob_size */
-#endif
-
"PropertyRNA", /* tp_name */
sizeof( BPy_PropertyRNA ), /* tp_basicsize */
0, /* tp_itemsize */
@@ -2555,7 +2526,6 @@ static struct PyMethodDef props_methods[] = {
{NULL, NULL, 0, NULL}
};
-#if PY_VERSION_HEX >= 0x03000000
static struct PyModuleDef props_module = {
PyModuleDef_HEAD_INIT,
"bpy.props",
@@ -2564,16 +2534,11 @@ static struct PyModuleDef props_module = {
props_methods,
NULL, NULL, NULL, NULL
};
-#endif
PyObject *BPY_rna_props( void )
{
PyObject *submodule;
-#if PY_VERSION_HEX >= 0x03000000
submodule= PyModule_Create(&props_module);
-#else /* Py2.x */
- submodule= Py_InitModule3( "bpy.props", props_methods, "" );
-#endif
/* INCREF since its its assumed that all these functions return the
* module with a new ref like PyDict_New, since they are passed to
diff --git a/source/blender/python/intern/bpy_ui.c b/source/blender/python/intern/bpy_ui.c
index 59e566b3b37..af3588f458c 100644
--- a/source/blender/python/intern/bpy_ui.c
+++ b/source/blender/python/intern/bpy_ui.c
@@ -26,7 +26,6 @@
#include "bpy_util.h"
#include "bpy_rna.h" /* for rna buttons */
#include "bpy_operator.h" /* for setting button operator properties */
-#include "bpy_compat.h"
#include "WM_types.h" /* for WM_OP_INVOKE_DEFAULT & friends */
@@ -47,7 +46,6 @@ static struct PyMethodDef ui_methods[] = {
{NULL, NULL, 0, NULL}
};
-#if PY_VERSION_HEX >= 0x03000000
static struct PyModuleDef ui_module = {
PyModuleDef_HEAD_INIT,
"bpy.ui",
@@ -56,16 +54,11 @@ static struct PyModuleDef ui_module = {
ui_methods,
NULL, NULL, NULL, NULL
};
-#endif
PyObject *BPY_ui_module( void )
{
PyObject *submodule, *mod;
-#if PY_VERSION_HEX >= 0x03000000
submodule= PyModule_Create(&ui_module);
-#else /* Py2.x */
- submodule= Py_InitModule3( "bpy.ui", ui_methods, "" );
-#endif
/* INCREF since its its assumed that all these functions return the
* module with a new ref like PyDict_New, since they are passed to
diff --git a/source/blender/python/intern/bpy_util.c b/source/blender/python/intern/bpy_util.c
index 3084cc1f871..25967d96dab 100644
--- a/source/blender/python/intern/bpy_util.c
+++ b/source/blender/python/intern/bpy_util.c
@@ -373,11 +373,7 @@ PyObject *BPY_exception_buffer(void)
* string_io = StringIO.StringIO()
*/
-#if PY_VERSION_HEX < 0x03000000
- if(! (string_io_mod= PyImport_ImportModule("StringIO")) ) {
-#else
if(! (string_io_mod= PyImport_ImportModule("io")) ) {
-#endif
goto error_cleanup;
} else if (! (string_io = PyObject_CallMethod(string_io_mod, "StringIO", NULL))) {
goto error_cleanup;
diff --git a/source/blender/python/intern/bpy_util.h b/source/blender/python/intern/bpy_util.h
index df204b7b90d..6751ab59396 100644
--- a/source/blender/python/intern/bpy_util.h
+++ b/source/blender/python/intern/bpy_util.h
@@ -27,7 +27,10 @@
#ifndef BPY_UTIL_H
#define BPY_UTIL_H
-#include "bpy_compat.h"
+#if PY_VERSION_HEX < 0x03010000
+#error Python versions below 3.1 are not supported anymore, you'll need to update your python.
+#endif
+
#include "RNA_types.h" /* for EnumPropertyItem only */
struct EnumPropertyItem;