Browse Source

Py_buffer is not available in Python versions before 2.6

rdb 12 years ago
parent
commit
87aa66f09c

+ 4 - 3
panda/src/express/pointerToArray.I

@@ -96,6 +96,7 @@ PointerToArray(PyObject *self, PyObject *source) :
   // self in the constructor--the caller can't initialize this for us.
   ((Dtool_PyInstDef *)self)->_ptr_to_object = this;
 
+#if PY_VERSION_HEX >= 0x02060000
   if (PyObject_CheckBuffer(source)) {
     // User passed a buffer object.
     Py_buffer view;
@@ -119,6 +120,7 @@ PointerToArray(PyObject *self, PyObject *source) :
     PyBuffer_Release(&view);
     return;
   }
+#endif
 
   if (!PySequence_Check(source)) {
     // If passed with a non-sequence, this isn't the right constructor.
@@ -1330,6 +1332,7 @@ clear() {
 }
 
 #ifdef HAVE_PYTHON
+#if PY_VERSION_HEX >= 0x02060000
 ////////////////////////////////////////////////////////////////////
 //     Function: PointerToArray::__getbuffer__
 //       Access: Published
@@ -1342,7 +1345,6 @@ INLINE int PointerToArray<Element>::
 __getbuffer__(PyObject *self, Py_buffer *view, int flags) {
 
   const char *format = get_format_code(Element);
-  cerr << "non-const __getbuffer__ with fmt " << format << "\n";
   if (format == NULL) {
     // Not supported.
     return -1;
@@ -1411,14 +1413,12 @@ INLINE int ConstPointerToArray<Element>::
 __getbuffer__(PyObject *self, Py_buffer *view, int flags) const {
 
   if ((flags & PyBUF_WRITABLE) == PyBUF_WRITABLE) {
-    cerr << "writable buffer requested of const array\n";
     PyErr_SetString(PyExc_BufferError,
                     "Object is not writable.");
     return -1;
   }
 
   const char *format = get_format_code(Element);
-  cerr << "const __getbuffer__ with fmt " << format << "\n";
   if (format == NULL) {
     // Not supported.
     return -1;
@@ -1474,6 +1474,7 @@ __releasebuffer__(PyObject *self, Py_buffer *view) const {
     view->internal = NULL;
   }
 }
+#endif  // PY_VERSION_HEX
 #endif  // HAVE_PYTHON
 
 #endif  // CPPPARSER

+ 2 - 0
panda/src/express/pointerToArray.h

@@ -131,9 +131,11 @@ PUBLISHED:
   INLINE int get_node_ref_count() const;
 
 #ifdef HAVE_PYTHON
+#if PY_VERSION_HEX >= 0x02060000
   int __getbuffer__(PyObject *self, Py_buffer *view, int flags);
   void __releasebuffer__(PyObject *self, Py_buffer *view) const;
 #endif
+#endif
 
 #else  // CPPPARSER
   // This is the actual, complete interface.

+ 2 - 1
panda/src/express/virtualFileMountAndroidAsset.cxx

@@ -129,6 +129,7 @@ read_file(const Filename &file, bool do_uncompress,
   if (asset == (AAsset *)NULL) {
     express_cat.info()
       << "Unable to read " << file << "\n";
+    return false;
   }
 
   // Reserve enough space to hold the entire file.
@@ -251,7 +252,7 @@ get_system_info(const Filename &file, SubfileInfo &info) {
   // We don't actually need the file descriptor, so close it.
   close(fd);
 
-  info = SubfileInfo(_apk_path, start, length); 
+  info = SubfileInfo(_apk_path, start, length);
   return true;
 }