Skip to content

Empty env variable raises KeyError #3

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
osantana opened this issue Aug 15, 2014 · 0 comments
Closed

Empty env variable raises KeyError #3

osantana opened this issue Aug 15, 2014 · 0 comments

Comments

@osantana
Copy link
Contributor

I've created a .env file with:

FOO=

... and when I try to get FOO decouple raises a KeyError exception:

$ cat .env
FOO=
BAR=1
>>> from decouple import config
>>> config("BAR")
'1'
>>> config("BAZ", "undefined")
'undefined'
>>> config("FOO", "undefined")
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "decouple.py", line 190, in __call__
    return self.config(*args, **kwargs)
  File "decouple.py", line 73, in __call__
    return self.get(*args, **kwargs)
  File "decouple.py", line 55, in get
    value = self.repository.get(option)
  File "decouple.py", line 123, in get
    return self.data.get(key) or os.environ[key]
  File "/home/osantana/.virtualenvs/opinious/lib/python2.7/UserDict.py", line 23, in __getitem__
    raise KeyError(key)
KeyError: 'FOO'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant