When updating portage to anything stable or testing (currently this includes 2.1.10.65 and 2.1.11) the FileOwner helper from gentoolkit-0.3.0.6-r3 raises an AttributeError on Package. I wasn't sure if this would be a bug in gentoolkit or in portage so I'm indicating both and appropriate versions to help track this down. I also would understand if this is no longer a recognized way to accomplish this and would be willing to accept advice on how to do this the new way. Reproducible: Always Steps to Reproduce: 1.Run the following snippet of code from a python interpreter or script: from gentoolkit.helpers import FileOwner finder = FileOwner() package = unicode(finder(("/usr/bin/python", ))[0][0]) 2.Observe exception indicating that a Package can't be split. Actual Results: The exception raised is the following for the snippet provided (including snippet): alunduil@elijah ~ % ipython In [1]: from gentoolkit.helpers import FileOwner In [2]: finder = FileOwner() In [3]: package = unicode(finder(("/usr/bin/python", ))[0][0]) --------------------------------------------------------------------------- AttributeError Traceback (most recent call last) /home/alunduil/<ipython-input-3-c6fe5207bc02> in <module>() ----> 1 package = unicode(finder(("/usr/bin/python", ))[0][0]) /usr/lib64/portage/pym/portage/versions.pyc in __init__(self, cpv, slot, repo, eapi) 346 cpv = _unicode_decode(cpv) 347 _unicode.__init__(cpv) --> 348 self.__dict__['cpv_split'] = catpkgsplit(cpv, eapi=eapi) 349 if self.cpv_split is None: 350 raise InvalidData(cpv) /usr/lib64/portage/pym/portage/versions.pyc in catpkgsplit(mydata, silent, eapi) 314 except AttributeError: 315 pass --> 316 mysplit = mydata.split('/', 1) 317 p_split=None 318 if len(mysplit)==1: AttributeError: 'Package' object has no attribute 'split' Expected Results: The expectation (and the results with a compatible version of portage) are as follows (again including snippet): alunduil@elijah ~ % ipython In [1]: from gentoolkit.helpers import FileOwner In [2]: finder = FileOwner() In [3]: package = unicode(finder(("/usr/bin/python", ))[0][0]) In [4]: print package app-admin/eselect-python-20111108 I tried looking around to see if this bug was a duplicate but wasn't able to find anything. I apologize if this is already a known issue.
Created attachment 316121 [details, diff] return string from gentoolkit's Package.__str__ This seems to be a bug in gentoolkit. It looks like the problem is that gentoolkit has a Package class which has a __str__ method which gets called when this example code is run, but that method doesn't actually return a string, and instead returns a Package, so when the portage code tries to split the variable which it expects to be a string, it can't. This patch casts the variable returned by the __str__ method into a string.
(In reply to comment #1) > This patch casts the variable returned by the __str__ method into a string. Just curious but is it convention to use str in gentoolkit rather than unicode?
(In reply to comment #2) > (In reply to comment #1) > > This patch casts the variable returned by the __str__ method into a string. > > Just curious but is it convention to use str in gentoolkit rather than > unicode? I used str() because gentoolkit has to be able to work with python3 as well, which automatically is using unicode, and doesn't have the unicode() method. Regardless, I ran a couple tests and it looks like by the time the variable is passed into the portage code, it is recognized as being of type unicode. FYI, I'm not a gentoo or a gentoolkit dev, so if you want a completely authoritative answer, I would ask one of them.
With the proposed patch to gentoolkit everything works as expected for this test case.
The patch has been committed to the gentoolkit repository and can be tested/verified with gentoolkit-9999
The 9999 version works perfectly. Loving the performance boost it buys as well. Thanks for the good work guys. Looking forward to a stable release of this codebase.
Released in gentoolkit-0.3.0.7