You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When using the following code, the private variable self._prefix is not cleared on errors:
with env.prefixed(PREFIX):
do_something()
If do_something() raises an error, then session attempts to run with env.prefixed() again it will behave like it is a nested with. This can happen in an interactive shell or if exceptions are caught.
Details
You can do the following to reproduce.
$ export PREFIX_PNG="path/to/my.png"
$ ipython
/usr/local/Cellar/ipython/7.5.0/libexec/lib/python3.7/site-packages/IPython/core/interactiveshell.py:925: UserWarning: Attempting to work in a virtualenv. If you encounter problems, please install IPython inside the virtualenv.
warn("Attempting to work in a virtualenv. If you encounter problems, please "
Python 3.7.3 (default, Mar 27 2019, 09:23:15)
Type 'copyright', 'credits' or 'license' for more information
IPython 7.5.0 -- An enhanced Interactive Python. Type '?' for help.
In [1]: from environs import Env
In [2]: env = Env()
In [3]: with env.prefixed("PREFIX_"):
...: print(env.str("PNG"))
...:
path/to/my.png
In [4]: with env.prefixed("PREFIX_"):
...: raise
...:
---------------------------------------------------------------------------
RuntimeError Traceback (most recent call last)
<ipython-input-4-6c7273e50e26> in <module>
1 with env.prefixed("PREFIX_"):
----> 2 raise
3
RuntimeError: No active exception to reraise
In [5]: with env.prefixed("PREFIX_"):
...: print(env.str("PNG"))
...:
---------------------------------------------------------------------------
EnvError Traceback (most recent call last)
<ipython-input-5-60d974fcda59> in <module>
1 with env.prefixed("PREFIX_"):
----> 2 print(env.str("PNG"))
3
~/dev/virtualenvs/tmp-da5b0d36b01c294/lib/python3.7/site-packages/environs.py in method(self, name, default, subcast, **kwargs)
51 if raw_value is ma.missing and field.missing is ma.missing:
52 raise EnvError(
---> 53 'Environment variable "{}" not set'.format(proxied_key or parsed_key)
54 )
55 if raw_value or raw_value == "":
EnvError: Environment variable "PREFIX_PREFIX_PNG" not set
The text was updated successfully, but these errors were encountered:
version:
4.1.3
Problem
When using the following code, the private variable
self._prefix
is not cleared on errors:If
do_something()
raises an error, then session attempts to runwith env.prefixed()
again it will behave like it is a nestedwith
. This can happen in an interactive shell or if exceptions are caught.Details
You can do the following to reproduce.
The text was updated successfully, but these errors were encountered: