Created attachment 328544 [details] handle unicode strings The first parameter passed into any of the xattr calls may be either a filename or a file object. However if the filename is a unicode string rather than a str object the functions fail producing the error: argument 1 must be string or int even though the argument is a string. This occurs due to the convertObj function which only checks for str objects. Normally the str vs. unicode handling would be taken care of by PyArg_ParseTuple, but because the first arg may be a variety of object types the PyArg_ParseTuple logic is bypassed and instead convertObj is called on the first parameter. If PyArg_ParseTuple had been passed a format specifier of 's' for the first arg then a unicode object would have been encoded to a C string using the default encoding. There are other string functions which can be called directly on a PyObject string which will return a decoded C string using the default encoding, however even though the default encoding will work most of the time for filenames it is not technically the right encoding, one should use the encoding specified for the file system (Py_FileSystemDefaultEncoding, see the posix module for examples). When you decode a unicode object to something other than the default encoding the decoded C string is malloc'ed and must be freed (see the documentation of the 'e' format conversion specifiers for PyArg_ParseTuple and it's implementation in the posix module). I have fixed the above problems and provided a patch which is attached. The patch works by modifying convertObj to check for both str objects and unicode objects. In both cases the filename returned through the filename pointer parameter is malloc'ed string which the caller must free. In the case of a unicode object it is decoded using the Py_FileSystemDefaultEncoding. I also updated each location where convertObj is called to free the filename string.
Thank you John for your report and a patch. I think it would be better to merge it upstream and I sent it to the author: https://sourceforge.net/tracker/index.php?func=detail&aid=2495931&group_id=69931&atid=526201 I suggest to wait for his feedback to decide does it make sense to release the next version of RPM or wait for the next version of pyxattr.
This message is a reminder that Fedora 10 is nearing its end of life. Approximately 30 (thirty) days from now Fedora will stop maintaining and issuing updates for Fedora 10. It is Fedora's policy to close all bug reports from releases that are no longer maintained. At that time this bug will be closed as WONTFIX if it remains open with a Fedora 'version' of '10'. Package Maintainer: If you wish for this bug to remain open because you plan to fix it in a currently maintained version, simply change the 'version' to a later Fedora version prior to Fedora 10's end of life. Bug Reporter: Thank you for reporting this issue and we are sorry that we may not be able to fix it before Fedora 10 is end of life. If you would still like to see this bug fixed and are able to reproduce it against a later version of Fedora please change the 'version' of this bug to the applicable version. If you are unable to change the version, please add a comment here and someone will do it for you. Although we aim to fix as many bugs as possible during every release's lifetime, sometimes those efforts are overtaken by events. Often a more recent Fedora release includes newer upstream software that fixes bugs or makes them obsolete. The process we are following is described here: http://fedoraproject.org/wiki/BugZappers/HouseKeeping
Hello again John! Yesterday I've got a notification from pyxattr's author about a new version which should solve a problem with unicode strings (he has missed previous bug reports :) ). I've made packages which are available from my webpage: http://timeoff.wsisiz.edu.pl/rpms/pyxattr/pyxattr-0.5.0-1.fc11.i586.rpm http://timeoff.wsisiz.edu.pl/rpms/pyxattr/pyxattr-0.5.0-1.src.rpm (in case you have Fedora 12 or use another architecture and need to rebuild) Could you check if that works for you? (then I would put in into normal Fedora package repository) Marcin
A very quick check on F-12 after building from the srpm seems to indicate this is working. I also did a quick check on how the C file was coded and it seems fine as well.
pyxattr-0.5.0-1.fc12 has been submitted as an update for Fedora 12. http://admin.fedoraproject.org/updates/pyxattr-0.5.0-1.fc12
pyxattr-0.5.0-1.fc12 has been pushed to the Fedora 12 testing repository. If problems still persist, please make note of it in this bug report. If you want to test the update, you can install it with su -c 'yum --enablerepo=updates-testing update pyxattr'. You can provide feedback for this update here: http://admin.fedoraproject.org/updates/F12/FEDORA-2010-0587
pyxattr-0.5.0-1.fc12 has been pushed to the Fedora 12 stable repository. If problems still persist, please make note of it in this bug report.