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

Propagate errors with context management #161

Closed
zshaheen opened this issue Aug 23, 2017 · 5 comments
Closed

Propagate errors with context management #161

zshaheen opened this issue Aug 23, 2017 · 5 comments
Assignees

Comments

@zshaheen
Copy link
Contributor

zshaheen commented Aug 23, 2017

At lines 1260 here, we should have something like this:

def __exit__(self, type, value, traceback):
    if type is None:
        self.close()
    else:
        return False

Returning False will propagate any exceptions raised by the with block below:

with cdms2.open('something.nc') as f:
    # this is the with block
@zshaheen
Copy link
Contributor Author

zshaheen commented Aug 23, 2017

@doutriaux1 @dnadeau4 thought?

@doutriaux1
Copy link
Contributor

doutriaux1 commented Aug 23, 2017

@zshaheen sounds right, do you mind submitting a PR?

dnadeau4 added a commit that referenced this issue Sep 22, 2017
@dnadeau4
Copy link
Contributor

dnadeau4 commented Sep 22, 2017

@zshaheen I put your code in and create a test for it. I tried to make it failed with and without your code and got the same error message. So I did not understand what it does more.

It is in my python3merge branch and all tests passed.

@doutriaux1
Copy link
Contributor

doutriaux1 commented Sep 25, 2017

@zshaheen can you provide a test for it please? Or a link to why this is important, @dnadeau4 and I can make a test from such a link as well.

@zshaheen
Copy link
Contributor Author

zshaheen commented Sep 25, 2017

@doutriaux1 Sure, I'll get to this this week.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants