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:
Diffstat (limited to 'source/blender/python')
-rw-r--r--source/blender/python/BPY_extern.h2
-rw-r--r--source/blender/python/generic/IDProp.c8
-rw-r--r--source/blender/python/generic/bgl.c30
-rw-r--r--source/blender/python/generic/bpy_internal_import.c10
-rw-r--r--source/blender/python/generic/mathutils_geometry.c8
-rw-r--r--source/blender/python/generic/py_capi_utils.c48
-rw-r--r--source/blender/python/generic/py_capi_utils.h2
-rw-r--r--source/blender/python/intern/bpy.c8
-rw-r--r--source/blender/python/intern/bpy_driver.c2
-rw-r--r--source/blender/python/intern/bpy_interface.c67
-rw-r--r--source/blender/python/intern/bpy_library.c8
-rw-r--r--source/blender/python/intern/bpy_operator.c45
-rw-r--r--source/blender/python/intern/bpy_props.c131
-rw-r--r--source/blender/python/intern/bpy_rna.c455
-rw-r--r--source/blender/python/intern/bpy_rna_anim.c47
-rw-r--r--source/blender/python/intern/bpy_traceback.c118
-rw-r--r--source/blender/python/intern/bpy_util.c14
17 files changed, 690 insertions, 313 deletions
diff --git a/source/blender/python/BPY_extern.h b/source/blender/python/BPY_extern.h
index 7901957e5e4..e8796a6f8dd 100644
--- a/source/blender/python/BPY_extern.h
+++ b/source/blender/python/BPY_extern.h
@@ -86,7 +86,7 @@ void BPY_modules_load_user(struct bContext *C);
void BPY_driver_reset(void);
float BPY_driver_exec(struct ChannelDriver *driver);
-int BPY_button_exec(struct bContext *C, const char *expr, double *value);
+int BPY_button_exec(struct bContext *C, const char *expr, double *value, const short verbose);
int BPY_string_exec(struct bContext *C, const char *expr);
void BPY_DECREF(void *pyob_ptr); /* Py_DECREF() */
diff --git a/source/blender/python/generic/IDProp.c b/source/blender/python/generic/IDProp.c
index 36dc6fca503..ccf498f1550 100644
--- a/source/blender/python/generic/IDProp.c
+++ b/source/blender/python/generic/IDProp.c
@@ -513,15 +513,15 @@ static PyObject *BPy_IDGroup_MapDataToPy(IDProperty *prop)
for (i=0; i<prop->len; i++) {
if (prop->subtype == IDP_FLOAT) {
PyList_SET_ITEM(seq, i,
- PyFloat_FromDouble(((float*)prop->data.pointer)[i]));
+ PyFloat_FromDouble(((float*)prop->data.pointer)[i]));
}
else if (prop->subtype == IDP_DOUBLE) {
PyList_SET_ITEM(seq, i,
- PyFloat_FromDouble(((double*)prop->data.pointer)[i]));
+ PyFloat_FromDouble(((double*)prop->data.pointer)[i]));
}
else {
PyList_SET_ITEM(seq, i,
- PyLong_FromLong(((int*)prop->data.pointer)[i]));
+ PyLong_FromLong(((int*)prop->data.pointer)[i]));
}
}
return seq;
@@ -588,7 +588,7 @@ static PyObject *BPy_IDGroup_Pop(BPy_IDProperty *self, PyObject *value)
/*ok something bad happened with the pyobject,
so don't remove the prop from the group. if pyform is
NULL, then it already should have raised an exception.*/
- return NULL;
+ return NULL;
}
IDP_RemFromGroup(self->prop, idprop);
diff --git a/source/blender/python/generic/bgl.c b/source/blender/python/generic/bgl.c
index 2c15755a642..730db73e685 100644
--- a/source/blender/python/generic/bgl.c
+++ b/source/blender/python/generic/bgl.c
@@ -132,16 +132,16 @@ static PyObject *Method_##funcname (PyObject *UNUSED(self), PyObject *args) {\
int BGL_typeSize(int type)
{
switch (type) {
- case GL_BYTE:
- return sizeof(char);
- case GL_SHORT:
- return sizeof(short);
- case GL_INT:
- return sizeof(int);
- case GL_FLOAT:
- return sizeof(float);
- case GL_DOUBLE:
- return sizeof(double);
+ case GL_BYTE:
+ return sizeof(char);
+ case GL_SHORT:
+ return sizeof(short);
+ case GL_INT:
+ return sizeof(int);
+ case GL_FLOAT:
+ return sizeof(float);
+ case GL_DOUBLE:
+ return sizeof(double);
}
return -1;
}
@@ -293,7 +293,7 @@ static PyObject *Buffer_item(PyObject *self, int i)
size= BGL_typeSize(buf->type);
newbuf= (Buffer *) PyObject_NEW(Buffer, &BGL_bufferType);
-
+
Py_INCREF(self);
newbuf->parent= self;
@@ -307,7 +307,7 @@ static PyObject *Buffer_item(PyObject *self, int i)
return (PyObject *) newbuf;
}
-
+
return NULL;
}
@@ -435,7 +435,7 @@ static PyObject *Buffer_dimensions(PyObject *self)
Buffer *buffer= (Buffer *) self;
PyObject *list= PyList_New(buffer->ndimensions);
int i;
-
+
for (i= 0; i<buffer->ndimensions; i++) {
PyList_SET_ITEM(list, i, PyLong_FromLong(buffer->dimensions[i]));
}
@@ -804,7 +804,7 @@ BGLU_Wrap(9, UnProject, GLint, (GLdouble, GLdouble, GLdouble, GLdoubleP, GLdo
* {"glAccum", Method_Accumfunc, METH_VARARGS} */
static struct PyMethodDef BGL_methods[] = {
- {"Buffer", Method_Buffer, METH_VARARGS, Method_Buffer_doc},
+ {"Buffer", Method_Buffer, METH_VARARGS, Method_Buffer_doc},
/* #ifndef __APPLE__ */
MethodDef(Accum),
@@ -1641,7 +1641,7 @@ PyObject *BPyInit_bgl(void)
EXPP_ADDCONST(GL_TEXTURE_RESIDENT);
EXPP_ADDCONST(GL_TEXTURE_BINDING_1D);
EXPP_ADDCONST(GL_TEXTURE_BINDING_2D);
-
+
return submodule;
}
diff --git a/source/blender/python/generic/bpy_internal_import.c b/source/blender/python/generic/bpy_internal_import.c
index 0ea4e083e3e..96fe13bf6fc 100644
--- a/source/blender/python/generic/bpy_internal_import.c
+++ b/source/blender/python/generic/bpy_internal_import.c
@@ -132,7 +132,7 @@ PyObject *bpy_text_import(Text *text)
PyObject *bpy_text_import_name(char *name, int *found)
{
Text *text;
- char txtname[22]; /* 21+NULL */
+ char txtname[MAX_ID_NAME-2];
int namelen= strlen(name);
//XXX Main *maggie= bpy_import_main ? bpy_import_main:G.main;
Main *maggie= bpy_import_main;
@@ -144,7 +144,7 @@ PyObject *bpy_text_import_name(char *name, int *found)
return NULL;
}
- if (namelen>21-3) return NULL; /* we know this cant be importable, the name is too long for blender! */
+ if (namelen >= (MAX_ID_NAME-2) - 3) return NULL; /* we know this cant be importable, the name is too long for blender! */
memcpy(txtname, name, namelen);
memcpy(&txtname[namelen], ".py", 4);
@@ -304,7 +304,7 @@ static PyObject *blender_reload(PyObject *UNUSED(self), PyObject * module)
}
else {
/* no blender text was found that could import the module
- * rause the original error from PyImport_ImportModuleEx */
+ * reuse the original error from PyImport_ImportModuleEx */
PyErr_Restore(exception, err, tb);
}
@@ -326,8 +326,8 @@ PyMethodDef bpy_reload_meth= {"bpy_reload_meth", (PyCFunction)blender_reload, ME
* it wont reload scripts between loading different blend files or while making the game.
* - use 'clear_all' arg in this case.
*
- * Since pythons bultins include a full path even for win32.
- * even if we remove a python module a reimport will bring it back again.
+ * Since pythons built-ins include a full path even for win32.
+ * even if we remove a python module a re-import will bring it back again.
*/
#if 0 // not used anymore but may still come in handy later
diff --git a/source/blender/python/generic/mathutils_geometry.c b/source/blender/python/generic/mathutils_geometry.c
index 51b1a9754c9..6031c716807 100644
--- a/source/blender/python/generic/mathutils_geometry.c
+++ b/source/blender/python/generic/mathutils_geometry.c
@@ -841,10 +841,10 @@ static PyObject *M_Geometry_barycentric_transform(PyObject *UNUSED(self), PyObje
vec_t1_tar->size != 3 ||
vec_t2_tar->size != 3 ||
vec_t3_tar->size != 3)
- {
- PyErr_SetString(PyExc_ValueError, "One of more of the vector arguments wasnt a 3D vector");
- return NULL;
- }
+ {
+ PyErr_SetString(PyExc_ValueError, "One of more of the vector arguments wasnt a 3D vector");
+ return NULL;
+ }
barycentric_transform(vec, vec_pt->vec,
vec_t1_tar->vec, vec_t2_tar->vec, vec_t3_tar->vec,
diff --git a/source/blender/python/generic/py_capi_utils.c b/source/blender/python/generic/py_capi_utils.c
index 7182d5f75d0..ec774f44075 100644
--- a/source/blender/python/generic/py_capi_utils.c
+++ b/source/blender/python/generic/py_capi_utils.c
@@ -30,6 +30,12 @@
#include "py_capi_utils.h"
+#include "BKE_font.h" /* only for utf8towchar, should replace with py funcs but too late in release now */
+
+#ifdef _WIN32 /* BLI_setenv */
+#include "BLI_path_util.h"
+#endif
+
#define PYC_INTERPRETER_ACTIVE (((PyThreadState*)_Py_atomic_load_relaxed(&_PyThreadState_Current)) != NULL)
/* for debugging */
@@ -284,6 +290,48 @@ void PyC_MainModule_Restore(PyObject *main_mod)
Py_XDECREF(main_mod);
}
+/* must be called before Py_Initialize, expects output of BLI_get_folder(BLENDER_PYTHON, NULL) */
+void PyC_SetHomePath(const char *py_path_bundle)
+{
+ if(py_path_bundle==NULL) {
+ /* Common enough to have bundled *nix python but complain on OSX/Win */
+#if defined(__APPLE__) || defined(_WIN32)
+ fprintf(stderr, "Warning! bundled python not found and is expected on this platform. (if you built with CMake: 'install' target may have not been built)\n");
+#endif
+ return;
+ }
+ /* set the environment path */
+ printf("found bundled python: %s\n", py_path_bundle);
+
+#ifdef __APPLE__
+ /* OSX allow file/directory names to contain : character (represented as / in the Finder)
+ but current Python lib (release 3.1.1) doesn't handle these correctly */
+ if(strchr(py_path_bundle, ':'))
+ printf("Warning : Blender application is located in a path containing : or / chars\
+ \nThis may make python import function fail\n");
+#endif
+
+#ifdef _WIN32
+ /* cmake/MSVC debug build crashes without this, why only
+ in this case is unknown.. */
+ {
+ BLI_setenv("PYTHONPATH", py_path_bundle);
+ }
+#endif
+
+ {
+ static wchar_t py_path_bundle_wchar[1024];
+
+ /* cant use this, on linux gives bug: #23018, TODO: try LANG="en_US.UTF-8" /usr/bin/blender, suggested 22008 */
+ /* mbstowcs(py_path_bundle_wchar, py_path_bundle, FILE_MAXDIR); */
+
+ utf8towchar(py_path_bundle_wchar, py_path_bundle);
+
+ Py_SetPythonHome(py_path_bundle_wchar);
+ // printf("found python (wchar_t) '%ls'\n", py_path_bundle_wchar);
+ }
+}
+
/* Would be nice if python had this built in */
void PyC_RunQuicky(const char *filepath, int n, ...)
{
diff --git a/source/blender/python/generic/py_capi_utils.h b/source/blender/python/generic/py_capi_utils.h
index 0b821759bec..1730ad71721 100644
--- a/source/blender/python/generic/py_capi_utils.h
+++ b/source/blender/python/generic/py_capi_utils.h
@@ -48,4 +48,6 @@ void PyC_RunQuicky(const char *filepath, int n, ...);
void PyC_MainModule_Backup(PyObject **main_mod);
void PyC_MainModule_Restore(PyObject *main_mod);
+void PyC_SetHomePath(const char *py_path_bundle);
+
#endif // PY_CAPI_UTILS_H
diff --git a/source/blender/python/intern/bpy.c b/source/blender/python/intern/bpy.c
index 18129af28be..906f6ccbca2 100644
--- a/source/blender/python/intern/bpy.c
+++ b/source/blender/python/intern/bpy.c
@@ -46,7 +46,7 @@
#include "BLI_bpath.h"
#include "BLI_utildefines.h"
-
+#include "BKE_main.h"
#include "BKE_global.h" /* XXX, G.main only */
#include "BKE_blender.h"
@@ -76,12 +76,12 @@ static PyObject *bpy_script_paths(PyObject *UNUSED(self))
{
PyObject *ret= PyTuple_New(2);
char *path;
-
+
path= BLI_get_folder(BLENDER_USER_SCRIPTS, NULL);
PyTuple_SET_ITEM(ret, 0, PyUnicode_FromString(path?path:""));
path= BLI_get_folder(BLENDER_SYSTEM_SCRIPTS, NULL);
PyTuple_SET_ITEM(ret, 1, PyUnicode_FromString(path?path:""));
-
+
return ret;
}
@@ -111,7 +111,7 @@ static PyObject *bpy_blend_paths(PyObject *UNUSED(self), PyObject *args, PyObjec
list= PyList_New(0);
- for(BLI_bpathIterator_init(&bpi, G.main, NULL, 0); !BLI_bpathIterator_isDone(bpi); BLI_bpathIterator_step(bpi)) {
+ for(BLI_bpathIterator_init(&bpi, G.main, G.main->name, 0); !BLI_bpathIterator_isDone(bpi); BLI_bpathIterator_step(bpi)) {
/* build the list */
if (absolute) {
BLI_bpathIterator_getPathExpanded(bpi, filepath_expanded);
diff --git a/source/blender/python/intern/bpy_driver.c b/source/blender/python/intern/bpy_driver.c
index 27260aed8d2..df31fab6bde 100644
--- a/source/blender/python/intern/bpy_driver.c
+++ b/source/blender/python/intern/bpy_driver.c
@@ -255,7 +255,7 @@ float BPY_driver_exec(ChannelDriver *driver)
if(use_gil)
PyGILState_Release(gilstate);
-
+
if(finite(result)) {
return (float)result;
}
diff --git a/source/blender/python/intern/bpy_interface.c b/source/blender/python/intern/bpy_interface.c
index 83c52464c9c..acd23887af0 100644
--- a/source/blender/python/intern/bpy_interface.c
+++ b/source/blender/python/intern/bpy_interface.c
@@ -164,52 +164,6 @@ void BPY_modules_update(bContext *C)
bpy_context_module->ptr.data= (void *)C;
}
-/* must be called before Py_Initialize */
-#ifndef WITH_PYTHON_MODULE
-static void bpy_python_start_path(void)
-{
- char *py_path_bundle= BLI_get_folder(BLENDER_PYTHON, NULL);
-
- if(py_path_bundle==NULL) {
- /* Common enough to have bundled *nix python but complain on OSX/Win */
-#if defined(__APPLE__) || defined(_WIN32)
- fprintf(stderr, "Warning! bundled python not found and is expected on this platform. (if you built with CMake: 'install' target may have not been built)\n");
-#endif
- return;
- }
- /* set the environment path */
- printf("found bundled python: %s\n", py_path_bundle);
-
-#ifdef __APPLE__
- /* OSX allow file/directory names to contain : character (represented as / in the Finder)
- but current Python lib (release 3.1.1) doesn't handle these correctly */
- if(strchr(py_path_bundle, ':'))
- printf("Warning : Blender application is located in a path containing : or / chars\
- \nThis may make python import function fail\n");
-#endif
-
-#ifdef _WIN32
- /* cmake/MSVC debug build crashes without this, why only
- in this case is unknown.. */
- {
- BLI_setenv("PYTHONPATH", py_path_bundle);
- }
-#endif
-
- {
- static wchar_t py_path_bundle_wchar[FILE_MAX];
-
- /* cant use this, on linux gives bug: #23018, TODO: try LANG="en_US.UTF-8" /usr/bin/blender, suggested 22008 */
- /* mbstowcs(py_path_bundle_wchar, py_path_bundle, FILE_MAXDIR); */
-
- utf8towchar(py_path_bundle_wchar, py_path_bundle);
-
- Py_SetPythonHome(py_path_bundle_wchar);
- // printf("found python (wchar_t) '%ls'\n", py_path_bundle_wchar);
- }
-}
-#endif
-
void BPY_context_set(bContext *C)
{
BPy_SetContext(C);
@@ -242,7 +196,8 @@ void BPY_python_start(int argc, const char **argv)
/* must run before python initializes */
PyImport_ExtendInittab(bpy_internal_modules);
- bpy_python_start_path(); /* allow to use our own included python */
+ /* allow to use our own included python */
+ PyC_SetHomePath(BLI_get_folder(BLENDER_PYTHON, NULL));
/* Python 3.2 now looks for '2.57/python/include/python3.2d/pyconfig.h' to parse
* from the 'sysconfig' module which is used by 'site', so for now disable site.
@@ -415,7 +370,9 @@ static int python_script_exec(bContext *C, const char *fn, struct Text *text, st
#endif
}
else {
- PyErr_Format(PyExc_IOError, "Python file \"%s\" could not be opened: %s", fn, strerror(errno));
+ PyErr_Format(PyExc_IOError,
+ "Python file \"%s\" could not be opened: %s",
+ fn, strerror(errno));
py_result= NULL;
}
}
@@ -471,7 +428,8 @@ void BPY_DECREF(void *pyob_ptr)
PyGILState_Release(gilstate);
}
-int BPY_button_exec(bContext *C, const char *expr, double *value)
+/* return -1 on error, else 0 */
+int BPY_button_exec(bContext *C, const char *expr, double *value, const short verbose)
{
PyGILState_STATE gilstate;
PyObject *py_dict, *mod, *retval;
@@ -536,7 +494,12 @@ int BPY_button_exec(bContext *C, const char *expr, double *value)
}
if(error_ret) {
- BPy_errors_to_report(CTX_wm_reports(C));
+ if(verbose) {
+ BPy_errors_to_report(CTX_wm_reports(C));
+ }
+ else {
+ PyErr_Clear();
+ }
}
PyC_MainModule_Backup(&main_mod);
@@ -707,8 +670,8 @@ static struct PyModuleDef bpy_proxy_def= {
};
typedef struct {
- PyObject_HEAD
- /* Type-specific fields go here. */
+ PyObject_HEAD
+ /* Type-specific fields go here. */
PyObject *mod;
} dealloc_obj;
diff --git a/source/blender/python/intern/bpy_library.c b/source/blender/python/intern/bpy_library.c
index 08a0b514a0c..4291fc824e9 100644
--- a/source/blender/python/intern/bpy_library.c
+++ b/source/blender/python/intern/bpy_library.c
@@ -230,7 +230,9 @@ static PyObject *bpy_lib_enter(BPy_Library *self, PyObject *UNUSED(args))
if(self->blo_handle == NULL) {
if(BPy_reports_to_error(&reports, PyExc_IOError, TRUE) != -1) {
- PyErr_Format(PyExc_IOError, "load: %s failed to open blend file", self->abspath);
+ PyErr_Format(PyExc_IOError,
+ "load: %s failed to open blend file",
+ self->abspath);
}
return NULL;
}
@@ -301,7 +303,9 @@ static PyObject *bpy_lib_exit(BPy_Library *self, PyObject *UNUSED(args))
if(item_str) {
if(!BLO_library_append_named_part(NULL, mainl, &(self->blo_handle), item_str, code, self->flag)) {
- PyErr_Format(PyExc_KeyError, "load: %s does not contain %s[\"%s\"]", self->abspath, name_plural, item_str);
+ PyErr_Format(PyExc_KeyError,
+ "load: %s does not contain %s[\"%s\"]",
+ self->abspath, name_plural, item_str);
err= -1;
break;
}
diff --git a/source/blender/python/intern/bpy_operator.c b/source/blender/python/intern/bpy_operator.c
index ebe6e05ee43..c230e952ca1 100644
--- a/source/blender/python/intern/bpy_operator.c
+++ b/source/blender/python/intern/bpy_operator.c
@@ -79,14 +79,19 @@ static PyObject *pyop_poll(PyObject *UNUSED(self), PyObject *args)
ot= WM_operatortype_find(opname, TRUE);
if (ot == NULL) {
- PyErr_Format(PyExc_AttributeError, "Polling operator \"bpy.ops.%s\" error, could not be found", opname);
+ PyErr_Format(PyExc_AttributeError,
+ "Polling operator \"bpy.ops.%s\" error, "
+ "could not be found", opname);
return NULL;
}
if(context_str) {
if(RNA_enum_value_from_id(operator_context_items, context_str, &context)==0) {
char *enum_str= BPy_enum_as_string(operator_context_items);
- PyErr_Format(PyExc_TypeError, "Calling operator \"bpy.ops.%s.poll\" error, expected a string enum in (%.200s)", opname, enum_str);
+ PyErr_Format(PyExc_TypeError,
+ "Calling operator \"bpy.ops.%s.poll\" error, "
+ "expected a string enum in (%.200s)",
+ opname, enum_str);
MEM_freeN(enum_str);
return NULL;
}
@@ -96,7 +101,10 @@ static PyObject *pyop_poll(PyObject *UNUSED(self), PyObject *args)
context_dict= NULL;
}
else if (!PyDict_Check(context_dict)) {
- PyErr_Format(PyExc_TypeError, "Calling operator \"bpy.ops.%s.poll\" error, custom context expected a dict or None, got a %.200s", opname, Py_TYPE(context_dict)->tp_name);
+ PyErr_Format(PyExc_TypeError,
+ "Calling operator \"bpy.ops.%s.poll\" error, "
+ "custom context expected a dict or None, got a %.200s",
+ opname, Py_TYPE(context_dict)->tp_name);
return NULL;
}
@@ -146,19 +154,27 @@ static PyObject *pyop_call(PyObject *UNUSED(self), PyObject *args)
ot= WM_operatortype_find(opname, TRUE);
if (ot == NULL) {
- PyErr_Format(PyExc_AttributeError, "Calling operator \"bpy.ops.%s\" error, could not be found", opname);
+ PyErr_Format(PyExc_AttributeError,
+ "Calling operator \"bpy.ops.%s\" error, "
+ "could not be found", opname);
return NULL;
}
if(!pyrna_write_check()) {
- PyErr_Format(PyExc_RuntimeError, "Calling operator \"bpy.ops.%s\" error, can't modify blend data in this state (drawing/rendering)", opname);
+ PyErr_Format(PyExc_RuntimeError,
+ "Calling operator \"bpy.ops.%s\" error, "
+ "can't modify blend data in this state (drawing/rendering)",
+ opname);
return NULL;
}
if(context_str) {
if(RNA_enum_value_from_id(operator_context_items, context_str, &context)==0) {
char *enum_str= BPy_enum_as_string(operator_context_items);
- PyErr_Format(PyExc_TypeError, "Calling operator \"bpy.ops.%s\" error, expected a string enum in (%.200s)", opname, enum_str);
+ PyErr_Format(PyExc_TypeError,
+ "Calling operator \"bpy.ops.%s\" error, "
+ "expected a string enum in (%.200s)",
+ opname, enum_str);
MEM_freeN(enum_str);
return NULL;
}
@@ -168,7 +184,10 @@ static PyObject *pyop_call(PyObject *UNUSED(self), PyObject *args)
context_dict= NULL;
}
else if (!PyDict_Check(context_dict)) {
- PyErr_Format(PyExc_TypeError, "Calling operator \"bpy.ops.%s\" error, custom context expected a dict or None, got a %.200s", opname, Py_TYPE(context_dict)->tp_name);
+ PyErr_Format(PyExc_TypeError,
+ "Calling operator \"bpy.ops.%s\" error, "
+ "custom context expected a dict or None, got a %.200s",
+ opname, Py_TYPE(context_dict)->tp_name);
return NULL;
}
@@ -179,7 +198,9 @@ static PyObject *pyop_call(PyObject *UNUSED(self), PyObject *args)
if(WM_operator_poll_context((bContext*)C, ot, context) == FALSE) {
const char *msg= CTX_wm_operator_poll_msg_get(C);
- PyErr_Format(PyExc_RuntimeError, "Operator bpy.ops.%.200s.poll() %.200s", opname, msg ? msg : "failed, context is incorrect");
+ PyErr_Format(PyExc_RuntimeError,
+ "Operator bpy.ops.%.200s.poll() %.200s",
+ opname, msg ? msg : "failed, context is incorrect");
CTX_wm_operator_poll_msg_set(C, NULL); /* better set to NULL else it could be used again */
error_val= -1;
}
@@ -225,7 +246,9 @@ static PyObject *pyop_call(PyObject *UNUSED(self), PyObject *args)
{
/* no props */
if (kw != NULL) {
- PyErr_Format(PyExc_AttributeError, "Operator \"%s\" does not take any args", opname);
+ PyErr_Format(PyExc_AttributeError,
+ "Operator \"%s\" does not take any args",
+ opname);
return NULL;
}
@@ -281,7 +304,9 @@ static PyObject *pyop_as_string(PyObject *UNUSED(self), PyObject *args)
ot= WM_operatortype_find(opname, TRUE);
if (ot == NULL) {
- PyErr_Format(PyExc_AttributeError, "_bpy.ops.as_string: operator \"%.200s\"could not be found", opname);
+ PyErr_Format(PyExc_AttributeError,
+ "_bpy.ops.as_string: operator \"%.200s\" "
+ "could not be found", opname);
return NULL;
}
diff --git a/source/blender/python/intern/bpy_props.c b/source/blender/python/intern/bpy_props.c
index e51ea048b92..6ea52abc5f4 100644
--- a/source/blender/python/intern/bpy_props.c
+++ b/source/blender/python/intern/bpy_props.c
@@ -129,7 +129,7 @@ static PyObject *bpy_prop_deferred_return(PyObject *func, PyObject *kw)
}
/* this define runs at the start of each function and deals with
- * returning a deferred property (to be registed later) */
+ * returning a deferred property (to be registered later) */
#define BPY_PROPDEF_HEAD(_func) \
if (PyTuple_GET_SIZE(args) == 1) { \
PyObject *ret; \
@@ -140,7 +140,7 @@ static PyObject *bpy_prop_deferred_return(PyObject *func, PyObject *kw)
return ret; \
} \
else if (PyTuple_GET_SIZE(args) > 1) { \
- PyErr_SetString(PyExc_ValueError, "all args must be keywords"); \
+ PyErr_SetString(PyExc_ValueError, "all args must be keywords"); \
return NULL; \
} \
srna= srna_from_self(self, #_func"(...):"); \
@@ -223,8 +223,14 @@ static PyObject *BPy_BoolProperty(PyObject *self, PyObject *args, PyObject *kw)
char *pysubtype= NULL;
int subtype= PROP_NONE;
- if (!PyArg_ParseTupleAndKeywords(args, kw, "s#|ssiO!s:BoolProperty", (char **)kwlist, &id, &id_len, &name, &description, &def, &PySet_Type, &pyopts, &pysubtype))
+ if (!PyArg_ParseTupleAndKeywords(args, kw,
+ "s#|ssiO!s:BoolProperty",
+ (char **)kwlist, &id, &id_len,
+ &name, &description, &def,
+ &PySet_Type, &pyopts, &pysubtype))
+ {
return NULL;
+ }
BPY_PROPDEF_SUBTYPE_CHECK(BoolProperty, property_flag_items, property_subtype_number_items)
@@ -277,8 +283,14 @@ static PyObject *BPy_BoolVectorProperty(PyObject *self, PyObject *args, PyObject
char *pysubtype= NULL;
int subtype= PROP_NONE;
- if (!PyArg_ParseTupleAndKeywords(args, kw, "s#|ssOO!si:BoolVectorProperty", (char **)kwlist, &id, &id_len, &name, &description, &pydef, &PySet_Type, &pyopts, &pysubtype, &size))
+ if (!PyArg_ParseTupleAndKeywords(args, kw,
+ "s#|ssOO!si:BoolVectorProperty",
+ (char **)kwlist, &id, &id_len,
+ &name, &description, &pydef,
+ &PySet_Type, &pyopts, &pysubtype,&size))
+ {
return NULL;
+ }
BPY_PROPDEF_SUBTYPE_CHECK(BoolVectorProperty, property_flag_items, property_subtype_array_items)
@@ -335,8 +347,15 @@ static PyObject *BPy_IntProperty(PyObject *self, PyObject *args, PyObject *kw)
char *pysubtype= NULL;
int subtype= PROP_NONE;
- if (!PyArg_ParseTupleAndKeywords(args, kw, "s#|ssiiiiiiO!s:IntProperty", (char **)kwlist, &id, &id_len, &name, &description, &def, &min, &max, &soft_min, &soft_max, &step, &PySet_Type, &pyopts, &pysubtype))
+ if (!PyArg_ParseTupleAndKeywords(args, kw,
+ "s#|ssiiiiiiO!s:IntProperty",
+ (char **)kwlist, &id, &id_len,
+ &name, &description, &def,
+ &min, &max, &soft_min, &soft_max,
+ &step, &PySet_Type, &pyopts, &pysubtype))
+ {
return NULL;
+ }
BPY_PROPDEF_SUBTYPE_CHECK(IntProperty, property_flag_items, property_subtype_number_items)
@@ -390,8 +409,16 @@ static PyObject *BPy_IntVectorProperty(PyObject *self, PyObject *args, PyObject
char *pysubtype= NULL;
int subtype= PROP_NONE;
- if (!PyArg_ParseTupleAndKeywords(args, kw, "s#|ssOiiiiiO!si:IntVectorProperty", (char **)kwlist, &id, &id_len, &name, &description, &pydef, &min, &max, &soft_min, &soft_max, &step, &PySet_Type, &pyopts, &pysubtype, &size))
+ if (!PyArg_ParseTupleAndKeywords(args, kw,
+ "s#|ssOiiiiiO!si:IntVectorProperty",
+ (char **)kwlist, &id, &id_len,
+ &name, &description, &pydef,
+ &min, &max, &soft_min, &soft_max,
+ &step, &PySet_Type, &pyopts,
+ &pysubtype, &size))
+ {
return NULL;
+ }
BPY_PROPDEF_SUBTYPE_CHECK(IntVectorProperty, property_flag_items, property_subtype_array_items)
@@ -454,8 +481,16 @@ static PyObject *BPy_FloatProperty(PyObject *self, PyObject *args, PyObject *kw)
char *pyunit= NULL;
int unit= PROP_UNIT_NONE;
- if (!PyArg_ParseTupleAndKeywords(args, kw, "s#|ssffffffiO!ss:FloatProperty", (char **)kwlist, &id, &id_len, &name, &description, &def, &min, &max, &soft_min, &soft_max, &step, &precision, &PySet_Type, &pyopts, &pysubtype, &pyunit))
+ if (!PyArg_ParseTupleAndKeywords(args, kw,
+ "s#|ssffffffiO!ss:FloatProperty",
+ (char **)kwlist, &id, &id_len,
+ &name, &description, &def,
+ &min, &max, &soft_min, &soft_max,
+ &step, &precision, &PySet_Type,
+ &pyopts, &pysubtype, &pyunit))
+ {
return NULL;
+ }
BPY_PROPDEF_SUBTYPE_CHECK(FloatProperty, property_flag_items, property_subtype_number_items)
@@ -514,8 +549,16 @@ static PyObject *BPy_FloatVectorProperty(PyObject *self, PyObject *args, PyObjec
char *pysubtype= NULL;
int subtype= PROP_NONE;
- if (!PyArg_ParseTupleAndKeywords(args, kw, "s#|ssOfffffiO!si:FloatVectorProperty", (char **)kwlist, &id, &id_len, &name, &description, &pydef, &min, &max, &soft_min, &soft_max, &step, &precision, &PySet_Type, &pyopts, &pysubtype, &size))
+ if (!PyArg_ParseTupleAndKeywords(args, kw,
+ "s#|ssOfffffiO!si:FloatVectorProperty",
+ (char **)kwlist, &id, &id_len,
+ &name, &description, &pydef,
+ &min, &max, &soft_min, &soft_max,
+ &step, &precision, &PySet_Type,
+ &pyopts, &pysubtype, &size))
+ {
return NULL;
+ }
BPY_PROPDEF_SUBTYPE_CHECK(FloatVectorProperty, property_flag_items, property_subtype_array_items)
@@ -572,8 +615,14 @@ static PyObject *BPy_StringProperty(PyObject *self, PyObject *args, PyObject *kw
char *pysubtype= NULL;
int subtype= PROP_NONE;
- if (!PyArg_ParseTupleAndKeywords(args, kw, "s#|sssiO!s:StringProperty", (char **)kwlist, &id, &id_len, &name, &description, &def, &maxlen, &PySet_Type, &pyopts, &pysubtype))
+ if (!PyArg_ParseTupleAndKeywords(args, kw,
+ "s#|sssiO!s:StringProperty",
+ (char **)kwlist, &id, &id_len,
+ &name, &description, &def,
+ &maxlen, &PySet_Type, &pyopts, &pysubtype))
+ {
return NULL;
+ }
BPY_PROPDEF_SUBTYPE_CHECK(StringProperty, property_flag_items, property_subtype_string_items)
@@ -607,7 +656,10 @@ static EnumPropertyItem *enum_items_from_py(PyObject *seq_fast, PyObject *def, i
return NULL;
}
if(def && !PySet_Check(def)) {
- PyErr_Format(PyExc_TypeError, "EnumProperty(...): default option must be a 'set' type when ENUM_FLAG is enabled, not a '%.200s'", Py_TYPE(def)->tp_name);
+ PyErr_Format(PyExc_TypeError,
+ "EnumProperty(...): default option must be a 'set' "
+ "type when ENUM_FLAG is enabled, not a '%.200s'",
+ Py_TYPE(def)->tp_name);
return NULL;
}
}
@@ -615,7 +667,10 @@ static EnumPropertyItem *enum_items_from_py(PyObject *seq_fast, PyObject *def, i
if(def) {
def_cmp= _PyUnicode_AsString(def);
if(def_cmp==NULL) {
- PyErr_Format(PyExc_TypeError, "EnumProperty(...): default option must be a 'str' type when ENUM_FLAG is disabled, not a '%.200s'", Py_TYPE(def)->tp_name);
+ PyErr_Format(PyExc_TypeError,
+ "EnumProperty(...): default option must be a 'str' "
+ "type when ENUM_FLAG is disabled, not a '%.200s'",
+ Py_TYPE(def)->tp_name);
return NULL;
}
}
@@ -666,7 +721,9 @@ static EnumPropertyItem *enum_items_from_py(PyObject *seq_fast, PyObject *def, i
if(def && def_used != PySet_GET_SIZE(def)) {
MEM_freeN(items);
- PyErr_Format(PyExc_TypeError, "EnumProperty(..., default={...}): set has %d unused member(s)", PySet_GET_SIZE(def) - def_used);
+ PyErr_Format(PyExc_TypeError,
+ "EnumProperty(..., default={...}): set has %d unused member(s)",
+ PySet_GET_SIZE(def) - def_used);
return NULL;
}
}
@@ -674,7 +731,9 @@ static EnumPropertyItem *enum_items_from_py(PyObject *seq_fast, PyObject *def, i
if(def && def_used == 0) {
MEM_freeN(items);
- PyErr_Format(PyExc_TypeError, "EnumProperty(..., default=\'%s\'): not found in enum members", def);
+ PyErr_Format(PyExc_TypeError,
+ "EnumProperty(..., default=\'%s\'): not found in enum members",
+ def);
return NULL;
}
}
@@ -714,8 +773,14 @@ static PyObject *BPy_EnumProperty(PyObject *self, PyObject *args, PyObject *kw)
PyObject *pyopts= NULL;
int opts=0;
- if (!PyArg_ParseTupleAndKeywords(args, kw, "s#O|ssOO!:EnumProperty", (char **)kwlist, &id, &id_len, &items, &name, &description, &def, &PySet_Type, &pyopts))
+ if (!PyArg_ParseTupleAndKeywords(args, kw,
+ "s#O|ssOO!:EnumProperty",
+ (char **)kwlist, &id, &id_len,
+ &items, &name, &description,
+ &def, &PySet_Type, &pyopts))
+ {
return NULL;
+ }
BPY_PROPDEF_CHECK(EnumProperty, property_flag_enum_items)
@@ -752,17 +817,23 @@ static StructRNA *pointer_type_from_py(PyObject *value, const char *error_prefix
if(PyErr_Occurred()) {
PyObject *msg= PyC_ExceptionBuffer();
char *msg_char= _PyUnicode_AsString(msg);
- PyErr_Format(PyExc_TypeError, "%.200s expected an RNA type derived from PropertyGroup, failed with: %s", error_prefix, msg_char);
+ PyErr_Format(PyExc_TypeError,
+ "%.200s expected an RNA type derived from PropertyGroup, failed with: %s",
+ error_prefix, msg_char);
Py_DECREF(msg);
}
else {
- PyErr_Format(PyExc_TypeError, "%.200s expected an RNA type derived from PropertyGroup, failed with type '%s'", error_prefix, Py_TYPE(value)->tp_name);
+ PyErr_Format(PyExc_TypeError,
+ "%.200s expected an RNA type derived from PropertyGroup, failed with type '%s'",
+ error_prefix, Py_TYPE(value)->tp_name);
}
return NULL;
}
if(!RNA_struct_is_a(srna, &RNA_PropertyGroup)) {
- PyErr_Format(PyExc_TypeError, "%.200s expected an RNA type derived from PropertyGroup", error_prefix);
+ PyErr_Format(PyExc_TypeError,
+ "%.200s expected an RNA type derived from PropertyGroup",
+ error_prefix);
return NULL;
}
@@ -797,8 +868,14 @@ static PyObject *BPy_PointerProperty(PyObject *self, PyObject *args, PyObject *k
PyObject *pyopts= NULL;
int opts=0;
- if (!PyArg_ParseTupleAndKeywords(args, kw, "s#O|ssO!:PointerProperty", (char **)kwlist, &id, &id_len, &type, &name, &description, &PySet_Type, &pyopts))
+ if (!PyArg_ParseTupleAndKeywords(args, kw,
+ "s#O|ssO!:PointerProperty",
+ (char **)kwlist, &id, &id_len,
+ &type, &name, &description,
+ &PySet_Type, &pyopts))
+ {
return NULL;
+ }
BPY_PROPDEF_CHECK(PointerProperty, property_flag_items)
@@ -844,8 +921,14 @@ static PyObject *BPy_CollectionProperty(PyObject *self, PyObject *args, PyObject
PyObject *pyopts= NULL;
int opts=0;
- if (!PyArg_ParseTupleAndKeywords(args, kw, "s#O|ssO!:CollectionProperty", (char **)kwlist, &id, &id_len, &type, &name, &description, &PySet_Type, &pyopts))
+ if (!PyArg_ParseTupleAndKeywords(args, kw,
+ "s#O|ssO!:CollectionProperty",
+ (char **)kwlist, &id, &id_len,
+ &type, &name, &description,
+ &PySet_Type, &pyopts))
+ {
return NULL;
+ }
BPY_PROPDEF_CHECK(CollectionProperty, property_flag_items)
@@ -884,7 +967,7 @@ static PyObject *BPy_RemoveProperty(PyObject *self, PyObject *args, PyObject *kw
return ret;
}
else if (PyTuple_GET_SIZE(args) > 1) {
- PyErr_SetString(PyExc_ValueError, "all args must be keywords"); \
+ PyErr_SetString(PyExc_ValueError, "all args must be keywords"); \
return NULL;
}
@@ -901,8 +984,12 @@ static PyObject *BPy_RemoveProperty(PyObject *self, PyObject *args, PyObject *kw
char *id=NULL;
- if (!PyArg_ParseTupleAndKeywords(args, kw, "s:RemoveProperty", (char **)kwlist, &id))
+ if (!PyArg_ParseTupleAndKeywords(args, kw,
+ "s:RemoveProperty",
+ (char **)kwlist, &id))
+ {
return NULL;
+ }
if(RNA_def_property_free_identifier(srna, id) != 1) {
PyErr_Format(PyExc_TypeError, "RemoveProperty(): '%s' not a defined dynamic property", id);
@@ -948,7 +1035,7 @@ PyObject *BPY_rna_props( void )
/* INCREF since its its assumed that all these functions return the
* module with a new ref like PyDict_New, since they are passed to
- * PyModule_AddObject which steals a ref */
+ * PyModule_AddObject which steals a ref */
Py_INCREF(submodule);
/* api needs the PyObjects internally */
diff --git a/source/blender/python/intern/bpy_rna.c b/source/blender/python/intern/bpy_rna.c
index 61ccd0d9310..8af0db6ee13 100644
--- a/source/blender/python/intern/bpy_rna.c
+++ b/source/blender/python/intern/bpy_rna.c
@@ -91,7 +91,9 @@ int pyrna_prop_validity_check(BPy_PropertyRNA *self)
{
if(self->ptr.type)
return 0;
- PyErr_Format(PyExc_ReferenceError, "PropertyRNA of type %.200s.%.200s has been removed", Py_TYPE(self)->tp_name, RNA_property_identifier(self->prop));
+ PyErr_Format(PyExc_ReferenceError,
+ "PropertyRNA of type %.200s.%.200s has been removed",
+ Py_TYPE(self)->tp_name, RNA_property_identifier(self->prop));
return -1;
}
@@ -144,7 +146,7 @@ struct GHash *id_weakref_pool= NULL;
static PyObject *id_free_weakref_cb(PyObject *weakinfo_pair, PyObject *weakref);
static PyMethodDef id_free_weakref_cb_def= {"id_free_weakref_cb", (PyCFunction)id_free_weakref_cb, METH_O, NULL};
-/* adds a reference to the list, remember ot decref */
+/* adds a reference to the list, remember to decref */
static GHash *id_weakref_pool_get(ID *id)
{
GHash *weakinfo_hash= NULL;
@@ -303,7 +305,10 @@ static int rna_id_write_error(PointerRNA *ptr, PyObject *key)
/* make a nice string error */
BLI_assert(idtype != NULL);
- PyErr_Format(PyExc_AttributeError, "Writing to ID classes in this context is not allowed: %.200s, %.200s datablock, error setting %.200s.%.200s", id->name+2, idtype, RNA_struct_identifier(ptr->type), pyname);
+ PyErr_Format(PyExc_AttributeError,
+ "Writing to ID classes in this context is not allowed: "
+ "%.200s, %.200s datablock, error setting %.200s.%.200s",
+ id->name+2, idtype, RNA_struct_identifier(ptr->type), pyname);
return TRUE;
}
@@ -392,7 +397,9 @@ static int mathutils_rna_vector_set(BaseMathObject *bmo, int subtype)
#endif // USE_PEDANTIC_WRITE
if (!RNA_property_editable_flag(&self->ptr, self->prop)) {
- PyErr_Format(PyExc_AttributeError, "bpy_prop \"%.200s.%.200s\" is read-only", RNA_struct_identifier(self->ptr.type), RNA_property_identifier(self->prop));
+ PyErr_Format(PyExc_AttributeError,
+ "bpy_prop \"%.200s.%.200s\" is read-only",
+ RNA_struct_identifier(self->ptr.type), RNA_property_identifier(self->prop));
return -1;
}
@@ -454,7 +461,9 @@ static int mathutils_rna_vector_set_index(BaseMathObject *bmo, int UNUSED(subtyp
#endif // USE_PEDANTIC_WRITE
if (!RNA_property_editable_flag(&self->ptr, self->prop)) {
- PyErr_Format(PyExc_AttributeError, "bpy_prop \"%.200s.%.200s\" is read-only", RNA_struct_identifier(self->ptr.type), RNA_property_identifier(self->prop));
+ PyErr_Format(PyExc_AttributeError,
+ "bpy_prop \"%.200s.%.200s\" is read-only",
+ RNA_struct_identifier(self->ptr.type), RNA_property_identifier(self->prop));
return -1;
}
@@ -509,7 +518,9 @@ static int mathutils_rna_matrix_set(BaseMathObject *bmo, int UNUSED(subtype))
#endif // USE_PEDANTIC_WRITE
if (!RNA_property_editable_flag(&self->ptr, self->prop)) {
- PyErr_Format(PyExc_AttributeError, "bpy_prop \"%.200s.%.200s\" is read-only", RNA_struct_identifier(self->ptr.type), RNA_property_identifier(self->prop));
+ PyErr_Format(PyExc_AttributeError,
+ "bpy_prop \"%.200s.%.200s\" is read-only",
+ RNA_struct_identifier(self->ptr.type), RNA_property_identifier(self->prop));
return -1;
}
@@ -548,7 +559,7 @@ static short pyrna_rotation_euler_order_get(PointerRNA *ptr, PropertyRNA **prop_
#endif // USE_MATHUTILS
/* note that PROP_NONE is included as a vector subtype. this is because its handy to
- * have x/y access to fcurve keyframes and other fixed size float arrayas of length 2-4. */
+ * have x/y access to fcurve keyframes and other fixed size float arrays of length 2-4. */
#define PROP_ALL_VECTOR_SUBTYPES PROP_COORDS: case PROP_TRANSLATION: case PROP_DIRECTION: case PROP_VELOCITY: case PROP_ACCELERATION: case PROP_XYZ: case PROP_XYZ_LENGTH
PyObject *pyrna_math_object_from_array(PointerRNA *ptr, PropertyRNA *prop)
@@ -573,7 +584,7 @@ PyObject *pyrna_math_object_from_array(PointerRNA *ptr, PropertyRNA *prop)
if (totdim == 1 || (totdim == 2 && subtype == PROP_MATRIX)) {
if(!is_thick)
- ret= pyrna_prop_CreatePyObject(ptr, prop); /* owned by the Mathutils PyObject */
+ ret= pyrna_prop_CreatePyObject(ptr, prop); /* owned by the mathutils PyObject */
switch(RNA_property_subtype(prop)) {
case PROP_ALL_VECTOR_SUBTYPES:
@@ -668,7 +679,7 @@ PyObject *pyrna_math_object_from_array(PointerRNA *ptr, PropertyRNA *prop)
ret= pyrna_prop_array_subscript_slice(NULL, ptr, prop, 0, len, len);
}
else {
- ret= pyrna_prop_CreatePyObject(ptr, prop); /* owned by the Mathutils PyObject */
+ ret= pyrna_prop_CreatePyObject(ptr, prop); /* owned by the mathutils PyObject */
}
}
#else // USE_MATHUTILS
@@ -684,7 +695,9 @@ int pyrna_enum_value_from_id(EnumPropertyItem *item, const char *identifier, int
{
if(RNA_enum_value_from_id(item, identifier, value) == 0) {
const char *enum_str= BPy_enum_as_string(item);
- PyErr_Format(PyExc_TypeError, "%s: '%.200s' not found in (%s)", error_prefix, identifier, enum_str);
+ PyErr_Format(PyExc_TypeError,
+ "%s: '%.200s' not found in (%s)",
+ error_prefix, identifier, enum_str);
MEM_freeN((void *)enum_str);
return -1;
}
@@ -1017,7 +1030,9 @@ static int pyrna_string_to_enum(PyObject *item, PointerRNA *ptr, PropertyRNA *pr
if (param==NULL) {
const char *enum_str= pyrna_enum_as_string(ptr, prop);
- PyErr_Format(PyExc_TypeError, "%.200s expected a string enum type in (%.200s)", error_prefix, enum_str);
+ PyErr_Format(PyExc_TypeError,
+ "%.200s expected a string enum type in (%.200s)",
+ error_prefix, enum_str);
MEM_freeN((void *)enum_str);
return 0;
}
@@ -1028,7 +1043,9 @@ static int pyrna_string_to_enum(PyObject *item, PointerRNA *ptr, PropertyRNA *pr
if (!RNA_property_enum_value(BPy_GetContext(), ptr, prop, param, val)) {
const char *enum_str= pyrna_enum_as_string(ptr, prop);
- PyErr_Format(PyExc_TypeError, "%.200s enum \"%.200s\" not found in (%.200s)", error_prefix, param, enum_str);
+ PyErr_Format(PyExc_TypeError,
+ "%.200s enum \"%.200s\" not found in (%.200s)",
+ error_prefix, param, enum_str);
MEM_freeN((void *)enum_str);
return 0;
}
@@ -1053,7 +1070,9 @@ int pyrna_set_to_enum_bitfield(EnumPropertyItem *items, PyObject *value, int *r_
const char *param= _PyUnicode_AsString(key);
if(param==NULL) {
- PyErr_Format(PyExc_TypeError, "%.200s expected a string, not %.200s", error_prefix, Py_TYPE(key)->tp_name);
+ PyErr_Format(PyExc_TypeError,
+ "%.200s expected a string, not %.200s",
+ error_prefix, Py_TYPE(key)->tp_name);
return -1;
}
if(pyrna_enum_value_from_id(items, param, &ret, error_prefix) < 0)
@@ -1081,7 +1100,9 @@ static int pyrna_prop_to_enum_bitfield(PointerRNA *ptr, PropertyRNA *prop, PyObj
}
else {
if(PySet_GET_SIZE(value)) {
- PyErr_Format(PyExc_TypeError, "%.200s: empty enum \"%.200s\" could not have any values assigned", error_prefix, RNA_property_identifier(prop));
+ PyErr_Format(PyExc_TypeError,
+ "%.200s: empty enum \"%.200s\" could not have any values assigned",
+ error_prefix, RNA_property_identifier(prop));
ret= -1;
}
else {
@@ -1168,9 +1189,11 @@ static PyObject *pyrna_enum_to_py(PointerRNA *ptr, PropertyRNA *prop, int val)
if(free)
MEM_freeN(enum_item);
-
- /*PyErr_Format(PyExc_AttributeError, "RNA Error: Current value \"%d\" matches no enum", val);
- ret= NULL;*/
+ /*
+ PyErr_Format(PyExc_AttributeError,
+ "RNA Error: Current value \"%d\" matches no enum", val);
+ ret= NULL;
+ */
}
}
@@ -1238,7 +1261,8 @@ PyObject * pyrna_prop_to_py(PointerRNA *ptr, PropertyRNA *prop)
ret= pyrna_prop_CreatePyObject(ptr, prop);
break;
default:
- PyErr_Format(PyExc_TypeError, "bpy_struct internal error: unknown type '%d' (pyrna_prop_to_py)", type);
+ PyErr_Format(PyExc_TypeError,
+ "bpy_struct internal error: unknown type '%d' (pyrna_prop_to_py)", type);
ret= NULL;
break;
}
@@ -1263,7 +1287,9 @@ int pyrna_pydict_to_props(PointerRNA *ptr, PyObject *kw, int all_args, const cha
if (strcmp(arg_name, "rna_type")==0) continue;
if (kw==NULL) {
- PyErr_Format(PyExc_TypeError, "%.200s: no keywords, expected \"%.200s\"", error_prefix, arg_name ? arg_name : "<UNKNOWN>");
+ PyErr_Format(PyExc_TypeError,
+ "%.200s: no keywords, expected \"%.200s\"",
+ error_prefix, arg_name ? arg_name : "<UNKNOWN>");
error_val= -1;
break;
}
@@ -1272,7 +1298,9 @@ int pyrna_pydict_to_props(PointerRNA *ptr, PyObject *kw, int all_args, const cha
if (item == NULL) {
if(all_args) {
- PyErr_Format(PyExc_TypeError, "%.200s: keyword \"%.200s\" missing", error_prefix, arg_name ? arg_name : "<UNKNOWN>");
+ PyErr_Format(PyExc_TypeError,
+ "%.200s: keyword \"%.200s\" missing",
+ error_prefix, arg_name ? arg_name : "<UNKNOWN>");
error_val= -1; /* pyrna_py_to_prop sets the error */
break;
}
@@ -1297,7 +1325,9 @@ int pyrna_pydict_to_props(PointerRNA *ptr, PyObject *kw, int all_args, const cha
arg_name= NULL;
}
- PyErr_Format(PyExc_TypeError, "%.200s: keyword \"%.200s\" unrecognized", error_prefix, arg_name ? arg_name : "<UNKNOWN>");
+ PyErr_Format(PyExc_TypeError,
+ "%.200s: keyword \"%.200s\" unrecognized",
+ error_prefix, arg_name ? arg_name : "<UNKNOWN>");
error_val= -1;
}
@@ -1313,7 +1343,9 @@ static PyObject *pyrna_func_to_py(BPy_DummyPointerRNA *pyrna, FunctionRNA *func)
PyObject *ret;
if(func==NULL) {
- PyErr_Format(PyExc_RuntimeError, "%.200s: type attempted to get NULL function", RNA_struct_identifier(pyrna->ptr.type));
+ PyErr_Format(PyExc_RuntimeError,
+ "%.200s: type attempted to get NULL function",
+ RNA_struct_identifier(pyrna->ptr.type));
return NULL;
}
@@ -1365,7 +1397,10 @@ static int pyrna_py_to_prop(PointerRNA *ptr, PropertyRNA *prop, void *data, PyOb
param= PyLong_AsLong(value);
if(param < 0) {
- PyErr_Format(PyExc_TypeError, "%.200s %.200s.%.200s expected True/False or 0/1, not %.200s", error_prefix, RNA_struct_identifier(ptr->type), RNA_property_identifier(prop), Py_TYPE(value)->tp_name);
+ PyErr_Format(PyExc_TypeError,
+ "%.200s %.200s.%.200s expected True/False or 0/1, not %.200s",
+ error_prefix, RNA_struct_identifier(ptr->type),
+ RNA_property_identifier(prop), Py_TYPE(value)->tp_name);
return -1;
}
else {
@@ -1379,11 +1414,18 @@ static int pyrna_py_to_prop(PointerRNA *ptr, PropertyRNA *prop, void *data, PyOb
int overflow;
long param= PyLong_AsLongAndOverflow(value, &overflow);
if(overflow || (param > INT_MAX) || (param < INT_MIN)) {
- PyErr_Format(PyExc_ValueError, "%.200s %.200s.%.200s value not in 'int' range (" STRINGIFY(INT_MIN) ", " STRINGIFY(INT_MAX) ")", error_prefix, RNA_struct_identifier(ptr->type), RNA_property_identifier(prop));
+ PyErr_Format(PyExc_ValueError,
+ "%.200s %.200s.%.200s value not in 'int' range "
+ "(" STRINGIFY(INT_MIN) ", " STRINGIFY(INT_MAX) ")",
+ error_prefix, RNA_struct_identifier(ptr->type),
+ RNA_property_identifier(prop));
return -1;
}
else if (param==-1 && PyErr_Occurred()) {
- PyErr_Format(PyExc_TypeError, "%.200s %.200s.%.200s expected an int type, not %.200s", error_prefix, RNA_struct_identifier(ptr->type), RNA_property_identifier(prop), Py_TYPE(value)->tp_name);
+ PyErr_Format(PyExc_TypeError,
+ "%.200s %.200s.%.200s expected an int type, not %.200s",
+ error_prefix, RNA_struct_identifier(ptr->type),
+ RNA_property_identifier(prop), Py_TYPE(value)->tp_name);
return -1;
}
else {
@@ -1398,7 +1440,10 @@ static int pyrna_py_to_prop(PointerRNA *ptr, PropertyRNA *prop, void *data, PyOb
{
float param= PyFloat_AsDouble(value);
if (PyErr_Occurred()) {
- PyErr_Format(PyExc_TypeError, "%.200s %.200s.%.200s expected a float type, not %.200s", error_prefix, RNA_struct_identifier(ptr->type), RNA_property_identifier(prop), Py_TYPE(value)->tp_name);
+ PyErr_Format(PyExc_TypeError,
+ "%.200s %.200s.%.200s expected a float type, not %.200s",
+ error_prefix, RNA_struct_identifier(ptr->type),
+ RNA_property_identifier(prop), Py_TYPE(value)->tp_name);
return -1;
}
else {
@@ -1426,7 +1471,10 @@ static int pyrna_py_to_prop(PointerRNA *ptr, PropertyRNA *prop, void *data, PyOb
#endif // USE_STRING_COERCE
if (param==NULL) {
- PyErr_Format(PyExc_TypeError, "%.200s %.200s.%.200s expected a string type, not %.200s", error_prefix, RNA_struct_identifier(ptr->type), RNA_property_identifier(prop), Py_TYPE(value)->tp_name);
+ PyErr_Format(PyExc_TypeError,
+ "%.200s %.200s.%.200s expected a string type, not %.200s",
+ error_prefix, RNA_struct_identifier(ptr->type),
+ RNA_property_identifier(prop), Py_TYPE(value)->tp_name);
return -1;
}
else {
@@ -1453,13 +1501,20 @@ static int pyrna_py_to_prop(PointerRNA *ptr, PropertyRNA *prop, void *data, PyOb
return -1;
}
else {
- PyErr_Format(PyExc_TypeError, "%.200s, %.200s.%.200s is not a bitflag enum type", error_prefix, RNA_struct_identifier(ptr->type), RNA_property_identifier(prop));
+ PyErr_Format(PyExc_TypeError,
+ "%.200s, %.200s.%.200s is not a bitflag enum type",
+ error_prefix, RNA_struct_identifier(ptr->type),
+ RNA_property_identifier(prop));
return -1;
}
}
else {
const char *enum_str= pyrna_enum_as_string(ptr, prop);
- PyErr_Format(PyExc_TypeError, "%.200s %.200s.%.200s expected a string enum or a set of strings in (%.2000s), not %.200s", error_prefix, RNA_struct_identifier(ptr->type), RNA_property_identifier(prop), enum_str, Py_TYPE(value)->tp_name);
+ PyErr_Format(PyExc_TypeError,
+ "%.200s %.200s.%.200s expected a string enum or a set of strings in (%.2000s), not %.200s",
+ error_prefix, RNA_struct_identifier(ptr->type),
+ RNA_property_identifier(prop), enum_str,
+ Py_TYPE(value)->tp_name);
MEM_freeN((void *)enum_str);
return -1;
}
@@ -1511,21 +1566,35 @@ static int pyrna_py_to_prop(PointerRNA *ptr, PropertyRNA *prop, void *data, PyOb
value_new= value;
}
else {
- PyErr_Format(PyExc_TypeError, "%.200s %.200s.%.200s collection has no type, cant be used as a %.200s type", error_prefix, RNA_struct_identifier(ptr->type), RNA_property_identifier(prop), RNA_struct_identifier(ptr_type));
+ PyErr_Format(PyExc_TypeError,
+ "%.200s %.200s.%.200s collection has no type, "
+ "cant be used as a %.200s type",
+ error_prefix, RNA_struct_identifier(ptr->type),
+ RNA_property_identifier(prop), RNA_struct_identifier(ptr_type));
return -1;
}
}
if(!BPy_StructRNA_Check(value) && value != Py_None) {
- PyErr_Format(PyExc_TypeError, "%.200s %.200s.%.200s expected a %.200s type, not %.200s", error_prefix, RNA_struct_identifier(ptr->type), RNA_property_identifier(prop), RNA_struct_identifier(ptr_type), Py_TYPE(value)->tp_name);
+ PyErr_Format(PyExc_TypeError,
+ "%.200s %.200s.%.200s expected a %.200s type, not %.200s",
+ error_prefix, RNA_struct_identifier(ptr->type),
+ RNA_property_identifier(prop), RNA_struct_identifier(ptr_type),
+ Py_TYPE(value)->tp_name);
Py_XDECREF(value_new); return -1;
}
else if((flag & PROP_NEVER_NULL) && value == Py_None) {
- PyErr_Format(PyExc_TypeError, "%.200s %.200s.%.200s does not support a 'None' assignment %.200s type", error_prefix, RNA_struct_identifier(ptr->type), RNA_property_identifier(prop), RNA_struct_identifier(ptr_type));
+ PyErr_Format(PyExc_TypeError,
+ "%.200s %.200s.%.200s does not support a 'None' assignment %.200s type",
+ error_prefix, RNA_struct_identifier(ptr->type),
+ RNA_property_identifier(prop), RNA_struct_identifier(ptr_type));
Py_XDECREF(value_new); return -1;
}
else if(value != Py_None && ((flag & PROP_ID_SELF_CHECK) && ptr->id.data == ((BPy_StructRNA*)value)->ptr.id.data)) {
- PyErr_Format(PyExc_TypeError, "%.200s %.200s.%.200s ID type does not support assignment to its self", error_prefix, RNA_struct_identifier(ptr->type), RNA_property_identifier(prop));
+ PyErr_Format(PyExc_TypeError,
+ "%.200s %.200s.%.200s ID type does not support assignment to its self",
+ error_prefix, RNA_struct_identifier(ptr->type),
+ RNA_property_identifier(prop));
Py_XDECREF(value_new); return -1;
}
else {
@@ -1561,7 +1630,11 @@ static int pyrna_py_to_prop(PointerRNA *ptr, PropertyRNA *prop, void *data, PyOb
else {
PointerRNA tmp;
RNA_pointer_create(NULL, ptr_type, NULL, &tmp);
- PyErr_Format(PyExc_TypeError, "%.200s %.200s.%.200s expected a %.200s type. not %.200s", error_prefix, RNA_struct_identifier(ptr->type), RNA_property_identifier(prop), RNA_struct_identifier(tmp.type), RNA_struct_identifier(param->ptr.type));
+ PyErr_Format(PyExc_TypeError,
+ "%.200s %.200s.%.200s expected a %.200s type. not %.200s",
+ error_prefix, RNA_struct_identifier(ptr->type),
+ RNA_property_identifier(prop), RNA_struct_identifier(tmp.type),
+ RNA_struct_identifier(param->ptr.type));
Py_XDECREF(value_new); return -1;
}
}
@@ -1569,7 +1642,11 @@ static int pyrna_py_to_prop(PointerRNA *ptr, PropertyRNA *prop, void *data, PyOb
if(raise_error) {
PointerRNA tmp;
RNA_pointer_create(NULL, ptr_type, NULL, &tmp);
- PyErr_Format(PyExc_TypeError, "%.200s %.200s.%.200s expected a %.200s type, not %.200s", error_prefix, RNA_struct_identifier(ptr->type), RNA_property_identifier(prop), RNA_struct_identifier(tmp.type), RNA_struct_identifier(param->ptr.type));
+ PyErr_Format(PyExc_TypeError,
+ "%.200s %.200s.%.200s expected a %.200s type, not %.200s",
+ error_prefix, RNA_struct_identifier(ptr->type),
+ RNA_property_identifier(prop), RNA_struct_identifier(tmp.type),
+ RNA_struct_identifier(param->ptr.type));
Py_XDECREF(value_new); return -1;
}
}
@@ -1590,7 +1667,10 @@ static int pyrna_py_to_prop(PointerRNA *ptr, PropertyRNA *prop, void *data, PyOb
/* convert a sequence of dict's into a collection */
if(!PySequence_Check(value)) {
- PyErr_Format(PyExc_TypeError, "%.200s %.200s.%.200s expected a sequence for an RNA collection, not %.200s", error_prefix, RNA_struct_identifier(ptr->type), RNA_property_identifier(prop), Py_TYPE(value)->tp_name);
+ PyErr_Format(PyExc_TypeError,
+ "%.200s %.200s.%.200s expected a sequence for an RNA collection, not %.200s",
+ error_prefix, RNA_struct_identifier(ptr->type),
+ RNA_property_identifier(prop), Py_TYPE(value)->tp_name);
return -1;
}
@@ -1599,13 +1679,20 @@ static int pyrna_py_to_prop(PointerRNA *ptr, PropertyRNA *prop, void *data, PyOb
item= PySequence_GetItem(value, i);
if(item==NULL) {
- PyErr_Format(PyExc_TypeError, "%.200s %.200s.%.200s failed to get sequence index '%d' for an RNA collection", error_prefix, RNA_struct_identifier(ptr->type), RNA_property_identifier(prop), i);
+ PyErr_Format(PyExc_TypeError,
+ "%.200s %.200s.%.200s failed to get sequence index '%d' for an RNA collection",
+ error_prefix, RNA_struct_identifier(ptr->type),
+ RNA_property_identifier(prop), i);
Py_XDECREF(item);
return -1;
}
if(PyDict_Check(item)==0) {
- PyErr_Format(PyExc_TypeError, "%.200s %.200s.%.200s expected a each sequence member to be a dict for an RNA collection, not %.200s", error_prefix, RNA_struct_identifier(ptr->type), RNA_property_identifier(prop), Py_TYPE(item)->tp_name);
+ PyErr_Format(PyExc_TypeError,
+ "%.200s %.200s.%.200s expected a each sequence "
+ "member to be a dict for an RNA collection, not %.200s",
+ error_prefix, RNA_struct_identifier(ptr->type),
+ RNA_property_identifier(prop), Py_TYPE(item)->tp_name);
Py_XDECREF(item);
return -1;
}
@@ -1622,7 +1709,11 @@ static int pyrna_py_to_prop(PointerRNA *ptr, PropertyRNA *prop, void *data, PyOb
PyObject *msg= PyC_ExceptionBuffer();
const char *msg_char= _PyUnicode_AsString(msg);
- PyErr_Format(PyExc_TypeError, "%.200s %.200s.%.200s error converting a member of a collection from a dicts into an RNA collection, failed with: %s", error_prefix, RNA_struct_identifier(ptr->type), RNA_property_identifier(prop), msg_char);
+ PyErr_Format(PyExc_TypeError,
+ "%.200s %.200s.%.200s error converting a member of a collection "
+ "from a dicts into an RNA collection, failed with: %s",
+ error_prefix, RNA_struct_identifier(ptr->type),
+ RNA_property_identifier(prop), msg_char);
Py_DECREF(item);
Py_DECREF(msg);
@@ -1634,7 +1725,10 @@ static int pyrna_py_to_prop(PointerRNA *ptr, PropertyRNA *prop, void *data, PyOb
break;
}
default:
- PyErr_Format(PyExc_AttributeError, "%.200s %.200s.%.200s unknown property type (pyrna_py_to_prop)", error_prefix, RNA_struct_identifier(ptr->type), RNA_property_identifier(prop));
+ PyErr_Format(PyExc_AttributeError,
+ "%.200s %.200s.%.200s unknown property type (pyrna_py_to_prop)",
+ error_prefix, RNA_struct_identifier(ptr->type),
+ RNA_property_identifier(prop));
return -1;
break;
}
@@ -1670,7 +1764,7 @@ static int pyrna_py_to_prop_array_index(BPy_PropertyArrayRNA *self, int index, P
}
}
else {
- /* see if we can coorce into a python type - PropertyType */
+ /* see if we can coerce into a python type - PropertyType */
switch (RNA_property_type(prop)) {
case PROP_BOOLEAN:
{
@@ -1744,7 +1838,7 @@ static Py_ssize_t pyrna_prop_collection_length(BPy_PropertyRNA *self)
return RNA_property_collection_length(&self->ptr, self->prop);
}
-/* bool funcs are for speed, so we can avoid getting the length
+/* bool functions are for speed, so we can avoid getting the length
* of 1000's of items in a linked list for eg. */
static int pyrna_prop_array_bool(BPy_PropertyRNA *self)
{
@@ -1793,10 +1887,15 @@ static PyObject *pyrna_prop_collection_subscript_int(BPy_PropertyRNA *self, Py_s
else {
const int len= RNA_property_collection_length(&self->ptr, self->prop);
if(keynum_abs >= len) {
- PyErr_Format(PyExc_IndexError, "bpy_prop_collection[index]: index %d out of range, size %d", keynum, len);
+ PyErr_Format(PyExc_IndexError,
+ "bpy_prop_collection[index]: "
+ "index %d out of range, size %d", keynum, len);
}
else {
- PyErr_Format(PyExc_RuntimeError, "bpy_prop_collection[index]: internal error, valid index %d given in %d sized collection but value not found", keynum_abs, len);
+ PyErr_Format(PyExc_RuntimeError,
+ "bpy_prop_collection[index]: internal error, "
+ "valid index %d given in %d sized collection but value not found",
+ keynum_abs, len);
}
return NULL;
@@ -1885,7 +1984,7 @@ static PyObject *pyrna_prop_array_subscript_slice(BPy_PropertyArrayRNA *self, Po
tuple= PyTuple_New(stop - start);
- /* PYRNA_PROP_CHECK_OBJ(self) isnt needed, internal use only */
+ /* PYRNA_PROP_CHECK_OBJ(self) isn't needed, internal use only */
totdim= RNA_property_array_dimension(ptr, prop, NULL);
@@ -2005,7 +2104,10 @@ static PyObject *pyrna_prop_collection_subscript(BPy_PropertyRNA *self, PyObject
}
}
else {
- PyErr_Format(PyExc_TypeError, "bpy_prop_collection[key]: invalid key, must be a string or an int, not %.200s", Py_TYPE(key)->tp_name);
+ PyErr_Format(PyExc_TypeError,
+ "bpy_prop_collection[key]: invalid key, "
+ "must be a string or an int, not %.200s",
+ Py_TYPE(key)->tp_name);
return NULL;
}
}
@@ -2177,7 +2279,7 @@ static int prop_subscript_ass_array_int(BPy_PropertyArrayRNA *self, Py_ssize_t k
if(keynum >= 0 && keynum < len)
return pyrna_py_to_prop_array_index(self, keynum, value);
- PyErr_SetString(PyExc_IndexError, "bpy_prop_array[index]= value: index out of range");
+ PyErr_SetString(PyExc_IndexError, "bpy_prop_array[index] = value: index out of range");
return -1;
}
@@ -2186,10 +2288,12 @@ static int pyrna_prop_array_ass_subscript(BPy_PropertyArrayRNA *self, PyObject *
/* char *keyname= NULL; */ /* not supported yet */
int ret= -1;
- PYRNA_PROP_CHECK_INT((BPy_PropertyRNA *)self)
+ PYRNA_PROP_CHECK_INT((BPy_PropertyRNA *)self);
if (!RNA_property_editable_flag(&self->ptr, self->prop)) {
- PyErr_Format(PyExc_AttributeError, "bpy_prop_collection: attribute \"%.200s\" from \"%.200s\" is read-only", RNA_property_identifier(self->prop), RNA_struct_identifier(self->ptr.type));
+ PyErr_Format(PyExc_AttributeError,
+ "bpy_prop_collection: attribute \"%.200s\" from \"%.200s\" is read-only",
+ RNA_property_identifier(self->prop), RNA_struct_identifier(self->ptr.type));
ret= -1;
}
@@ -2309,7 +2413,7 @@ static int pyrna_struct_contains(BPy_StructRNA *self, PyObject *value)
}
if(RNA_struct_idprops_check(self->ptr.type)==0) {
- PyErr_SetString(PyExc_TypeError, "bpy_struct: this type doesnt support IDProperties");
+ PyErr_SetString(PyExc_TypeError, "bpy_struct: this type doesn't support IDProperties");
return -1;
}
@@ -2525,7 +2629,9 @@ static PyObject *pyrna_struct_is_property_set(BPy_StructRNA *self, PyObject *arg
return NULL;
if((prop= RNA_struct_find_property(&self->ptr, name)) == NULL) {
- PyErr_Format(PyExc_TypeError, "%.200s.is_property_set(\"%.200s\") not found", RNA_struct_identifier(self->ptr.type), name);
+ PyErr_Format(PyExc_TypeError,
+ "%.200s.is_property_set(\"%.200s\") not found",
+ RNA_struct_identifier(self->ptr.type), name);
return NULL;
}
@@ -2566,7 +2672,9 @@ static PyObject *pyrna_struct_is_property_hidden(BPy_StructRNA *self, PyObject *
return NULL;
if((prop= RNA_struct_find_property(&self->ptr, name)) == NULL) {
- PyErr_Format(PyExc_TypeError, "%.200s.is_property_hidden(\"%.200s\") not found", RNA_struct_identifier(self->ptr.type), name);
+ PyErr_Format(PyExc_TypeError,
+ "%.200s.is_property_hidden(\"%.200s\") not found",
+ RNA_struct_identifier(self->ptr.type), name);
return NULL;
}
@@ -2600,7 +2708,9 @@ static PyObject *pyrna_struct_path_resolve(BPy_StructRNA *self, PyObject *args)
if(r_prop) {
if(index != -1) {
if(index >= RNA_property_array_length(&r_ptr, r_prop) || index < 0) {
- PyErr_Format(PyExc_TypeError, "%.200s.path_resolve(\"%.200s\") index out of range", RNA_struct_identifier(self->ptr.type), path);
+ PyErr_Format(PyExc_TypeError,
+ "%.200s.path_resolve(\"%.200s\") index out of range",
+ RNA_struct_identifier(self->ptr.type), path);
return NULL;
}
else {
@@ -2621,7 +2731,9 @@ static PyObject *pyrna_struct_path_resolve(BPy_StructRNA *self, PyObject *args)
}
}
else {
- PyErr_Format(PyExc_TypeError, "%.200s.path_resolve(\"%.200s\") could not be resolved", RNA_struct_identifier(self->ptr.type), path);
+ PyErr_Format(PyExc_TypeError,
+ "%.200s.path_resolve(\"%.200s\") could not be resolved",
+ RNA_struct_identifier(self->ptr.type), path);
return NULL;
}
}
@@ -2651,7 +2763,9 @@ static PyObject *pyrna_struct_path_from_id(BPy_StructRNA *self, PyObject *args)
if(name) {
prop= RNA_struct_find_property(&self->ptr, name);
if(prop==NULL) {
- PyErr_Format(PyExc_TypeError, "%.200s.path_from_id(\"%.200s\") not found", RNA_struct_identifier(self->ptr.type), name);
+ PyErr_Format(PyExc_TypeError,
+ "%.200s.path_from_id(\"%.200s\") not found",
+ RNA_struct_identifier(self->ptr.type), name);
return NULL;
}
@@ -2662,8 +2776,16 @@ static PyObject *pyrna_struct_path_from_id(BPy_StructRNA *self, PyObject *args)
}
if(path==NULL) {
- if(name) PyErr_Format(PyExc_TypeError, "%.200s.path_from_id(\"%s\") found but does not support path creation", RNA_struct_identifier(self->ptr.type), name);
- else PyErr_Format(PyExc_TypeError, "%.200s.path_from_id() does not support path creation for this type", RNA_struct_identifier(self->ptr.type));
+ if(name) {
+ PyErr_Format(PyExc_TypeError,
+ "%.200s.path_from_id(\"%s\") found but does not support path creation",
+ RNA_struct_identifier(self->ptr.type), name);
+ }
+ else {
+ PyErr_Format(PyExc_TypeError,
+ "%.200s.path_from_id() does not support path creation for this type",
+ RNA_struct_identifier(self->ptr.type));
+ }
return NULL;
}
@@ -2690,7 +2812,9 @@ static PyObject *pyrna_prop_path_from_id(BPy_PropertyRNA *self)
path= RNA_path_from_ID_to_property(&self->ptr, self->prop);
if(path==NULL) {
- PyErr_Format(PyExc_TypeError, "%.200s.%.200s.path_from_id() does not support path creation for this type", RNA_struct_identifier(self->ptr.type), RNA_property_identifier(prop));
+ PyErr_Format(PyExc_TypeError,
+ "%.200s.%.200s.path_from_id() does not support path creation for this type",
+ RNA_struct_identifier(self->ptr.type), RNA_property_identifier(prop));
return NULL;
}
@@ -2905,7 +3029,9 @@ static PyObject *pyrna_struct_getattro(BPy_StructRNA *self, PyObject *pyname)
/* should never happen */
BLI_assert(!"Invalid context type");
- PyErr_Format(PyExc_AttributeError, "bpy_struct: Context type invalid %d, can't get \"%.200s\" from context", newtype, name);
+ PyErr_Format(PyExc_AttributeError,
+ "bpy_struct: Context type invalid %d, can't get \"%.200s\" from context",
+ newtype, name);
ret= NULL;
}
}
@@ -2942,9 +3068,9 @@ static PyObject *pyrna_struct_getattro(BPy_StructRNA *self, PyObject *pyname)
#if 0
static int pyrna_struct_pydict_contains(PyObject *self, PyObject *pyname)
{
- PyObject *dict= *(_PyObject_GetDictPtr((PyObject *)self));
- if (dict==NULL) /* unlikely */
- return 0;
+ PyObject *dict= *(_PyObject_GetDictPtr((PyObject *)self));
+ if (dict==NULL) /* unlikely */
+ return 0;
return PyDict_Contains(dict, pyname);
}
@@ -2965,7 +3091,7 @@ static PyObject *pyrna_struct_meta_idprop_getattro(PyObject *cls, PyObject *attr
* >>> bpy.types.Scene.foo= BoolProperty()
* >>> bpy.types.Scene.foo
* <bpy_struct, BooleanProperty("foo")>
- * ...rather then returning the defered class register tuple as checked by pyrna_is_deferred_prop()
+ * ...rather then returning the deferred class register tuple as checked by pyrna_is_deferred_prop()
*
* Disable for now, this is faking internal behavior in a way thats too tricky to maintain well. */
#if 0
@@ -2993,7 +3119,10 @@ static int pyrna_struct_meta_idprop_setattro(PyObject *cls, PyObject *attr, PyOb
const int is_deferred_prop= (value && pyrna_is_deferred_prop(value));
if(srna && !pyrna_write_check() && (is_deferred_prop || RNA_struct_type_find_property(srna, _PyUnicode_AsString(attr)))) {
- PyErr_Format(PyExc_AttributeError, "pyrna_struct_meta_idprop_setattro() can't set in readonly state '%.200s.%S'", ((PyTypeObject *)cls)->tp_name, attr);
+ PyErr_Format(PyExc_AttributeError,
+ "pyrna_struct_meta_idprop_setattro() "
+ "can't set in readonly state '%.200s.%S'",
+ ((PyTypeObject *)cls)->tp_name, attr);
return -1;
}
@@ -3001,7 +3130,9 @@ static int pyrna_struct_meta_idprop_setattro(PyObject *cls, PyObject *attr, PyOb
/* allow setting on unregistered classes which can be registered later on */
/*
if(value && is_deferred_prop) {
- PyErr_Format(PyExc_AttributeError, "pyrna_struct_meta_idprop_setattro() unable to get srna from class '%.200s'", ((PyTypeObject *)cls)->tp_name);
+ PyErr_Format(PyExc_AttributeError,
+ "pyrna_struct_meta_idprop_setattro() unable to get srna from class '%.200s'",
+ ((PyTypeObject *)cls)->tp_name);
return -1;
}
*/
@@ -3024,9 +3155,9 @@ static int pyrna_struct_meta_idprop_setattro(PyObject *cls, PyObject *attr, PyOb
* but gets confusing from script writers POV if the assigned value cant be read back. */
}
else {
- /* remove existing property if its set or we also end up with confusement */
+ /* remove existing property if its set or we also end up with confusion */
const char *attr_str= _PyUnicode_AsString(attr);
- RNA_def_property_free_identifier(srna, attr_str); /* ignore on failier */
+ RNA_def_property_free_identifier(srna, attr_str); /* ignore on failure */
}
}
else { /* __delattr__ */
@@ -3062,7 +3193,9 @@ static int pyrna_struct_setattro(BPy_StructRNA *self, PyObject *pyname, PyObject
}
else if (name[0] != '_' && (prop= RNA_struct_find_property(&self->ptr, name))) {
if (!RNA_property_editable_flag(&self->ptr, prop)) {
- PyErr_Format(PyExc_AttributeError, "bpy_struct: attribute \"%.200s\" from \"%.200s\" is read-only", RNA_property_identifier(prop), RNA_struct_identifier(self->ptr.type));
+ PyErr_Format(PyExc_AttributeError,
+ "bpy_struct: attribute \"%.200s\" from \"%.200s\" is read-only",
+ RNA_property_identifier(prop), RNA_struct_identifier(self->ptr.type));
return -1;
}
}
@@ -3533,14 +3666,16 @@ static int foreach_parse_args(
/* rna_access.c - rna_raw_access(...) uses this same method */
if(target_tot != (*tot)) {
- PyErr_Format(PyExc_TypeError, "foreach_get(attr, sequence) sequence length mismatch given %d, needed %d", *tot, target_tot);
+ PyErr_Format(PyExc_TypeError,
+ "foreach_get(attr, sequence) sequence length mismatch given %d, needed %d",
+ *tot, target_tot);
return -1;
}
#endif
}
/* check 'attr_tot' otherwise we dont know if any values were set
- * this isnt ideal because it means running on an empty list may fail silently when its not compatible. */
+ * this isn't ideal because it means running on an empty list may fail silently when its not compatible. */
if (*size == 0 && *attr_tot != 0) {
PyErr_SetString(PyExc_AttributeError, "attribute does not support foreach method");
return -1;
@@ -3705,7 +3840,7 @@ static PyObject *foreach_getset(BPy_PropertyRNA *self, PyObject *args, int set)
if(PyErr_Occurred()) {
/* Maybe we could make our own error */
PyErr_Print();
- PyErr_SetString(PyExc_TypeError, "could not access the py sequence");
+ PyErr_SetString(PyExc_TypeError, "couldn't access the py sequence");
return NULL;
}
if (!ok) {
@@ -3719,13 +3854,13 @@ static PyObject *foreach_getset(BPy_PropertyRNA *self, PyObject *args, int set)
static char pyrna_prop_collection_foreach_get_doc[] =
".. method:: foreach_get(attr, seq)\n"
"\n"
-" This is a function to give fast access to attribites within a collection.\n"
+" This is a function to give fast access to attributes within a collection.\n"
"\n"
" .. code-block:: python\n"
"\n"
" collection.foreach_get(someseq, attr)\n"
"\n"
-" # Python equivelent\n"
+" # Python equivalent\n"
" for i in range(len(seq)): someseq[i]= getattr(collection, attr)\n"
"\n"
;
@@ -3739,13 +3874,13 @@ static PyObject *pyrna_prop_collection_foreach_get(BPy_PropertyRNA *self, PyObje
static char pyrna_prop_collection_foreach_set_doc[] =
".. method:: foreach_set(attr, seq)\n"
"\n"
-" This is a function to give fast access to attribites within a collection.\n"
+" This is a function to give fast access to attributes within a collection.\n"
"\n"
" .. code-block:: python\n"
"\n"
" collection.foreach_set(seq, attr)\n"
"\n"
-" # Python equivelent\n"
+" # Python equivalent\n"
" for i in range(len(seq)): setattr(collection[i], attr, seq[i])\n"
"\n"
;
@@ -3872,7 +4007,7 @@ static PyObject *pyrna_struct_new(PyTypeObject *type, PyObject *args, PyObject *
}
else if (PyType_IsSubtype(Py_TYPE(base), &pyrna_struct_Type)) {
/* this almost never runs, only when using user defined subclasses of built-in object.
- * this isnt common since its NOT related to registerable subclasses. eg:
+ * this isn't common since its NOT related to registerable subclasses. eg:
>>> class MyObSubclass(bpy.types.Object):
... def test_func(self):
@@ -4108,6 +4243,14 @@ static PyObject *pyrna_func_call(PyObject *self, PyObject *args, PyObject *kw)
PropertyRNA *pret_single= NULL;
void *retdata_single= NULL;
+ /* enable this so all strings are copied and freed after calling.
+ * this exposes bugs where the pointer to the string is held and re-used */
+// #define DEBUG_STRING_FREE
+
+#ifdef DEBUG_STRING_FREE
+ PyObject *string_free_ls= PyList_New(0);
+#endif
+
/* Should never happen but it does in rare cases */
BLI_assert(self_ptr != NULL);
@@ -4117,7 +4260,9 @@ static PyObject *pyrna_func_call(PyObject *self, PyObject *args, PyObject *kw)
}
if(self_func==NULL) {
- PyErr_Format(PyExc_RuntimeError, "%.200s.<unknown>(): rna function internal function is NULL, this is a bug. aborting", RNA_struct_identifier(self_ptr->type));
+ PyErr_Format(PyExc_RuntimeError,
+ "%.200s.<unknown>(): rna function internal function is NULL, this is a bug. aborting",
+ RNA_struct_identifier(self_ptr->type));
return NULL;
}
@@ -4146,7 +4291,10 @@ static PyObject *pyrna_func_call(PyObject *self, PyObject *args, PyObject *kw)
if(pyargs_len + pykw_len > parms_len) {
RNA_parameter_list_end(&iter);
- PyErr_Format(PyExc_TypeError, "%.200s.%.200s(): takes at most %d arguments, got %d", RNA_struct_identifier(self_ptr->type), RNA_function_identifier(self_func), parms_len, pyargs_len + pykw_len);
+ PyErr_Format(PyExc_TypeError,
+ "%.200s.%.200s(): takes at most %d arguments, got %d",
+ RNA_struct_identifier(self_ptr->type), RNA_function_identifier(self_func),
+ parms_len, pyargs_len + pykw_len);
err= -1;
}
@@ -4185,18 +4333,30 @@ static PyObject *pyrna_func_call(PyObject *self, PyObject *args, PyObject *kw)
if (item==NULL) {
if(flag & PROP_REQUIRED) {
- PyErr_Format(PyExc_TypeError, "%.200s.%.200s(): required parameter \"%.200s\" not specified", RNA_struct_identifier(self_ptr->type), RNA_function_identifier(self_func), parm_id);
+ PyErr_Format(PyExc_TypeError,
+ "%.200s.%.200s(): required parameter \"%.200s\" not specified",
+ RNA_struct_identifier(self_ptr->type), RNA_function_identifier(self_func), parm_id);
err= -1;
break;
}
- else /* PyDict_GetItemString wont raise an error */
+ else { /* PyDict_GetItemString wont raise an error */
continue;
+ }
}
+#ifdef DEBUG_STRING_FREE
+ if(item) {
+ if(PyUnicode_Check(item)) {
+ item= PyUnicode_FromString(_PyUnicode_AsString(item));
+ PyList_Append(string_free_ls, item);
+ Py_DECREF(item);
+ }
+ }
+#endif
err= pyrna_py_to_prop(&funcptr, parm, iter.data, item, "");
if(err!=0) {
- /* the error generated isnt that useful, so generate it again with a useful prefix
+ /* the error generated isn't that useful, so generate it again with a useful prefix
* could also write a function to prepend to error messages */
char error_prefix[512];
PyErr_Clear(); /* re-raise */
@@ -4214,7 +4374,7 @@ static PyObject *pyrna_func_call(PyObject *self, PyObject *args, PyObject *kw)
RNA_parameter_list_end(&iter);
- /* Check if we gave args that dont exist in the function
+ /* Check if we gave args that don't exist in the function
* printing the error is slow but it should only happen when developing.
* the if below is quick, checking if it passed less keyword args then we gave.
* (Dont overwrite the error if we have one, otherwise can skip important messages and confuse with args)
@@ -4275,7 +4435,10 @@ static PyObject *pyrna_func_call(PyObject *self, PyObject *args, PyObject *kw)
bad_args_str= BLI_dynstr_get_cstring(bad_args);
good_args_str= BLI_dynstr_get_cstring(good_args);
- PyErr_Format(PyExc_TypeError, "%.200s.%.200s(): was called with invalid keyword arguments(s) (%s), expected (%s)", RNA_struct_identifier(self_ptr->type), RNA_function_identifier(self_func), bad_args_str, good_args_str);
+ PyErr_Format(PyExc_TypeError,
+ "%.200s.%.200s(): was called with invalid keyword arguments(s) (%s), expected (%s)",
+ RNA_struct_identifier(self_ptr->type), RNA_function_identifier(self_func),
+ bad_args_str, good_args_str);
BLI_dynstr_free(bad_args);
BLI_dynstr_free(good_args);
@@ -4325,6 +4488,13 @@ static PyObject *pyrna_func_call(PyObject *self, PyObject *args, PyObject *kw)
}
}
+
+#ifdef DEBUG_STRING_FREE
+ // if(PyList_Size(string_free_ls)) printf("%.200s.%.200s(): has %d strings\n", RNA_struct_identifier(self_ptr->type), RNA_function_identifier(self_func), (int)PyList_Size(string_free_ls));
+ Py_DECREF(string_free_ls);
+#undef DEBUG_STRING_FREE
+#endif
+
/* cleanup */
RNA_parameter_list_end(&iter);
RNA_parameter_list_free(&parms);
@@ -5018,7 +5188,7 @@ static void pyrna_subtype_set_rna(PyObject *newclass, StructRNA *srna)
/* Not 100% needed but useful,
* having an instance within a type looks wrong however this instance IS an rna type */
- /* python deals with the curcular ref */
+ /* python deals with the circular ref */
RNA_pointer_create(NULL, &RNA_Struct, srna, &ptr);
item= pyrna_struct_CreatePyObject(&ptr);
@@ -5116,7 +5286,7 @@ static PyObject* pyrna_srna_Subtype(StructRNA *srna)
/* stupid/simple case */
if (srna == NULL) {
newclass= NULL; /* Nothing to do */
- } /* the class may have alredy been declared & allocated */
+ } /* the class may have already been declared & allocated */
else if ((newclass= RNA_struct_py_type_get(srna))) {
Py_INCREF(newclass);
} /* check if bpy_types.py module has the class defined in it */
@@ -5124,9 +5294,9 @@ static PyObject* pyrna_srna_Subtype(StructRNA *srna)
pyrna_subtype_set_rna(newclass, srna);
Py_INCREF(newclass);
} /* create a new class instance with the C api
- * maintly for the purposing of matching the C/rna type hierarchy */
+ * mainly for the purposing of matching the C/rna type hierarchy */
else {
- /* subclass equivelents
+ /* subclass equivalents
- class myClass(myBase):
some='value' # or ...
- myClass= type(name='myClass', bases=(myBase,), dict={'__module__':'bpy.types'})
@@ -5356,7 +5526,7 @@ PyObject *BPY_rna_doc(void)
#endif
-/* pyrna_basetype_* - BPy_BaseTypeRNA is just a BPy_PropertyRNA struct with a differnt type
+/* pyrna_basetype_* - BPy_BaseTypeRNA is just a BPy_PropertyRNA struct with a different type
* the self->ptr and self->prop are always set to the "structs" collection */
//---------------getattr--------------------------------------------
static PyObject *pyrna_basetype_getattro(BPy_BaseTypeRNA *self, PyObject *pyname)
@@ -5372,12 +5542,16 @@ static PyObject *pyrna_basetype_getattro(BPy_BaseTypeRNA *self, PyObject *pyname
else if (RNA_property_collection_lookup_string(&self->ptr, self->prop, name, &newptr)) {
ret= pyrna_struct_Subtype(&newptr);
if (ret==NULL) {
- PyErr_Format(PyExc_RuntimeError, "bpy.types.%.200s subtype could not be generated, this is a bug!", _PyUnicode_AsString(pyname));
+ PyErr_Format(PyExc_RuntimeError,
+ "bpy.types.%.200s subtype could not be generated, this is a bug!",
+ _PyUnicode_AsString(pyname));
}
}
else {
#if 0
- PyErr_Format(PyExc_AttributeError, "bpy.types.%.200s RNA_Struct does not exist", _PyUnicode_AsString(pyname));
+ PyErr_Format(PyExc_AttributeError,
+ "bpy.types.%.200s RNA_Struct does not exist",
+ _PyUnicode_AsString(pyname));
return NULL;
#endif
/* The error raised here will be displayed */
@@ -5463,19 +5637,26 @@ StructRNA *pyrna_struct_as_srna(PyObject *self, int parent, const char *error_pr
}
if(py_srna==NULL) {
- PyErr_Format(PyExc_RuntimeError, "%.200s, missing bl_rna attribute from '%.200s' instance (may not be registered)", error_prefix, Py_TYPE(self)->tp_name);
+ PyErr_Format(PyExc_RuntimeError,
+ "%.200s, missing bl_rna attribute from '%.200s' instance (may not be registered)",
+ error_prefix, Py_TYPE(self)->tp_name);
return NULL;
}
if(!BPy_StructRNA_Check(py_srna)) {
- PyErr_Format(PyExc_TypeError, "%.200s, bl_rna attribute wrong type '%.200s' on '%.200s'' instance", error_prefix, Py_TYPE(py_srna)->tp_name, Py_TYPE(self)->tp_name);
- Py_DECREF(py_srna);
+ PyErr_Format(PyExc_TypeError,
+ "%.200s, bl_rna attribute wrong type '%.200s' on '%.200s'' instance",
+ error_prefix, Py_TYPE(py_srna)->tp_name,
+ Py_TYPE(self)->tp_name);
+ Py_DECREF(py_srna);
return NULL;
}
if(py_srna->ptr.type != &RNA_Struct) {
- PyErr_Format(PyExc_TypeError, "%.200s, bl_rna attribute not a RNA_Struct, on '%.200s'' instance", error_prefix, Py_TYPE(self)->tp_name);
- Py_DECREF(py_srna);
+ PyErr_Format(PyExc_TypeError,
+ "%.200s, bl_rna attribute not a RNA_Struct, on '%.200s'' instance",
+ error_prefix, Py_TYPE(self)->tp_name);
+ Py_DECREF(py_srna);
return NULL;
}
@@ -5533,7 +5714,10 @@ static int deferred_register_prop(StructRNA *srna, PyObject *key, PyObject *item
PyObject *args_fake;
if(*_PyUnicode_AsString(key)=='_') {
- PyErr_Format(PyExc_ValueError, "bpy_struct \"%.200s\" registration error: %.200s could not register because the property starts with an '_'\n", RNA_struct_identifier(srna), _PyUnicode_AsString(key));
+ PyErr_Format(PyExc_ValueError,
+ "bpy_struct \"%.200s\" registration error: "
+ "%.200s could not register because the property starts with an '_'\n",
+ RNA_struct_identifier(srna), _PyUnicode_AsString(key));
return -1;
}
py_srna_cobject= PyCapsule_New(srna, NULL, NULL);
@@ -5556,7 +5740,10 @@ static int deferred_register_prop(StructRNA *srna, PyObject *key, PyObject *item
PyErr_Clear();
// PyC_LineSpit();
- PyErr_Format(PyExc_ValueError, "bpy_struct \"%.200s\" registration error: %.200s could not register\n", RNA_struct_identifier(srna), _PyUnicode_AsString(key));
+ PyErr_Format(PyExc_ValueError,
+ "bpy_struct \"%.200s\" registration error: "
+ "%.200s could not register\n",
+ RNA_struct_identifier(srna), _PyUnicode_AsString(key));
return -1;
}
}
@@ -5614,7 +5801,7 @@ static int pyrna_deferred_register_class_recursive(StructRNA *srna, PyTypeObject
PyTypeObject *py_superclass= (PyTypeObject *)PyTuple_GET_ITEM(py_class->tp_bases, i);
/* the rules for using these base classes are not clear,
- * 'object' is ofcourse not worth looking into and
+ * 'object' is of course not worth looking into and
* existing subclasses of RNA would cause a lot more dictionary
* looping then is needed (SomeOperator would scan Operator.__dict__)
* which is harmless but not at all useful.
@@ -5683,7 +5870,9 @@ static int bpy_class_validate(PointerRNA *dummyptr, void *py_data, int *have_fun
if (base_class) {
if (!PyObject_IsSubclass(py_class, base_class)) {
- PyErr_Format(PyExc_TypeError, "expected %.200s subclass of class \"%.200s\"", class_type, py_class_name);
+ PyErr_Format(PyExc_TypeError,
+ "expected %.200s subclass of class \"%.200s\"",
+ class_type, py_class_name);
return -1;
}
}
@@ -5705,7 +5894,10 @@ static int bpy_class_validate(PointerRNA *dummyptr, void *py_data, int *have_fun
if (item==NULL) {
if ((flag & FUNC_REGISTER_OPTIONAL)==0) {
- PyErr_Format(PyExc_AttributeError, "expected %.200s, %.200s class to have an \"%.200s\" attribute", class_type, py_class_name, RNA_function_identifier(func));
+ PyErr_Format(PyExc_AttributeError,
+ "expected %.200s, %.200s class to have an \"%.200s\" attribute",
+ class_type, py_class_name,
+ RNA_function_identifier(func));
return -1;
}
@@ -5715,14 +5907,18 @@ static int bpy_class_validate(PointerRNA *dummyptr, void *py_data, int *have_fun
Py_DECREF(item); /* no need to keep a ref, the class owns it (technically we should keep a ref but...) */
if(flag & FUNC_NO_SELF) {
if (PyMethod_Check(item)==0) {
- PyErr_Format(PyExc_TypeError, "expected %.200s, %.200s class \"%.200s\" attribute to be a method, not a %.200s", class_type, py_class_name, RNA_function_identifier(func), Py_TYPE(item)->tp_name);
+ PyErr_Format(PyExc_TypeError,
+ "expected %.200s, %.200s class \"%.200s\" attribute to be a method, not a %.200s",
+ class_type, py_class_name, RNA_function_identifier(func), Py_TYPE(item)->tp_name);
return -1;
}
item= ((PyMethodObject *)item)->im_func;
}
else {
if (PyFunction_Check(item)==0) {
- PyErr_Format(PyExc_TypeError, "expected %.200s, %.200s class \"%.200s\" attribute to be a function, not a %.200s", class_type, py_class_name, RNA_function_identifier(func), Py_TYPE(item)->tp_name);
+ PyErr_Format(PyExc_TypeError,
+ "expected %.200s, %.200s class \"%.200s\" attribute to be a function, not a %.200s",
+ class_type, py_class_name, RNA_function_identifier(func), Py_TYPE(item)->tp_name);
return -1;
}
}
@@ -5740,7 +5936,10 @@ static int bpy_class_validate(PointerRNA *dummyptr, void *py_data, int *have_fun
func_arg_count++;
if (arg_count != func_arg_count) {
- PyErr_Format(PyExc_ValueError, "expected %.200s, %.200s class \"%.200s\" function to have %d args, found %d", class_type, py_class_name, RNA_function_identifier(func), func_arg_count, arg_count);
+ PyErr_Format(PyExc_ValueError,
+ "expected %.200s, %.200s class \"%.200s\" function to have %d args, found %d",
+ class_type, py_class_name, RNA_function_identifier(func),
+ func_arg_count, arg_count);
return -1;
}
}
@@ -5782,7 +5981,9 @@ static int bpy_class_validate(PointerRNA *dummyptr, void *py_data, int *have_fun
#undef BPY_REPLACEMENT_STRING
if (item == NULL && (((flag & PROP_REGISTER_OPTIONAL) != PROP_REGISTER_OPTIONAL))) {
- PyErr_Format(PyExc_AttributeError, "expected %.200s, %.200s class to have an \"%.200s\" attribute", class_type, py_class_name, identifier);
+ PyErr_Format(PyExc_AttributeError,
+ "expected %.200s, %.200s class to have an \"%.200s\" attribute",
+ class_type, py_class_name, identifier);
return -1;
}
@@ -5875,7 +6076,7 @@ static int bpy_class_call(bContext *C, PointerRNA *ptr, FunctionRNA *func, Param
* Although this is annoying to have to impliment a part of pythons typeobject.c:type_call().
*/
if(py_class->tp_init) {
- /* true in most cases even when the class its self doesnt define an __init__ function. */
+ /* true in most cases even when the class its self doesn't define an __init__ function. */
args= PyTuple_New(0);
if (py_class->tp_init(py_srna, args, NULL) < 0) {
Py_DECREF(py_srna);
@@ -5888,7 +6089,7 @@ static int bpy_class_call(bContext *C, PointerRNA *ptr, FunctionRNA *func, Param
py_class_instance= py_srna;
#else
- /* 'almost' all the time calling the class isnt needed.
+ /* 'almost' all the time calling the class isn't needed.
* We could just do...
py_class_instance= py_srna;
Py_INCREF(py_class_instance);
@@ -5972,14 +6173,18 @@ static int bpy_class_call(bContext *C, PointerRNA *ptr, FunctionRNA *func, Param
else {
PyErr_Print();
PyErr_Clear();
- PyErr_Format(PyExc_TypeError, "could not find function %.200s in %.200s to execute callback", RNA_function_identifier(func), RNA_struct_identifier(ptr->type));
+ PyErr_Format(PyExc_TypeError,
+ "could not find function %.200s in %.200s to execute callback",
+ RNA_function_identifier(func), RNA_struct_identifier(ptr->type));
err= -1;
}
}
else {
- /* the error may be alredy set if the class instance couldnt be created */
+ /* the error may be already set if the class instance couldn't be created */
if(err != -1) {
- PyErr_Format(PyExc_RuntimeError, "could not create instance of %.200s to call callback function %.200s", RNA_struct_identifier(ptr->type), RNA_function_identifier(func));
+ PyErr_Format(PyExc_RuntimeError,
+ "could not create instance of %.200s to call callback function %.200s",
+ RNA_struct_identifier(ptr->type), RNA_function_identifier(func));
err= -1;
}
}
@@ -5989,7 +6194,10 @@ static int bpy_class_call(bContext *C, PointerRNA *ptr, FunctionRNA *func, Param
}
else {
if(ret_len==0 && ret != Py_None) {
- PyErr_Format(PyExc_RuntimeError, "expected class %.200s, function %.200s to return None, not %.200s", RNA_struct_identifier(ptr->type), RNA_function_identifier(func), Py_TYPE(ret)->tp_name);
+ PyErr_Format(PyExc_RuntimeError,
+ "expected class %.200s, function %.200s to return None, not %.200s",
+ RNA_struct_identifier(ptr->type), RNA_function_identifier(func),
+ Py_TYPE(ret)->tp_name);
err= -1;
}
else if(ret_len==1) {
@@ -5998,11 +6206,17 @@ static int bpy_class_call(bContext *C, PointerRNA *ptr, FunctionRNA *func, Param
else if (ret_len > 1) {
if(PyTuple_Check(ret)==0) {
- PyErr_Format(PyExc_RuntimeError, "expected class %.200s, function %.200s to return a tuple of size %d, not %.200s", RNA_struct_identifier(ptr->type), RNA_function_identifier(func), ret_len, Py_TYPE(ret)->tp_name);
+ PyErr_Format(PyExc_RuntimeError,
+ "expected class %.200s, function %.200s to return a tuple of size %d, not %.200s",
+ RNA_struct_identifier(ptr->type), RNA_function_identifier(func),
+ ret_len, Py_TYPE(ret)->tp_name);
err= -1;
}
else if (PyTuple_GET_SIZE(ret) != ret_len) {
- PyErr_Format(PyExc_RuntimeError, "class %.200s, function %.200s to returned %d items, expected %d", RNA_struct_identifier(ptr->type), RNA_function_identifier(func), PyTuple_GET_SIZE(ret), ret_len);
+ PyErr_Format(PyExc_RuntimeError,
+ "class %.200s, function %.200s to returned %d items, expected %d",
+ RNA_struct_identifier(ptr->type), RNA_function_identifier(func),
+ PyTuple_GET_SIZE(ret), ret_len);
err= -1;
}
else {
@@ -6140,7 +6354,7 @@ void pyrna_free_types(void)
* There is currently a bug where moving registering a python class does
* not properly manage refcounts from the python class, since the srna owns
* the python class this should not be so tricky but changing the references as
- * youd expect when changing ownership crashes blender on exit so I had to comment out
+ * you'd expect when changing ownership crashes blender on exit so I had to comment out
* the decref. This is not so bad because the leak only happens when re-registering (hold F8)
* - Should still be fixed - Campbell
* */
@@ -6178,7 +6392,9 @@ static PyObject *pyrna_register_class(PyObject *UNUSED(self), PyObject *py_class
/* fails in cases, cant use this check but would like to :| */
/*
if(RNA_struct_py_type_get(srna)) {
- PyErr_Format(PyExc_ValueError, "register_class(...): %.200s's parent class %.200s is alredy registered, this is not allowed", ((PyTypeObject*)py_class)->tp_name, RNA_struct_identifier(srna));
+ PyErr_Format(PyExc_ValueError,
+ "register_class(...): %.200s's parent class %.200s is already registered, this is not allowed",
+ ((PyTypeObject*)py_class)->tp_name, RNA_struct_identifier(srna));
return NULL;
}
*/
@@ -6187,7 +6403,10 @@ static PyObject *pyrna_register_class(PyObject *UNUSED(self), PyObject *py_class
reg= RNA_struct_register(srna);
if(!reg) {
- PyErr_Format(PyExc_ValueError, "register_class(...): expected a subclass of a registerable rna type (%.200s does not support registration)", RNA_struct_identifier(srna));
+ PyErr_Format(PyExc_ValueError,
+ "register_class(...): expected a subclass of a registerable "
+ "rna type (%.200s does not support registration)",
+ RNA_struct_identifier(srna));
return NULL;
}
@@ -6214,7 +6433,7 @@ static PyObject *pyrna_register_class(PyObject *UNUSED(self), PyObject *py_class
/* old srna still references us, keep the check incase registering somehow can free it */
if(RNA_struct_py_type_get(srna)) {
RNA_struct_py_type_set(srna, NULL);
- // Py_DECREF(py_class); // shuld be able to do this XXX since the old rna adds a new ref.
+ // Py_DECREF(py_class); // should be able to do this XXX since the old rna adds a new ref.
}
/* Can't use this because it returns a dict proxy
@@ -6338,7 +6557,9 @@ static PyObject *pyrna_unregister_class(PyObject *UNUSED(self), PyObject *py_cla
RNA_PROP_END;
if(prop_identifier) {
- PyErr_Format(PyExc_RuntimeError, "unregister_class(...): can't unregister %s because %s.%s pointer property is using this", RNA_struct_identifier(srna), RNA_struct_identifier(srna_iter), prop_identifier);
+ PyErr_Format(PyExc_RuntimeError,
+ "unregister_class(...): can't unregister %s because %s.%s pointer property is using this",
+ RNA_struct_identifier(srna), RNA_struct_identifier(srna_iter), prop_identifier);
return NULL;
}
}
diff --git a/source/blender/python/intern/bpy_rna_anim.c b/source/blender/python/intern/bpy_rna_anim.c
index b7f638b6441..5e53d4101f6 100644
--- a/source/blender/python/intern/bpy_rna_anim.c
+++ b/source/blender/python/intern/bpy_rna_anim.c
@@ -53,14 +53,16 @@
/* for keyframes and drivers */
static int pyrna_struct_anim_args_parse(PointerRNA *ptr, const char *error_prefix, const char *path,
- const char **path_full, int *index)
+ const char **path_full, int *index)
{
const int is_idbase= RNA_struct_is_ID(ptr->type);
PropertyRNA *prop;
PointerRNA r_ptr;
if (ptr->data==NULL) {
- PyErr_Format(PyExc_TypeError, "%.200s this struct has no data, can't be animated", error_prefix);
+ PyErr_Format(PyExc_TypeError,
+ "%.200s this struct has no data, can't be animated",
+ error_prefix);
return -1;
}
@@ -71,11 +73,15 @@ static int pyrna_struct_anim_args_parse(PointerRNA *ptr, const char *error_prefi
prop= NULL;
}
else if(r_index != -1) {
- PyErr_Format(PyExc_ValueError, "%.200s path includes index, must be a separate argument", error_prefix, path);
+ PyErr_Format(PyExc_ValueError,
+ "%.200s path includes index, must be a separate argument",
+ error_prefix, path);
return -1;
}
else if(ptr->id.data != r_ptr.id.data) {
- PyErr_Format(PyExc_ValueError, "%.200s path spans ID blocks", error_prefix, path);
+ PyErr_Format(PyExc_ValueError,
+ "%.200s path spans ID blocks",
+ error_prefix, path);
return -1;
}
}
@@ -85,12 +91,16 @@ static int pyrna_struct_anim_args_parse(PointerRNA *ptr, const char *error_prefi
}
if (prop==NULL) {
- PyErr_Format(PyExc_TypeError, "%.200s property \"%s\" not found", error_prefix, path);
+ PyErr_Format(PyExc_TypeError,
+ "%.200s property \"%s\" not found",
+ error_prefix, path);
return -1;
}
if (!RNA_property_animateable(&r_ptr, prop)) {
- PyErr_Format(PyExc_TypeError, "%.200s property \"%s\" not animatable", error_prefix, path);
+ PyErr_Format(PyExc_TypeError,
+ "%.200s property \"%s\" not animatable",
+ error_prefix, path);
return -1;
}
@@ -99,14 +109,18 @@ static int pyrna_struct_anim_args_parse(PointerRNA *ptr, const char *error_prefi
*index= 0;
}
else {
- PyErr_Format(PyExc_TypeError, "%.200s index %d was given while property \"%s\" is not an array", error_prefix, *index, path);
+ PyErr_Format(PyExc_TypeError,
+ "%.200s index %d was given while property \"%s\" is not an array",
+ error_prefix, *index, path);
return -1;
}
}
else {
int array_len= RNA_property_array_length(&r_ptr, prop);
if((*index) < -1 || (*index) >= array_len) {
- PyErr_Format(PyExc_TypeError, "%.200s index out of range \"%s\", given %d, array length is %d", error_prefix, path, *index, array_len);
+ PyErr_Format(PyExc_TypeError,
+ "%.200s index out of range \"%s\", given %d, array length is %d",
+ error_prefix, path, *index, array_len);
return -1;
}
}
@@ -118,7 +132,9 @@ static int pyrna_struct_anim_args_parse(PointerRNA *ptr, const char *error_prefi
*path_full= RNA_path_from_ID_to_property(&r_ptr, prop);
if (*path_full==NULL) {
- PyErr_Format(PyExc_TypeError, "%.200s could not make path to \"%s\"", error_prefix, path);
+ PyErr_Format(PyExc_TypeError,
+ "%.200s could not make path to \"%s\"",
+ error_prefix, path);
return -1;
}
}
@@ -128,7 +144,7 @@ static int pyrna_struct_anim_args_parse(PointerRNA *ptr, const char *error_prefi
/* internal use for insert and delete */
static int pyrna_struct_keyframe_parse(PointerRNA *ptr, PyObject *args, PyObject *kw, const char *parse_str, const char *error_prefix,
- const char **path_full, int *index, float *cfra, const char **group_name) /* return values */
+ const char **path_full, int *index, float *cfra, const char **group_name) /* return values */
{
static const char *kwlist[]= {"data_path", "index", "frame", "group", NULL};
const char *path;
@@ -172,7 +188,10 @@ PyObject *pyrna_struct_keyframe_insert(BPy_StructRNA *self, PyObject *args, PyOb
PYRNA_STRUCT_CHECK_OBJ(self)
- if(pyrna_struct_keyframe_parse(&self->ptr, args, kw, "s|ifs:bpy_struct.keyframe_insert()", "bpy_struct.keyframe_insert()", &path_full, &index, &cfra, &group_name) == -1) {
+ if(pyrna_struct_keyframe_parse(&self->ptr, args, kw,
+ "s|ifs:bpy_struct.keyframe_insert()", "bpy_struct.keyframe_insert()",
+ &path_full, &index, &cfra, &group_name) == -1)
+ {
return NULL;
}
else {
@@ -217,7 +236,11 @@ PyObject *pyrna_struct_keyframe_delete(BPy_StructRNA *self, PyObject *args, PyOb
PYRNA_STRUCT_CHECK_OBJ(self)
- if(pyrna_struct_keyframe_parse(&self->ptr, args, kw, "s|ifs:bpy_struct.keyframe_delete()", "bpy_struct.keyframe_insert()", &path_full, &index, &cfra, &group_name) == -1) {
+ if(pyrna_struct_keyframe_parse(&self->ptr, args, kw,
+ "s|ifs:bpy_struct.keyframe_delete()",
+ "bpy_struct.keyframe_insert()",
+ &path_full, &index, &cfra, &group_name) == -1)
+ {
return NULL;
}
else {
diff --git a/source/blender/python/intern/bpy_traceback.c b/source/blender/python/intern/bpy_traceback.c
index b5dec7205a6..17f082b79dc 100644
--- a/source/blender/python/intern/bpy_traceback.c
+++ b/source/blender/python/intern/bpy_traceback.c
@@ -38,68 +38,68 @@ static const char *traceback_filepath(PyTracebackObject *tb)
/* copied from pythonrun.c, 3.2.0 */
static int
parse_syntax_error(PyObject *err, PyObject **message, const char **filename,
- int *lineno, int *offset, const char **text)
+ int *lineno, int *offset, const char **text)
{
- long hold;
- PyObject *v;
-
- /* old style errors */
- if (PyTuple_Check(err))
- return PyArg_ParseTuple(err, "O(ziiz)", message, filename,
- lineno, offset, text);
-
- /* new style errors. `err' is an instance */
-
- if (! (v = PyObject_GetAttrString(err, "msg")))
- goto finally;
- *message = v;
-
- if (!(v = PyObject_GetAttrString(err, "filename")))
- goto finally;
- if (v == Py_None)
- *filename = NULL;
- else if (! (*filename = _PyUnicode_AsString(v)))
- goto finally;
-
- Py_DECREF(v);
- if (!(v = PyObject_GetAttrString(err, "lineno")))
- goto finally;
- hold = PyLong_AsLong(v);
- Py_DECREF(v);
- v = NULL;
- if (hold < 0 && PyErr_Occurred())
- goto finally;
- *lineno = (int)hold;
-
- if (!(v = PyObject_GetAttrString(err, "offset")))
- goto finally;
- if (v == Py_None) {
- *offset = -1;
- Py_DECREF(v);
- v = NULL;
+ long hold;
+ PyObject *v;
+
+ /* old style errors */
+ if (PyTuple_Check(err))
+ return PyArg_ParseTuple(err, "O(ziiz)", message, filename,
+ lineno, offset, text);
+
+ /* new style errors. `err' is an instance */
+
+ if (! (v = PyObject_GetAttrString(err, "msg")))
+ goto finally;
+ *message = v;
+
+ if (!(v = PyObject_GetAttrString(err, "filename")))
+ goto finally;
+ if (v == Py_None)
+ *filename = NULL;
+ else if (! (*filename = _PyUnicode_AsString(v)))
+ goto finally;
+
+ Py_DECREF(v);
+ if (!(v = PyObject_GetAttrString(err, "lineno")))
+ goto finally;
+ hold = PyLong_AsLong(v);
+ Py_DECREF(v);
+ v = NULL;
+ if (hold < 0 && PyErr_Occurred())
+ goto finally;
+ *lineno = (int)hold;
+
+ if (!(v = PyObject_GetAttrString(err, "offset")))
+ goto finally;
+ if (v == Py_None) {
+ *offset = -1;
+ Py_DECREF(v);
+ v = NULL;
}
else {
- hold = PyLong_AsLong(v);
- Py_DECREF(v);
- v = NULL;
- if (hold < 0 && PyErr_Occurred())
- goto finally;
- *offset = (int)hold;
- }
-
- if (!(v = PyObject_GetAttrString(err, "text")))
- goto finally;
- if (v == Py_None)
- *text = NULL;
- else if (!PyUnicode_Check(v) ||
- !(*text = _PyUnicode_AsString(v)))
- goto finally;
- Py_DECREF(v);
- return 1;
+ hold = PyLong_AsLong(v);
+ Py_DECREF(v);
+ v = NULL;
+ if (hold < 0 && PyErr_Occurred())
+ goto finally;
+ *offset = (int)hold;
+ }
+
+ if (!(v = PyObject_GetAttrString(err, "text")))
+ goto finally;
+ if (v == Py_None)
+ *text = NULL;
+ else if (!PyUnicode_Check(v) ||
+ !(*text = _PyUnicode_AsString(v)))
+ goto finally;
+ Py_DECREF(v);
+ return 1;
finally:
- Py_XDECREF(v);
- return 0;
+ Py_XDECREF(v);
+ return 0;
}
/* end copied function! */
@@ -122,7 +122,7 @@ void python_script_error_jump(const char *filepath, int *lineno, int *offset)
if(value) { /* should always be true */
PyObject *message;
- const char *filename, *text;
+ const char *filename, *text;
if(parse_syntax_error(value, &message, &filename, lineno, offset, &text)) {
/* python adds a '/', prefix, so check for both */
@@ -139,8 +139,6 @@ void python_script_error_jump(const char *filepath, int *lineno, int *offset)
*lineno= -1;
}
}
-
- /* this avoids an abort in Python 2.3's garbage collecting */
}
else {
PyErr_NormalizeException(&exception, &value, (PyObject **)&tb);
diff --git a/source/blender/python/intern/bpy_util.c b/source/blender/python/intern/bpy_util.c
index 0d3b036850d..6e321015bc6 100644
--- a/source/blender/python/intern/bpy_util.c
+++ b/source/blender/python/intern/bpy_util.c
@@ -98,7 +98,7 @@ short BPy_errors_to_report(ReportList *reports)
pystring= PyC_ExceptionBuffer();
if(pystring==NULL) {
- BKE_report(reports, RPT_ERROR, "unknown py-exception, could not convert");
+ BKE_report(reports, RPT_ERROR, "unknown py-exception, couldn't convert");
return 0;
}
@@ -138,7 +138,9 @@ int PyC_AsArray(void *array, PyObject *value, int length, PyTypeObject *type, co
if(value_len != length) {
Py_DECREF(value);
- PyErr_Format(PyExc_TypeError, "%.200s: invalid sequence length. expected %d, got %d", error_prefix, length, value_len);
+ PyErr_Format(PyExc_TypeError,
+ "%.200s: invalid sequence length. expected %d, got %d",
+ error_prefix, length, value_len);
return -1;
}
@@ -163,14 +165,18 @@ int PyC_AsArray(void *array, PyObject *value, int length, PyTypeObject *type, co
}
else {
Py_DECREF(value_fast);
- PyErr_Format(PyExc_TypeError, "%s: internal error %s is invalid", error_prefix, type->tp_name);
+ PyErr_Format(PyExc_TypeError,
+ "%s: internal error %s is invalid",
+ error_prefix, type->tp_name);
return -1;
}
Py_DECREF(value_fast);
if(PyErr_Occurred()) {
- PyErr_Format(PyExc_TypeError, "%s: one or more items could not be used as a %s", error_prefix, type->tp_name);
+ PyErr_Format(PyExc_TypeError,
+ "%s: one or more items could not be used as a %s",
+ error_prefix, type->tp_name);
return -1;
}