Skip to content
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

tools.environment_append raises if tries to unset variable which was never set #4323

Closed
3 tasks
SSE4 opened this issue Jan 16, 2019 · 0 comments · Fixed by #4324
Closed
3 tasks

tools.environment_append raises if tries to unset variable which was never set #4323

SSE4 opened this issue Jan 16, 2019 · 0 comments · Fixed by #4324
Assignees
Milestone

Comments

@SSE4
Copy link
Contributor

SSE4 commented Jan 16, 2019

after #4224, I may use the following code, for instance, to ensure variable is not set:

with environment_append({'CONAN_BASH_PATH': None}):
    pass

however, it raises if CONAN_BASH_PATH is not set (prior to the environment_append invocation):

Traceback (most recent call last):
  File "C:\bincrafters\conan\conans\test\unittests\client\tools\os_info\osinfo_test.py", line 39, in test_windows
    with environment_append(new_env):
  File "c:\users\sse4\appdata\local\programs\python\python36\lib\contextlib.py", line 81, in __enter__
    return next(self.gen)
  File "C:\bincrafters\conan\conans\client\tools\env.py", line 57, in environment_append
    os.environ.pop(var)
  File "c:\users\sse4\appdata\local\programs\python\python36\lib\_collections_abc.py", line 795, in pop
    value = self[key]
  File "c:\users\sse4\appdata\local\programs\python\python36\lib\os.py", line 669, in __getitem__
    raise KeyError(key) from None
KeyError: 'CONAN_BASH_PATH'

I would expect tools.environment_append to be no op in such case, otherwise, it requires additional logic to workaround this behavior.

To help us debug your issue please explain:

  • I've read the CONTRIBUTING guide.
  • I've specified the Conan version, operating system version and any tool that can be relevant.
  • I've explained the steps to reproduce the error or the motivation/use case of the question/suggestion.
@ghost ghost assigned SSE4 Jan 16, 2019
@ghost ghost added the stage: review label Jan 16, 2019
@SSE4 SSE4 changed the title tools.environment_append raises if tries to unset variables which was never set tools.environment_append raises if tries to unset variable which was never set Jan 16, 2019
@lasote lasote added this to the 1.12 milestone Jan 17, 2019
@ghost ghost removed the stage: review label Jan 17, 2019
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

Successfully merging a pull request may close this issue.

2 participants