Andrew Straw wrote:
> Robert Bradshaw wrote:
> OK, so there'd be part of the Cython compiler that checked if the name 
> of the current method was "__getbuffer__" and if the class was an 
> extension ctypedef, upon which it would insert some check before the 
> method returned? I don't know the internals of Cython enough to know 
> whether that would be a gratuitous hack or reasonable behavior... But if 
> you point me in the right direction, I'll have a look.

This just got a lot easier in the latest cython-devel to do if you want 
to have a shot.

If you look around line 1065 in Cython/Compiler/Nodes.py 
(FuncDefNode.getbuffer_X) you can see special functions which are called 
to insert code only if we're dealing with __getbuffer__. You could 
insert code to check if buf is non-NULL in the normal_cleanup case. If 
you need auxiliary code for the exception you can call 
code.globalscope.use_utility_code (see how it is done elsewhere).

-- 
Dag Sverre
_______________________________________________
Cython-dev mailing list
[email protected]
http://codespeak.net/mailman/listinfo/cython-dev

Reply via email to