bugzilla2trac.py: Attachments are copied incorrectly
|Reported by:||Owned by:||Jeroen Ruigrok van der Werven|
I am using bugzilla2trac.py to convert existing bugzilla data into Trac and it works quite nice. I did have an issue with attachments however. The software versions I am using are (and I cannot upgrade, because I am not the system administrator):
- Python: 2.3.4
- Bugzilla: 3.0.2
- Mysql: 4.0.18
- Trac: 0.10.4
- bugzilla2trac.py: revision 8272
- MySQL-python: 1.2.1_p2
In my bugzilla2trac.py I used: BZ_VERSION = 2233
The script works, but all attachments are corrupt. Instead of the original bytes, I see the array representation in the newly created attachments. A gif file starts for example:
array('c', 'GIF89aD\x02\xff\x00\xf7\x00\x00\x00\x00\x00\x00+S\x0 …..
I am a complete Python newbie, but managed to get correct attachments by changing:
line 436 filedata = StringIO.StringIO(a['thedata'])
filedata = StringIO.StringIO(a['thedata'].tostring())
is a character array and StringIO.StringIO uses str(buffer) to construct a file object.
By the way (don't know if it is relevant): the data column in my 'attach_data' bugzilla table is a LONGBLOB and the table itself is a MyISAM table.
My change to line 436 works, but I don't understand why it is necessary. Is it simply because I am using old versions of Python or Trac? Is it because I am using a newer version of Mysql or a newer version of Bugzilla than anticipated?
Personally, I can manage with my local change as a workaround, but I would like somebody who really understands how things are working to judge if my change should be applied as a patch (or not).