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

cdtime issue exception that seem to have no base class (python2 maybe 3) #10

Closed
doutriaux1 opened this Issue Nov 15, 2017 · 5 comments

Comments

Projects
None yet
2 participants
@doutriaux1
Member

doutriaux1 commented Nov 15, 2017

In python 2 for sure, didn't test in python3

import cdtime
try:
   b = cdtime.reltime(4,"days since YYY-XX))")
except:
    print "Failed"

catches the exception properly

BUT

import cdtime
try:
   b = cdtime.reltime(4,"days since YYY-XX))")
except Exception:
    print "Failed"

does not capture the exception

I "think" this is because the exception is raised at the C level and does not inherit from Exception.

This is not a big deal once you know it, but flake8 will complain that you cannot use an except statement w/o an Exception type

@doutriaux1 doutriaux1 added this to the 3.0 milestone Nov 15, 2017

@doutriaux1 doutriaux1 added the bug label Nov 15, 2017

@dnadeau4

This comment has been minimized.

Contributor

dnadeau4 commented Nov 15, 2017

Does not work in python 2 either.
There is no exception triggered. The results is wrong.
https://github.com/UV-CDAT/libcdms/blob/master/src/db_util/cdTimeConv.c#L299-L302

@dnadeau4 dnadeau4 closed this Nov 15, 2017

@doutriaux1

This comment has been minimized.

Member

doutriaux1 commented Nov 15, 2017

In vcs and python 2 had to leave it at except alone and it works, except Exception fails

@doutriaux1 doutriaux1 reopened this Nov 15, 2017

@doutriaux1

This comment has been minimized.

Member

doutriaux1 commented Nov 15, 2017

It is not urgent still there is a work around, but I would like to figure out the correct way to raise exceptions from C

@dnadeau4

This comment has been minimized.

Contributor

dnadeau4 commented Nov 15, 2017

I forgot to check in libcdms. will push now. We will need conda-forge to update it.

@dnadeau4 dnadeau4 closed this Nov 15, 2017

@dnadeau4

This comment has been minimized.

Contributor

dnadeau4 commented Nov 15, 2017

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