Comment 0 for bug 961705

Revision history for this message
Hobson Lane (hobs) wrote :

Looks like a local variable, type needs to be defined at the start of _compute_value() because it is used throughout. Alternatively it should us self.type insted of type to raise XmpValueError. It seems there are a lot of repeated patterns that could be turned into static functions to reduce these sorts of errors.

Lines 185-204 of src/pyexiv2/xmp.py:

    def _compute_value(self):
        # Lazy computation of the value from the raw value
        if self.type.startswith(('seq', 'bag', 'alt')):
            type = self.type[4:]
            if type.lower().startswith('closed choice of'):
                type = type[17:]
            self._value = map(lambda x: self._convert_to_python(x, type), self._raw_value)
        elif self.type == 'Lang Alt':
            self._value = {}
            for k, v in self._raw_value.iteritems():
                try:
                    self._value[unicode(k, 'utf-8')] = unicode(v, 'utf-8')
                except TypeError:
                    raise XmpValueError(self._raw_value, type) # FIXME: variable type is undefined here