[issue4606] Passing 'None' if argtype is set to POINTER(...) doesn't always result in NULL

Thomas Heller report at bugs.python.org
Thu Jul 30 21:14:56 CEST 2009


Thomas Heller <theller at ctypes.org> added the comment:

Thanks for bringing my attention to this problem again, and for the review.

Andrew McNabb schrieb:
> 
> I looked at the attached patch, and it seems to me the only alternative
> approach would be to use PyLong_FromLong instead of PyInt_FromLong. 

Using PyLong_FromLong doesn't make a difference at all, if you look into
the ConvParam code.

> However, since ConvParam already handles None appropriately, I think the
> fix in patch_ctypes_none_arg.diff really is the best way to do it.

The problem is that the patch changes the behaviour of the
'POINTER(...).from_param' methods, so I'm unsure if it can be applied
to 2.6 (or even 2.5).  Opinions?

> This patch is a one-line fix (plus tests and documentation), and it
> fixes a bug which crashes the interpreter.  The patch seems very

The patch is missing a 'Py_INCREF(value)' before the 'return value;',
but this is a minor point.

> straightforward, and there is no way that code could depend on the
> current behavior.

It could (on 32-bit systems), although I'm not sure if there is code
that does.

> I'm not sure if my patch review counts for much, but
> there you have it. :)

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue4606>
_______________________________________


More information about the Python-bugs-list mailing list