[issue44264] Add descriptive error message when environment variable not detected

Irit Katriel report at bugs.python.org
Sat Jan 29 19:23:04 EST 2022


Irit Katriel <iritkatriel at gmail.com> added the comment:

It's not necessarily true that the environment variable is not set just because the key is not in os.environ. In this example my del did not change the environment variable:

>>> import os
>>> os.environ['TMPDIR']
'/var/folders/kf/0v7kz3ps62dg11v9rq0sz35m0000gn/T/'
>>> del os.environ['TMPDIR']
>>> os.environ['TMPDIR']
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "<frozen os>", line 678, in __getitem__
KeyError: 'TMPDIR'

----------
nosy: +iritkatriel

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue44264>
_______________________________________


More information about the Python-bugs-list mailing list