+ for (i = 0; i < PyList_Size(list); i++) {
+ tuple = PyList_GetItem(list, i);
+ if (!PyArg_ParseTuple(tuple, "isUiiiis#",
+ &type, &mime_type, &description, &width, &height, &depth, &colors, &image, &len)) {
+ return 0;
+ }
+
+ description_utf8 = PyUnicode_AsEncodedString(description, "utf8",
+ "strict");
+ if (description_utf8 == 0) {
+ return 0;
+ }
+
+ description_utf8_s = PyString_AsString(description_utf8);
+ if (description_utf8_s == 0) {
+ return 0;
+ }
+
+ bv = new TagLib::ByteVector (image, len);
+ if (bv == 0) {
+ return PyErr_NoMemory();
+ }
+
+ p = new TagLib::ID3v2::AttachedPictureFrame;
+ if (p == 0) {
+ return PyErr_NoMemory();
+ }
+
+ /* Um, look at all these void-returning functions. I'm sure
+ * they can fail, i just have no way to detect it... */
+ p->setType((TagLib::ID3v2::AttachedPictureFrame::Type)type);
+ p->setMimeType(mime_type);
+ p->setDescription(description_utf8_s);
+ p->setTextEncoding(TagLib::String::UTF8);
+ // taglib doesn't support width, height, depth, colors.
+ p->setPicture(*bv);
+
+ // another void-returning function that i bet fails
+ t->addFrame(p);
+ }