summaryrefslogtreecommitdiffstats
path: root/pym/portage
diff options
context:
space:
mode:
authorZac Medico <zmedico@gentoo.org>2011-12-15 19:11:53 -0800
committerZac Medico <zmedico@gentoo.org>2011-12-15 19:11:53 -0800
commitb7aa8acf8f353c11e622692a863716966eacad6f (patch)
treeb2bb544981a1640b1079fb2c8596d2cf775e8443 /pym/portage
parent9c2990c593d739f19e85415b841273c74e54911d (diff)
downloadportage-b7aa8acf8f353c11e622692a863716966eacad6f.tar.gz
portage-b7aa8acf8f353c11e622692a863716966eacad6f.tar.bz2
portage-b7aa8acf8f353c11e622692a863716966eacad6f.zip
data.py: tweak getgrnam call for PyPy
This makes it unnecessary to explicitly call portage.data._init() in runTests, and fixes some other cases that trigger the same issue.
Diffstat (limited to 'pym/portage')
-rw-r--r--pym/portage/data.py7
-rwxr-xr-xpym/portage/tests/runTests4
2 files changed, 6 insertions, 5 deletions
diff --git a/pym/portage/data.py b/pym/portage/data.py
index cf94ab0cd..ec750a611 100644
--- a/pym/portage/data.py
+++ b/pym/portage/data.py
@@ -87,7 +87,12 @@ def _get_global(k):
#Discover the uid and gid of the portage user/group
try:
portage_uid = pwd.getpwnam(_get_global('_portage_username')).pw_uid
- portage_gid = grp.getgrnam(_get_global('_portage_grpname')).gr_gid
+ _portage_grpname = _get_global('_portage_grpname')
+ if platform.python_implementation() == 'PyPy':
+ # Somehow this prevents "TypeError: expected string" errors
+ # from grp.getgrnam() with PyPy 1.7
+ _portage_grpname = str(_portage_grpname)
+ portage_gid = grp.getgrnam(_portage_grpname).gr_gid
if secpass < 1 and portage_gid in os.getgroups():
secpass = 1
except KeyError:
diff --git a/pym/portage/tests/runTests b/pym/portage/tests/runTests
index 0c476b3eb..4c1008708 100755
--- a/pym/portage/tests/runTests
+++ b/pym/portage/tests/runTests
@@ -30,10 +30,6 @@ import portage
# work the same regardless of global configuration file state/existence.
portage._disable_legacy_globals()
-# Somehow this prevents "TypeError: expected string" errors
-# from grp.getgrnam() with PyPy 1.7
-portage.data._init(os.environ)
-
import portage.tests as tests
from portage.const import PORTAGE_BIN_PATH
path = os.environ.get("PATH", "").split(":")