This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author Zdeněk.Pavlas
Recipients Zdeněk.Pavlas, ezio.melotti, mrabarnett
Date 2013-03-25.19:40:28
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1364240428.83.0.173722774199.issue17544@psf.upfronthosting.co.za>
In-reply-to
Content
static PyObject*
foo(PyObject *, PyObject *arg)
{
    void *buf;
    Py_ssize_t size;
    if (PyObject_AsReadBuffer(arg, &buf, &size))
        size = -1;
    return PyInt_FromLong(size);
}

>>> import tst, re
>>> re.search("a", "a")
<_sre.SRE_Match object at 0xb76d0950>
>>> tst.foo("abc")
3
>>> re.search("a", "a")
<_sre.SRE_Match object at 0xb76d0950>
>>> tst.foo(None)
-1
>>> re.search("a", "a")
TypeError: expected a readable buffer object
>>>
History
Date User Action Args
2013-03-25 19:40:28Zdeněk.Pavlassetrecipients: + Zdeněk.Pavlas, ezio.melotti, mrabarnett
2013-03-25 19:40:28Zdeněk.Pavlassetmessageid: <1364240428.83.0.173722774199.issue17544@psf.upfronthosting.co.za>
2013-03-25 19:40:28Zdeněk.Pavlaslinkissue17544 messages
2013-03-25 19:40:28Zdeněk.Pavlascreate