Comment 2 for bug 961705

Revision history for this message
Hobson Lane (hobs) wrote : Re: [Bug 961705] Re: undefined local variable "type" in XmpTag._compute_value()

Wow. That is mysterious. Sorry for the hassle...again. Must've been an
errant keystroke on my local checkout.

On Mon, Apr 23, 2012 at 3:12 AM, Olivier Tilloy <email address hidden> wrote:

> What version of the code are you running?
> The trunk branch doesn’t have this, it already refers to self.type, and
> this line of code was never changed since it was first introduced,
> according to the branch’s history.
>
> See
>
> http://bazaar.launchpad.net/~osomon/pyexiv2/pyexiv2-0.3/view/head:/src/pyexiv2/xmp.py#L185
> .
>
> I’m guessing you’re running a modified version of the code that has this
> bug.
>
> ** Changed in: pyexiv2
> Status: New => Invalid
>
> --
> You received this bug notification because you are subscribed to the bug
> report.
> https://bugs.launchpad.net/bugs/961705
>
> Title:
> undefined local variable "type" in XmpTag._compute_value()
>
> Status in pyexiv2, a python binding to exiv2:
> Invalid
>
> Bug description:
> Looks like a local variable, `type`, needs to be defined at the start
> of XmpTag._compute_value() because it is used throughout.
> Alternatively compute_value should use 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
>
> To manage notifications about this bug go to:
> https://bugs.launchpad.net/pyexiv2/+bug/961705/+subscriptions
>