Atom: avoid TypeError with PyPy
authorZac Medico <zmedico@gentoo.org>
Wed, 8 Jun 2011 19:03:25 +0000 (12:03 -0700)
committerZac Medico <zmedico@gentoo.org>
Wed, 8 Jun 2011 19:03:25 +0000 (12:03 -0700)
Our test cases pass in raw bytes here, which causes _atom_base.__init__
to raise TypeError with PyPy.

pym/portage/dep/__init__.py

index 8332a05e4edd7d8584bc5cdd10e1d36fb20e0028..862154318ca643d4def25c08f14f05a736cf5b38 100644 (file)
@@ -30,7 +30,7 @@ __all__ = [
 import re, sys
 import warnings
 from itertools import chain
-import portage.exception
+from portage import _unicode_decode
 from portage.eapi import eapi_has_slot_deps, eapi_has_src_uri_arrows, \
        eapi_has_use_deps, eapi_has_strong_blocks, eapi_has_use_dep_defaults
 from portage.exception import InvalidAtom, InvalidData, InvalidDependString
@@ -1057,6 +1057,10 @@ class Atom(_atom_base):
                        raise TypeError(_("Expected %s, got %s") % \
                                (_atom_base, type(s)))
 
+               if not isinstance(s, _atom_base):
+                       # Avoid TypeError with from _atom_base.__init__ with PyPy.
+                       s = _unicode_decode(s)
+
                _atom_base.__init__(s)
 
                if "!" == s[:1]: