[Scipy-svn] r6766 - trunk/scipy/io/matlab

scipy-svn@scip... scipy-svn@scip...
Sat Sep 11 20:02:00 CDT 2010


Author: ptvirtan
Date: 2010-09-11 20:02:00 -0500 (Sat, 11 Sep 2010)
New Revision: 6766

Modified:
   trunk/scipy/io/matlab/mio5_utils.pyx
Log:
ENH: io/matlab: avoid swallowing exceptions in VarReader5 methods

Modified: trunk/scipy/io/matlab/mio5_utils.pyx
===================================================================
--- trunk/scipy/io/matlab/mio5_utils.pyx	2010-09-12 01:01:46 UTC (rev 6765)
+++ trunk/scipy/io/matlab/mio5_utils.pyx	2010-09-12 01:02:00 UTC (rev 6766)
@@ -342,10 +342,10 @@
             pp[0] = <char *>data
         return data
 
-    cdef void read_element_into(self,
-                                cnp.uint32_t *mdtype_ptr,
-                                cnp.uint32_t *byte_count_ptr,
-                                void *ptr):
+    cdef int read_element_into(self,
+                               cnp.uint32_t *mdtype_ptr,
+                               cnp.uint32_t *byte_count_ptr,
+                               void *ptr) except -1:
         ''' Read element into pre-allocated memory in `ptr`
 
         Parameters
@@ -379,6 +379,7 @@
             mod8 = byte_count % 8
             if mod8:
                 self.cstream.seek(8 - mod8, 1)
+        return 0
     
     cpdef inline cnp.ndarray read_numeric(self, int copy=True):
         ''' Read numeric data element into ndarray
@@ -476,9 +477,9 @@
         self.cread_full_tag(&mdtype, &byte_count)
         return mdtype, byte_count
 
-    cdef void cread_full_tag(self,
-                        cnp.uint32_t* mdtype,
-                        cnp.uint32_t* byte_count):
+    cdef int cread_full_tag(self,
+                            cnp.uint32_t* mdtype,
+                            cnp.uint32_t* byte_count) except -1:
         ''' C method for reading full u4, u4 tag from stream'''
         cdef cnp.uint32_t u4s[2]
         self.cstream.read_into(<void *>u4s, 8)
@@ -488,6 +489,7 @@
         else:
             mdtype[0] = u4s[0]
             byte_count[0] = u4s[1]
+        return 0
 
     cpdef VarHeader5 read_header(self):
         ''' Return matrix header for current stream position



More information about the Scipy-svn mailing list