#9450 Find and replace del os.environ['foo'] with os.environ.pop('foo', None)
Closed: fixed by rcritten. Opened by rcritten.

Issue

A new change included code that called "del os.environ['KRB5CCNAME']" where there was no such value in the environment. This caused an unnecessary installation failure.

commit https://pagure.io/freeipa/c/f248b22ef4d98293224b49576f5e6a1b8d672d76 addressed this issue by using pop instead.

There are other occurrences of this code style spread around various utilities. While it may be fair to assume that a given environment variable will always be present, using pop should be a safer route.

We should find and replace them. From a quick search there are only a few.

$ git grep "del os.environ"
install/certmonger/dogtag-ipa-ca-renew-agent-submit.in:            
del os.environ['CERTMONGER_CA_PROFILE']
ipaclient/install/ipa_certupdate.py:                del os.env
iron['KRB5CCNAME']
ipaserver/install/server/upgrade.py:            del os.environ
['KRB5CCNAME']
ipatests/test_ipaserver/test_ipap11helper.py:            del o
s.environ['SOFTHSM2_CONF']

Metadata Update from @abbra:
- Issue assigned to ianbrown78

Assigned to @ianbrown78 who submited PR: https://github.com/freeipa/freeipa/pull/7555

Thanks!

Metadata Update from @abbra:
- Custom field on_review adjusted to https://github.com/freeipa/freeipa/pull/7555

master:

  • f3ec6ae8d000add0d2af648645d22191012541a4 Replace instances of del os.environ with os.environ.pop

ipa-4-12:

  • 6735327c18b99420816d31dd64ba402ff93031be Replace instances of del os.environ with os.environ.pop

Metadata Update from @rcritten:
- Issue close_status updated to: fixed
- Issue status updated to: Closed (was: Open)

Metadata