[Bf-blender-cvs] [b94efe0] master: BGE: remove Py3.1 workaround

Campbell Barton noreply at git.blender.org
Mon Jan 26 17:35:25 CET 2015


Commit: b94efe0e8b785598933d9f506b965068652fb579
Author: Campbell Barton
Date:   Tue Jan 27 02:17:56 2015 +1100
Branches: master
https://developer.blender.org/rBb94efe0e8b785598933d9f506b965068652fb579

BGE: remove Py3.1 workaround

===================================================================

M	source/gameengine/VideoTexture/ImageBase.cpp

===================================================================

diff --git a/source/gameengine/VideoTexture/ImageBase.cpp b/source/gameengine/VideoTexture/ImageBase.cpp
index 0d46160..5a07b84 100644
--- a/source/gameengine/VideoTexture/ImageBase.cpp
+++ b/source/gameengine/VideoTexture/ImageBase.cpp
@@ -713,25 +713,19 @@ static int Image_getbuffer(PyImage *self, Py_buffer *view, int flags)
 	unsigned int * image;
 	int ret;
 
-	try
-	{
+	try {
 		// can throw in case of resize
 		image = self->m_image->getImage();
 	}
-	catch (Exception & exp)
-	{
+	catch (Exception & exp) {
 		// cannot return -1, this creates a crash in Python, for now we will just return an empty buffer
 		exp.report();
-		//return -1;
-		goto error;
+		return -1;
 	}
 
-	if (!image)
-	{
-		// same remark, see above
-		//PyErr_SetString(PyExc_BufferError, "Image buffer is not available");
-		//return -1;
-		goto error;
+	if (!image) {
+		PyErr_SetString(PyExc_BufferError, "Image buffer is not available");
+		return -1;
 	}
 	if (view == NULL)
 	{
@@ -742,17 +736,6 @@ static int Image_getbuffer(PyImage *self, Py_buffer *view, int flags)
 	if (ret >= 0)
 		self->m_image->m_exports++;
 	return ret;
-
-error:
-	// Return a empty buffer to avoid a crash in Python 3.1
-	// The bug is fixed in Python SVN 77916, as soon as the python revision used by Blender is
-	// updated, you can simply return -1 and set the error
-	static char* buf = (char *)"";
-	ret = PyBuffer_FillInfo(view, (PyObject *)self, buf, 0, 0, flags);
-	if (ret >= 0)
-		self->m_image->m_exports++;
-	return ret;
-	
 }
 
 static void Image_releaseBuffer(PyImage *self, Py_buffer *buffer)




More information about the Bf-blender-cvs mailing list