Skip to content

Move PyPredict custom exception definition to predict.c#6

Merged
jtrutna merged 2 commits into
masterfrom
cexception2
Dec 29, 2014
Merged

Move PyPredict custom exception definition to predict.c#6
jtrutna merged 2 commits into
masterfrom
cexception2

Conversation

@jtrutna
Copy link
Copy Markdown
Contributor

@jtrutna jtrutna commented Dec 18, 2014

Also added exceptions on failure cases in C code.

@mconst-nanosatisfi

Comment thread predict.c Outdated
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems a little weird to call this exception class "PredictException" in Python but "Exception" in C. Would it make more sense to use PredictException everywhere? That way it'll be clear what your PyErr_SetString calls are doing.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm trying to remember why I did it this way - I had them as PredictException's before and changed it. Line length issues ?:-/

It would be prettier to have them as predict.Exception, but I get the feeling that's frowned upon.

Anyway, fixing.

@mconst-spire
Copy link
Copy Markdown

Okay, other than the comments above (which are all minor), this looks good to me.

+ Rename 'Exception' to more desriptive 'PredictException'
+ Fixed reference count bug on PyObject * transit
+ Use likely more descriptive python error messages in List append failure
+ Handle case where PythonifyObservation fails to build value
@jtrutna
Copy link
Copy Markdown
Contributor Author

jtrutna commented Dec 19, 2014

Comments addressed. Could you take a quick look at the quick_predict function and make sure there aren't any lurking bugs with my use of a local goto?

@mconst-spire
Copy link
Copy Markdown

Cool, this looks good to me. (In theory I think you're also supposed to free your new py_obs reference if the subsequent PyList_Append fails, but I can't imagine that ever being a problem in practice -- it's a tiny memory leak, and it'll only happen if you're already out of memory for other reasons. Manual memory management sucks.)

jtrutna added a commit that referenced this pull request Dec 29, 2014
Move PyPredict custom exception definition to predict.c
@jtrutna jtrutna merged commit d6d381e into master Dec 29, 2014
@jerematt jerematt deleted the cexception2 branch February 1, 2022 17:35
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 this pull request may close these issues.

2 participants