Zdeněk Pavlas added the comment: 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 >>> ---------- _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue17544> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com