--- napi.py	2009-01-30 13:56:17.714652168 +0100
+++ mynapi.py	2009-01-30 18:02:15.241869007 +0100
@@ -1168,8 +1168,8 @@
             datafn = lambda: pdata.value
         else:
             # numeric - use numpy array
-            if dtype=='char': dtype = 'uint8'
-            data = numpy.zeros(shape,dtype)
+            if dtype=='char': data = numpy.zeros(shape[:-1],dtype = 'S%i'%shape[-1])
+            else: data = numpy.zeros(shape,dtype)
             if len(shape) == 1 and shape[0] == 1:
                 datafn = lambda: data[0]
             else:
@@ -1185,36 +1185,30 @@
         with its pointer.
         """
         if dtype == "char":
-            # Character data - pad with zeros to the right length
-            if not _is_string_like(data):
-                raise ValueError,"Expected character data: %s"%(self._loc())
-            if len(data) < shape[0]:
-                data += '\000'*(shape[0]-len(data))
+            data=numpy.array(data).astype('S%i'%shape[-1])
+            data_shape=data.shape+(data.itemsize,)
         else:
             # Convert scalars to vectors of length one
             if numpy.prod(shape) == 1 and not hasattr(data,'shape'):
                 data = numpy.array([data],dtype=dtype)
-            # Check that dimensions match
-            # Ick! need to exclude dimensions of length 1 in order to catch
-            # array slices such as a[:,1], which only report one dimension
-            input_shape = numpy.array([i for i in data.shape if i != 1])
-            target_shape = numpy.array([i for i in shape if i != 1])
-            if len(input_shape) != len(target_shape) or (input_shape != target_shape).any():
-                raise ValueError,\
-                    "Shape mismatch %s!=%s: %s"%(data.shape,shape,self.filename)
+            data_shape=data.shape
+            #Check data type
             if str(data.dtype) != dtype:
                 raise ValueError,\
                     "Type mismatch %s!=%s: %s"%(dtype,data.dtype,self._loc())
+                    
+        # Check that dimensions match
+        # Ick! need to exclude dimensions of length 1 in order to catch
+        # array slices such as a[:,1], which only report one dimension
+        input_shape = numpy.array([i for i in data_shape if i != 1])
+        target_shape = numpy.array([i for i in shape if i != 1])
+        if len(input_shape) != len(target_shape) or (input_shape != target_shape).any():
+            raise ValueError,\
+                "Shape mismatch %s!=%s: %s"%(data_shape,shape,self.filename)
 
-        if dtype == 'char':
-            # String: hand it over as usual for strings.  Assumes the string
-            # is the correct length for the storage area.
-            pdata = data
-        else:
-            # Vector: assume it is of the correct storage class and size
-            data = numpy.ascontiguousarray(data)
-            pdata = data.ctypes.data
-
+        data = numpy.ascontiguousarray(data)
+        pdata = data.ctypes.data
+            
         return data,pdata
 
     def show(self, path=None, indent=0):

