[issue3639] segfaults calling warnings.warn() with non-string message

Brett Cannon report at bugs.python.org
Fri Aug 22 20:08:46 CEST 2008


Brett Cannon <brett at python.org> added the comment:

On Fri, Aug 22, 2008 at 8:03 AM, Daniel Diniz <report at bugs.python.org> wrote:
>
> Daniel Diniz <ajaksu at gmail.com> added the comment:
>
> Brett,
> I don't think I know C (and CPython) enough to fix this. I was able to
> get rid of this specific segfault with this:
>
> -            const char *text_char = _PyUnicode_AsString(text);
> +            const char *text_char =
> _PyUnicode_AsString(PyObject_Str(text));
>
> But I have no idea whether I should also incref/decref the PyObject_Str.
>

That's along the lines of what needs to be done (and what I was
planning on doing), although you need to do more error checking on the
return values. Plus the patch I am cooking up adds more checks in the
code for the return value of _PyUnicode_AsString().

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


More information about the Python-bugs-list mailing list