~ubuntu-branches/debian/experimental/h5py/experimental

« back to all changes in this revision

Viewing changes to h5py/highlevel.py

  • Committer: Bazaar Package Importer
  • Author(s): Soeren Sonnenburg
  • Date: 2009-09-24 11:08:03 UTC
  • mfrom: (2.1.1 sid)
  • Revision ID: james.westby@ubuntu.com-20090924110803-hz0en6f43x8opgj4
Tags: 1.2.1-2
Build-depend on hdf5 >= 1.8.3 and enable api 1.8 (Closes: #548049)

Show diffs side-by-side

added added

removed removed

Lines of Context:
60
60
        try:
61
61
            try:
62
62
                fname = fname.encode(sys.getfilesystemencoding())
63
 
            except UnicodeError:
 
63
            except (UnicodeError, LookupError):
64
64
                pass
65
65
            return h5f.is_hdf5(fname)
66
66
        except H5Error:
563
563
        try:
564
564
            name = name.decode(sys.getfilesystemencoding())
565
565
            return name.encode('ascii')
566
 
        except UnicodeError:
 
566
        except (UnicodeError, LookupError):
567
567
            return name
568
568
 
569
569
    @property
616
616
            # If the byte string doesn't match the default encoding, just
617
617
            # pass it on as-is.  Note Unicode objects can always be encoded.
618
618
            name = name.encode(sys.getfilesystemencoding())
619
 
        except UnicodeError:
 
619
        except (UnicodeError, LookupError):
620
620
            pass
621
621
 
622
622
        if mode == 'r':
1012
1012
            if len(names) != 0:
1013
1013
                raise TypeError("Field name selections are not allowed for write.")
1014
1014
 
1015
 
            val2 = numpy.asarray(val, order='C')
1016
 
 
1017
 
            # Special fudge factor for weirdness with scalar compound literals
1018
 
            if self.dtype.kind == 'V' and val2.dtype.kind != 'V':
 
1015
            # Generally we try to avoid converting the arrays on the Python
 
1016
            # side.  However, for compound literals this is unavoidable.
 
1017
            if self.dtype.kind == 'V' and \
 
1018
            (not isinstance(val, numpy.ndarray) or val.dtype.kind != 'V'):
1019
1019
                val = numpy.asarray(val, dtype=self.dtype, order='C')
1020
1020
            else:
1021
 
                val = val2
 
1021
                val = numpy.asarray(val, order='C')
1022
1022
 
1023
1023
            # Check for array dtype compatibility and convert
1024
1024
            if self.dtype.subdtype is not None: