I would at least do the set/unset dance:
```python
old_logname = os.environ.get('LOGNAME')
os.environ['LOGNAME'] = 'pychefenv'
try:
    ...
finally::
    if old_logname is None:
        del os.environ['LOGNAME']
    else:
        os.environ['LOGNAME'] = old_logname
```