pypy/module/cpyext/test/test_getargs.py::AppTestGetargs::()::test_pyarg_parse_string_py_buffer
self = <pypy.interpreter.typedef.W_ObjectObjectUserDictWeakrefable object at 0x00007fa3faf9d948>
def test_pyarg_parse_string_py_buffer(self):
"""
The `s*` format specifier can be used to parse a str into a Py_buffer
structure containing a pointer to the string data and the length of the
string data.
"""
pybuffer = self.import_parser(
'''
Py_buffer buf;
PyObject *result;
if (!PyArg_ParseTuple(args, "s*", &buf)) {
return NULL;
}
result = PyBytes_FromStringAndSize(buf.buf, buf.len);
PyBuffer_Release(&buf);
return result;
''')
assert b'foo\0bar\0baz' == pybuffer(b'foo\0bar\0baz')
#return # XXX?
> assert b'foo\0bar\0baz' == pybuffer(bytearray(b'foo\0bar\0baz'))
E (application-level) ValueError: __release_buffer__ called with a buffer not obtained from this object
[/Users/matti/build-worker-x86_64/own-macos-x86-64/build/pypy/module/cpyext/test/test_getargs.py:108]:20: ValueError
---------- Captured stdout call ----------
Error in cpyext, CPython compatibility layer:
The function cpyext_bf_releasebuffer_bytearray was not supposed to fail
Fatal error in cpyext, CPython compatibility layer, calling cpyext_bf_releasebuffer_bytearray
Either report a bug or consider not using this particular extension
---------- Captured stderr call ----------
<function PyModule_Create2 at 0x00007fa3fa009b50> DONE
<function PySequence_Fast_ITEMS at 0x00007fa3fa83e5c0> DONE
<function bytes_getbuffer at 0x00007fa3fa3d7100> DONE
<function PyBuffer_IsContiguous at 0x00007fa3fa1e36a0> DONE
<function PyBytes_FromStringAndSize at 0x00007fa41a413970> DONE
<function PySequence_Fast_ITEMS at 0x00007fa3fa83e5c0> DONE
<function cpyext_bf_getbuffer_bytearray at 0x00007fa3f9b00bd8> DONE
<function PyBuffer_IsContiguous at 0x00007fa3fa1e36a0> DONE
<function PyBytes_FromStringAndSize at 0x00007fa41a413970> DONE
<function cpyext_bf_releasebuffer_bytearray at 0x00007fa3f9b00cc8>Traceback (most recent call last):
File "/Users/matti/build-worker-x86_64/own-macos-x86-64/build/pypy/module/cpyext/api.py", line 1164, in wrapper_second_level
raise not_supposed_to_fail(pname)
File "/Users/matti/build-worker-x86_64/own-macos-x86-64/build/pypy/module/cpyext/api.py", line 1018, in not_supposed_to_fail
raise SystemError
SystemError
File "/Users/matti/oss/pypy-x86_64-buildbot/lib_pypy/_ctypes/function.py", line 283, in f
return to_call(*args)
File "/Users/matti/build-worker-x86_64/own-macos-x86-64/build/rpython/rtyper/lltypesystem/ll2ctypes.py", line 895, in callback
return callback_internal(*cargs)
File "/Users/matti/build-worker-x86_64/own-macos-x86-64/build/rpython/rtyper/lltypesystem/ll2ctypes.py", line 872, in callback_internal
llres = container._callable(*llargs)
File "/Users/matti/build-worker-x86_64/own-macos-x86-64/build/pypy/module/cpyext/api.py", line 990, in wrapper
return wrapper_second_level(callable, pname, *args)
File "/Users/matti/build-worker-x86_64/own-macos-x86-64/build/pypy/module/cpyext/api.py", line 1186, in wrapper_second_level
state.check_and_raise_exception(always=True)
File "/Users/matti/build-worker-x86_64/own-macos-x86-64/build/pypy/module/cpyext/state.py", line 79, in check_and_raise_exception
raise operror
OpErrFmtNoArgs: [<W_TypeObject 'ValueError' at 0x7fa401cbd7c0>: W_BaseExceptionUserWeakrefable([W_UnicodeObject('__release_buffer__ called with a buffer not obtained from this object')])]
builder: own-macos-x86-64 build #1335+
test: pypy/module/cpyext/test/test_getargs.py::AppTestGetargs::()::test_pyarg_parse_string_py_buffer