From 39f12bd49a49b96d435c0ab7915bde6011d34f0f Mon Sep 17 00:00:00 2001 From: Eric Wieser Date: Tue, 3 Aug 2021 16:19:51 +0100 Subject: Do not call get_user_id if it is not needed On systems without any environment variables and no pwd module, gitpython crashes as it tries to read the environment variable before looking at its config. --- git/util.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/git/util.py b/git/util.py index 92d95379..84d0b015 100644 --- a/git/util.py +++ b/git/util.py @@ -704,7 +704,11 @@ class Actor(object): setattr(actor, attr, val) except KeyError: if config_reader is not None: - setattr(actor, attr, config_reader.get_value('user', cvar, default())) + try: + val = config_reader.get_value('user', cvar) + except Exception: + val = default() + setattr(actor, attr, val) # END config-reader handling if not getattr(actor, attr): setattr(actor, attr, default()) -- cgit v1.2.1