Pb setting IPTC Tags

Bug #363873 reported by snowgoon88
24
This bug affects 4 people
Affects Status Importance Assigned to Milestone
Phatch
Triaged
Medium
Unassigned
pyexiv2
Fix Released
High
Olivier Tilloy

Bug Description

When setting a "string" IPTC Tags with 'str', the cached value becomes a tuple. It is also the case with some multi-valued IPTC tag (like 'Iptc.Application2.Keywords') when set with one single str value.
But when the image is read again, it has its correct value.
I thought it was relevant to bug #183332 (https://bugs.launchpad.net/pyexiv2/+bug/183332) but I checked:
 - the bug's fixe (fix N°95 in bzr) is in my version of pyexiv2 (debian 0.1.2-4+b1)
 - even with pyexiv 0.1.3 (with exiv2 0.18) the "bug" is still there.

In [1]: import pyexiv2
In [2]: im = pyexiv2.Image("Images/p20080921_105313.jpg")
In [3]: im.readMetadata()
In [4]: im['Iptc.Application2.City']
Out[4]: 'coucou'
In [5]: im['Iptc.Application2.City'] = 'beep'
In [6]: im['Iptc.Application2.City']
Out[6]: ('b', 'e', 'e', 'p')

In [7]: im.writeMetadata()
In [8]: im.readMetadata()
In [9]: im['Iptc.Application2.City']
Out[9]: ('b', 'e', 'e', 'p')

In [10]: im = pyexiv2.Image("Images/p20080921_105313.jpg")
In [11]: im.readMetadata()
In [12]: im['Iptc.Application2.City']
Out[12]: 'beep'

Related branches

Revision history for this message
Olivier Tilloy (osomon) wrote :

Thanks for the report.
This bug should be fixed in the 0.2 branch.

Changed in pyexiv2:
assignee: nobody → Olivier Tilloy (osomon)
importance: Undecided → High
milestone: none → 0.2
status: New → Confirmed
Revision history for this message
Olivier Tilloy (osomon) wrote :

Fix committed with revision 234 of the 0.2 branch.
Trying to set the values of an IPTC tag to something else than a list or a tuple now raises a TypeError.

Changed in pyexiv2:
status: Confirmed → Fix Committed
Revision history for this message
Andrea Ambu (andreambu) wrote :

Hi Olivier,

does it require any particular effort to fix this for series 0.1.x too?
Ubuntu is actually shipping 0.1.3-3build1 and an updated of the current shipped library would be very nice to see.
I tried to play a little with and come up deleting two lines. On the bottom there is the diff, it doesn't seem to break the unittest, anyway that test must be there for a reason, what would not work in this way?

Andrea

=== modified file 'src/pyexiv2.py'
--- src/pyexiv2.py 2009-03-14 21:43:49 +0000
+++ src/pyexiv2.py 2010-02-15 18:32:50 +0000
@@ -654,8 +654,6 @@
      except KeyError:
       pass
    if len(newValues) > 0:
- if len(newValues) == 1:
- newValues = newValues[0]
     self.__iptcTagsDict[key] = tuple([ConvertToPythonType(tagFamily, typeName, str(v)) for v in newValues])
    else:
     if self.__iptcTagsDict.has_key(key):

Revision history for this message
Olivier Tilloy (osomon) wrote :

Hi Andrea,
The patch seems to make sense from what I can read, and I can't recall why this test is here in the first place.
It doesn't break the unit tests, but on the other hand unit tests don't really check thoroughly this piece of code.
I'm not against merging the patch, but I'm concerned about potential regressions we cannot spot right now.
I'm currently focusing my efforts on putting the finishing touch to the 0.2 branch to release it as soon as possible, in the hope that I can drop maintenance of the 0.1 branch which proved to be buggy in various places and difficult to maintain.
If you are willing to do some more testing, I certainly wouldn't mind merging the patch, and we can then propose it for inclusion in the debian/ubuntu packages.

Stani (stani)
Changed in phatch:
assignee: nobody → Andrea Ambu (andreambu)
importance: Undecided → Medium
status: New → In Progress
Revision history for this message
Andrea Ambu (andreambu) wrote :

Well we are actually using the library in Phatch. When debugging I came up to that check. For each test I did it seems to work. If you think of some specific test just tell me and I'll try to test it.

Andrea

Olivier Tilloy (osomon)
Changed in pyexiv2:
status: Fix Committed → Fix Released
Revision history for this message
Stani (stani) wrote :

Should be fixed in phatch 0.3 with pyexiv2 0.2

@Andrea:
Feel free to fix and re-assign this bug when we start working on 0.3

Changed in phatch:
assignee: Andrea Ambu (andreambu) → nobody
status: In Progress → Triaged
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Duplicates of this bug

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.