"James Reynolds" <eire1...@gmail.com> wrote


As far as the null point goes, it shouldn't be null at all once it gets to the point Alan pointed out. The pointer is set in (for example) stat_avg

   seq = PySequence_Fast(obj, "Expected a Sequence");

Can the function fail? If so what does it return? That was
my point. Can seq ever still be NULL after the function call?
For example if the function is allocating memory it could fail
to grab enough and then return a NULL....

But it depends on how reliable the Python function is in
its return value...

But maybe I am missing something that you have seen?

Don't rely on functio  returns being valid values.
It is common practice in industrial strength C to return a NULL
and expect the user to check. Manyb of the standard library
functions work that way too.

So you often see code like

if (foo = someFunction() ){ // notice it is an assignment not equality test
     process(foo);
}

HTH,

--
Alan Gauld
Author of the Learn to Program web site
http://www.alan-g.me.uk/


_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor

Reply via email to