[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [22180] branches/soc-2008-mxcurioni/source /blender/freestyle/intern/python/UnaryFunction1D: * Fixed uninitialized pointers in "__init__" methods of UnaryFunction1D types.

Tamito Kajiyama rd6t-kjym at asahi-net.or.jp
Mon Aug 3 16:38:15 CEST 2009


Revision: 22180
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=22180
Author:   kjym3
Date:     2009-08-03 16:38:15 +0200 (Mon, 03 Aug 2009)

Log Message:
-----------
* Fixed uninitialized pointers in "__init__" methods of UnaryFunction1D types.

There was a known issue for a long time that we occasionally encountered
strange "TypeError: an integer is required" and "RuntimeWarning: tp_compare
didn't return -1 or -2 for exception", as shown in the following unit test
log.  The source of the former error was PyInt_AsLong(obj) being used by
IntegrationType_from_BPy_IntegrationType(obj), where "obj" was not properly
initialized in "__init__" before the converter was called.  The TypeError
was left unattended for a while and showed up when a comparison occurred
and the TypeError was detected, which resulted in the latter warning.

> runTest (__main__.UnaryFunction1DDoubleInitTestCase) ...
> .\blender:211: RuntimeWarning: tp_compare didn't return -1 or -2 for exception
> ERROR
> 
> ======================================================================
> ERROR: runTest (__main__.UnaryFunction1DDoubleInitTestCase)
> ----------------------------------------------------------------------
> Traceback (most recent call last):
>   File "init_tests.py", line 211, in runTest
> TypeError: an integer is required
> 
> ----------------------------------------------------------------------

* Also removed unnecessary error messages in "__init__" methods of
UnaryFunction1D types.

Modified Paths:
--------------
    branches/soc-2008-mxcurioni/source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DDouble.cpp
    branches/soc-2008-mxcurioni/source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DEdgeNature.cpp
    branches/soc-2008-mxcurioni/source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DFloat.cpp
    branches/soc-2008-mxcurioni/source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DUnsigned.cpp
    branches/soc-2008-mxcurioni/source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DVec2f.cpp
    branches/soc-2008-mxcurioni/source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DVec3f.cpp
    branches/soc-2008-mxcurioni/source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DVectorViewShape.cpp
    branches/soc-2008-mxcurioni/source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DVoid.cpp
    branches/soc-2008-mxcurioni/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_Nature_EdgeNature/BPy_CurveNatureF1D.cpp
    branches/soc-2008-mxcurioni/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_Vec2f/BPy_Normal2DF1D.cpp
    branches/soc-2008-mxcurioni/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_Vec2f/BPy_Orientation2DF1D.cpp
    branches/soc-2008-mxcurioni/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_Vec3f/BPy_Orientation3DF1D.cpp
    branches/soc-2008-mxcurioni/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_Curvature2DAngleF1D.cpp
    branches/soc-2008-mxcurioni/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_DensityF1D.cpp
    branches/soc-2008-mxcurioni/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_GetCompleteViewMapDensityF1D.cpp
    branches/soc-2008-mxcurioni/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_GetDirectionalViewMapDensityF1D.cpp
    branches/soc-2008-mxcurioni/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_GetProjectedXF1D.cpp
    branches/soc-2008-mxcurioni/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_GetProjectedYF1D.cpp
    branches/soc-2008-mxcurioni/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_GetProjectedZF1D.cpp
    branches/soc-2008-mxcurioni/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_GetSteerableViewMapDensityF1D.cpp
    branches/soc-2008-mxcurioni/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_GetViewMapGradientNormF1D.cpp
    branches/soc-2008-mxcurioni/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_GetXF1D.cpp
    branches/soc-2008-mxcurioni/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_GetYF1D.cpp
    branches/soc-2008-mxcurioni/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_GetZF1D.cpp
    branches/soc-2008-mxcurioni/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_LocalAverageDepthF1D.cpp
    branches/soc-2008-mxcurioni/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_double/BPy_ZDiscontinuityF1D.cpp
    branches/soc-2008-mxcurioni/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_unsigned_int/BPy_QuantitativeInvisibilityF1D.cpp

Modified: branches/soc-2008-mxcurioni/source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DDouble.cpp
===================================================================
--- branches/soc-2008-mxcurioni/source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DDouble.cpp	2009-08-03 14:06:47 UTC (rev 22179)
+++ branches/soc-2008-mxcurioni/source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DDouble.cpp	2009-08-03 14:38:15 UTC (rev 22180)
@@ -217,12 +217,10 @@
 
 int UnaryFunction1DDouble___init__(BPy_UnaryFunction1DDouble* self, PyObject *args)
 {
-	PyObject *obj;
+	PyObject *obj = 0;
 
-	if( !PyArg_ParseTuple(args, "|O!", &IntegrationType_Type, &obj) ) {
-		cout << "ERROR: UnaryFunction1DDouble___init__ " << endl;		
+	if( !PyArg_ParseTuple(args, "|O!", &IntegrationType_Type, &obj) ) 	
 		return -1;
-	}
 	
 	if( !obj )
 		self->uf1D_double = new UnaryFunction1D<double>();

Modified: branches/soc-2008-mxcurioni/source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DEdgeNature.cpp
===================================================================
--- branches/soc-2008-mxcurioni/source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DEdgeNature.cpp	2009-08-03 14:06:47 UTC (rev 22179)
+++ branches/soc-2008-mxcurioni/source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DEdgeNature.cpp	2009-08-03 14:38:15 UTC (rev 22180)
@@ -138,12 +138,10 @@
 
 int UnaryFunction1DEdgeNature___init__(BPy_UnaryFunction1DEdgeNature* self, PyObject *args)
 {
-	PyObject *obj;
+	PyObject *obj = 0;
 
-	if( !PyArg_ParseTuple(args, "|O!", &IntegrationType_Type, &obj) ) {
-		cout << "ERROR: UnaryFunction1DEdgeNature___init__ " << endl;		
+	if( !PyArg_ParseTuple(args, "|O!", &IntegrationType_Type, &obj) )		
 		return -1;
-	}
 	
 	if( !obj )
 		self->uf1D_edgenature = new UnaryFunction1D<Nature::EdgeNature>();

Modified: branches/soc-2008-mxcurioni/source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DFloat.cpp
===================================================================
--- branches/soc-2008-mxcurioni/source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DFloat.cpp	2009-08-03 14:06:47 UTC (rev 22179)
+++ branches/soc-2008-mxcurioni/source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DFloat.cpp	2009-08-03 14:38:15 UTC (rev 22180)
@@ -131,12 +131,10 @@
 
 int UnaryFunction1DFloat___init__(BPy_UnaryFunction1DFloat* self, PyObject *args)
 {
-	PyObject *obj;
+	PyObject *obj = 0;
 
-	if( !PyArg_ParseTuple(args, "|O!", &IntegrationType_Type, &obj) ) {
-		cout << "ERROR: UnaryFunction1DFloat___init__ " << endl;		
+	if( !PyArg_ParseTuple(args, "|O!", &IntegrationType_Type, &obj) )	
 		return -1;
-	}
 	
 	if( !obj )
 		self->uf1D_float = new UnaryFunction1D<float>();

Modified: branches/soc-2008-mxcurioni/source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DUnsigned.cpp
===================================================================
--- branches/soc-2008-mxcurioni/source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DUnsigned.cpp	2009-08-03 14:06:47 UTC (rev 22179)
+++ branches/soc-2008-mxcurioni/source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DUnsigned.cpp	2009-08-03 14:38:15 UTC (rev 22180)
@@ -138,12 +138,10 @@
 
 int UnaryFunction1DUnsigned___init__(BPy_UnaryFunction1DUnsigned* self, PyObject *args)
 {
-	PyObject *obj;
+	PyObject *obj = 0;
 
-	if( !PyArg_ParseTuple(args, "|O!", &IntegrationType_Type, &obj) ) {
-		cout << "ERROR: UnaryFunction1DUnsigned___init__ " << endl;		
+	if( !PyArg_ParseTuple(args, "|O!", &IntegrationType_Type, &obj) )	
 		return -1;
-	}
 	
 	if( !obj )
 		self->uf1D_unsigned = new UnaryFunction1D<unsigned int>();

Modified: branches/soc-2008-mxcurioni/source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DVec2f.cpp
===================================================================
--- branches/soc-2008-mxcurioni/source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DVec2f.cpp	2009-08-03 14:06:47 UTC (rev 22179)
+++ branches/soc-2008-mxcurioni/source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DVec2f.cpp	2009-08-03 14:38:15 UTC (rev 22180)
@@ -144,12 +144,10 @@
 
 int UnaryFunction1DVec2f___init__(BPy_UnaryFunction1DVec2f* self, PyObject *args)
 {
-	PyObject *obj;
+	PyObject *obj = 0;
 
-	if( !PyArg_ParseTuple(args, "|O!", &IntegrationType_Type, &obj) ) {
-		cout << "ERROR: UnaryFunction1DVec2f___init__ " << endl;		
+	if( !PyArg_ParseTuple(args, "|O!", &IntegrationType_Type, &obj) )	
 		return -1;
-	}
 	
 	if( !obj )
 		self->uf1D_vec2f = new UnaryFunction1D<Vec2f>();

Modified: branches/soc-2008-mxcurioni/source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DVec3f.cpp
===================================================================
--- branches/soc-2008-mxcurioni/source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DVec3f.cpp	2009-08-03 14:06:47 UTC (rev 22179)
+++ branches/soc-2008-mxcurioni/source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DVec3f.cpp	2009-08-03 14:38:15 UTC (rev 22180)
@@ -138,12 +138,10 @@
 
 int UnaryFunction1DVec3f___init__(BPy_UnaryFunction1DVec3f* self, PyObject *args)
 {
-	PyObject *obj;
+	PyObject *obj = 0;
 
-	if( !PyArg_ParseTuple(args, "|O!", &IntegrationType_Type, &obj) ) {
-		cout << "ERROR: UnaryFunction1DVec3f___init__ " << endl;		
+	if( !PyArg_ParseTuple(args, "|O!", &IntegrationType_Type, &obj) )	
 		return -1;
-	}
 	
 	if( !obj )
 		self->uf1D_vec3f = new UnaryFunction1D<Vec3f>();

Modified: branches/soc-2008-mxcurioni/source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DVectorViewShape.cpp
===================================================================
--- branches/soc-2008-mxcurioni/source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DVectorViewShape.cpp	2009-08-03 14:06:47 UTC (rev 22179)
+++ branches/soc-2008-mxcurioni/source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DVectorViewShape.cpp	2009-08-03 14:38:15 UTC (rev 22180)
@@ -151,12 +151,10 @@
 
 int UnaryFunction1DVectorViewShape___init__(BPy_UnaryFunction1DVectorViewShape* self, PyObject *args)
 {
-	PyObject *obj;
+	PyObject *obj = 0;
 
-	if( !PyArg_ParseTuple(args, "|O!", &IntegrationType_Type, &obj) ) {
-		cout << "ERROR: UnaryFunction1DVectorViewShape___init__ " << endl;		
+	if( !PyArg_ParseTuple(args, "|O!", &IntegrationType_Type, &obj) )
 		return -1;
-	}
 	
 	if( !obj )
 		self->uf1D_vectorviewshape = new UnaryFunction1D< std::vector<ViewShape*> >();

Modified: branches/soc-2008-mxcurioni/source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DVoid.cpp
===================================================================
--- branches/soc-2008-mxcurioni/source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DVoid.cpp	2009-08-03 14:06:47 UTC (rev 22179)
+++ branches/soc-2008-mxcurioni/source/blender/freestyle/intern/python/UnaryFunction1D/BPy_UnaryFunction1DVoid.cpp	2009-08-03 14:38:15 UTC (rev 22180)
@@ -152,12 +152,10 @@
 
 int UnaryFunction1DVoid___init__(BPy_UnaryFunction1DVoid* self, PyObject *args)
 {
-	PyObject *obj;
+	PyObject *obj = 0;
 
-	if( !PyArg_ParseTuple(args, "|O!", &IntegrationType_Type, &obj) ) {
-		cout << "ERROR: UnaryFunction1DVoid___init__ " << endl;		
+	if( !PyArg_ParseTuple(args, "|O!", &IntegrationType_Type, &obj) )
 		return -1;
-	}
 	
 	if( !obj )
 		self->uf1D_void = new UnaryFunction1D_void();

Modified: branches/soc-2008-mxcurioni/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_Nature_EdgeNature/BPy_CurveNatureF1D.cpp
===================================================================
--- branches/soc-2008-mxcurioni/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_Nature_EdgeNature/BPy_CurveNatureF1D.cpp	2009-08-03 14:06:47 UTC (rev 22179)
+++ branches/soc-2008-mxcurioni/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_Nature_EdgeNature/BPy_CurveNatureF1D.cpp	2009-08-03 14:38:15 UTC (rev 22180)
@@ -104,10 +104,8 @@
 {
 	PyObject *obj = 0;
 
-	if( !PyArg_ParseTuple(args, "|O!", &IntegrationType_Type, &obj) ) {
-		cout << "ERROR: CurveNatureF1D___init__" << endl;		
+	if( !PyArg_ParseTuple(args, "|O!", &IntegrationType_Type, &obj) )
 		return -1;
-	}
 	
 	IntegrationType t = ( obj ) ? IntegrationType_from_BPy_IntegrationType(obj) : MEAN;
 	self->py_uf1D_edgenature.uf1D_edgenature = new Functions1D::CurveNatureF1D(t);

Modified: branches/soc-2008-mxcurioni/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_Vec2f/BPy_Normal2DF1D.cpp
===================================================================
--- branches/soc-2008-mxcurioni/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_Vec2f/BPy_Normal2DF1D.cpp	2009-08-03 14:06:47 UTC (rev 22179)
+++ branches/soc-2008-mxcurioni/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_Vec2f/BPy_Normal2DF1D.cpp	2009-08-03 14:38:15 UTC (rev 22180)
@@ -104,10 +104,8 @@
 {
 	PyObject *obj = 0;
 
-	if( !PyArg_ParseTuple(args, "|O!", &IntegrationType_Type, &obj) ) {
-		cout << "ERROR: Normal2DF1D___init__" << endl;		
+	if( !PyArg_ParseTuple(args, "|O!", &IntegrationType_Type, &obj) )
 		return -1;
-	}
 
 	IntegrationType t = ( obj ) ? IntegrationType_from_BPy_IntegrationType(obj) : MEAN;
 	self->py_uf1D_vec2f.uf1D_vec2f = new Functions1D::Normal2DF1D(t);

Modified: branches/soc-2008-mxcurioni/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_Vec2f/BPy_Orientation2DF1D.cpp
===================================================================
--- branches/soc-2008-mxcurioni/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_Vec2f/BPy_Orientation2DF1D.cpp	2009-08-03 14:06:47 UTC (rev 22179)
+++ branches/soc-2008-mxcurioni/source/blender/freestyle/intern/python/UnaryFunction1D/UnaryFunction1D_Vec2f/BPy_Orientation2DF1D.cpp	2009-08-03 14:38:15 UTC (rev 22180)
@@ -104,10 +104,8 @@
 {
 	PyObject *obj = 0;
 
-	if( !PyArg_ParseTuple(args, "|O!", &IntegrationType_Type, &obj) ) {
-		cout << "ERROR: Orientation2DF1D___init__" << endl;		
+	if( !PyArg_ParseTuple(args, "|O!", &IntegrationType_Type, &obj) )
 		return -1;
-	}
 

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list