Author: Devin Jeanpierre <[email protected]>
Branch: cpyext-old-buffers
Changeset: r84499:4bb54e740ea9
Date: 2016-05-16 14:44 -0700
http://bitbucket.org/pypy/pypy/changeset/4bb54e740ea9/
Log: Test that we don't leak strings when taking a buffer view of them.
diff --git a/pypy/module/cpyext/test/test_bytesobject.py
b/pypy/module/cpyext/test/test_bytesobject.py
--- a/pypy/module/cpyext/test/test_bytesobject.py
+++ b/pypy/module/cpyext/test/test_bytesobject.py
@@ -397,12 +397,15 @@
lenp = lltype.malloc(Py_ssize_tP.TO, 1, flavor='raw')
w_text = space.wrap("text")
- assert api.PyObject_AsCharBuffer(w_text, bufp, lenp) == 0
+ ref = make_ref(space, w_text)
+ prev_refcnt = ref.c_ob_refcnt
+ assert api.PyObject_AsCharBuffer(ref, bufp, lenp) == 0
+ assert ref.c_ob_refcnt == prev_refcnt
assert lenp[0] == 4
assert rffi.charp2str(bufp[0]) == 'text'
-
lltype.free(bufp, flavor='raw')
lltype.free(lenp, flavor='raw')
+ api.Py_DecRef(ref)
def test_intern(self, space, api):
buf = rffi.str2charp("test")
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit