Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 873088 - sys-apps/portage-3.0.31: TypeError: getpwnam() argument must be str, not None
Summary: sys-apps/portage-3.0.31: TypeError: getpwnam() argument must be str, not None
Status: RESOLVED FIXED
Alias: None
Product: Portage Development
Classification: Unclassified
Component: Core (show other bugs)
Hardware: All Linux
: Normal normal (vote)
Assignee: Portage team
URL:
Whiteboard:
Keywords: InVCS, REGRESSION
Depends on: 872710
Blocks:
  Show dependency tree
 
Reported: 2022-09-26 17:27 UTC by Zac Medico
Modified: 2022-10-01 03:00 UTC (History)
1 user (show)

See Also:
Package list:
Runtime testing required: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Zac Medico gentoo-dev 2022-09-26 17:27:58 UTC
This bug exists since this commit:

commit 18e5a8170c69aecd10f162918de571d85055ae81 (refs/bisect/bad)
Author: Kenneth Raplee <kenrap@kennethraplee.com>
Date:   Fri Mar 25 15:06:22 2022 -0700

    Miscellaneous refactors and cleanups
    
    Signed-off-by: Kenneth Raplee <kenrap@kennethraplee.com>
    Closes: https://github.com/gentoo/portage/pull/796
    Signed-off-by: Sam James <sam@gentoo.org>

>>> import portage.data
>>> int(portage.data.portage_uid)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "lib/portage/proxy/objectproxy.py", line 93, in __int__
    return int(object.__getattribute__(self, "_get_target")())
  File "lib/portage/data.py", line 305, in _get_target
    return _get_global(object.__getattribute__(self, "_name"))
  File "lib/portage/data.py", line 167, in _get_global
    portage_uid = pwd.getpwnam(_get_global("_portage_username")).pw_uid
TypeError: getpwnam() argument must be str, not None

Simple fix:

diff --git a/lib/portage/data.py b/lib/portage/data.py
index 1ef8d4aef..8aa66df7f 100644
--- a/lib/portage/data.py
+++ b/lib/portage/data.py
@@ -259,7 +259,7 @@ def _get_global(k):
         if env_key in os.environ:
             v = os.environ[env_key]
         elif hasattr(portage, "settings"):
-            v = portage.settings.get(env_key)
+            v = portage.settings.get(env_key, v)
         else:
             # The config class has equivalent code, but we also need to
             # do it here if _disable_legacy_globals() has been called.
Comment 1 Larry the Git Cow gentoo-dev 2022-09-26 17:52:34 UTC
The bug has been referenced in the following commit(s):

https://gitweb.gentoo.org/proj/portage.git/commit/?id=73514c310754def1f8cb932f00296e008b9d4437

commit 73514c310754def1f8cb932f00296e008b9d4437
Author:     Zac Medico <zmedico@gentoo.org>
AuthorDate: 2022-09-26 17:40:33 +0000
Commit:     Zac Medico <zmedico@gentoo.org>
CommitDate: 2022-09-26 17:44:33 +0000

    data.py: fix PORTAGE_USERNAME default (bug 873088)
    
    Fix the PORTAGE_USERNAME default for the case where the portage.settings
    attribute exists and PORTAGE_USERNAME is unset.
    
    Fixes: 18e5a8170c69aecd10f162918de571d85055ae81
    Bug: https://bugs.gentoo.org/873088
    Signed-off-by: Zac Medico <zmedico@gentoo.org>

 lib/portage/data.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Comment 2 Larry the Git Cow gentoo-dev 2022-10-01 03:00:07 UTC
The bug has been closed via the following commit(s):

https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=00f62c1578506cb2d94b3ccf922cb40fa128387a

commit 00f62c1578506cb2d94b3ccf922cb40fa128387a
Author:     Sam James <sam@gentoo.org>
AuthorDate: 2022-10-01 02:59:09 +0000
Commit:     Sam James <sam@gentoo.org>
CommitDate: 2022-10-01 02:59:59 +0000

    sys-apps/portage: add 3.0.38
    
    Closes: https://bugs.gentoo.org/827974
    Closes: https://bugs.gentoo.org/864259
    Closes: https://bugs.gentoo.org/865115
    Closes: https://bugs.gentoo.org/871570
    Closes: https://bugs.gentoo.org/872392
    Closes: https://bugs.gentoo.org/872440
    Closes: https://bugs.gentoo.org/873088
    Signed-off-by: Sam James <sam@gentoo.org>

 sys-apps/portage/Manifest              |   1 +
 sys-apps/portage/portage-3.0.38.ebuild | 273 +++++++++++++++++++++++++++++++++
 2 files changed, 274 insertions(+)