Author: Armin Rigo <[email protected]>
Branch:
Changeset: r74376:a6902fd7e9a7
Date: 2014-11-07 17:40 +0100
http://bitbucket.org/pypy/pypy/changeset/a6902fd7e9a7/
Log: Issue 1914: test and fix
diff --git a/rpython/jit/metainterp/test/test_rawmem.py
b/rpython/jit/metainterp/test/test_rawmem.py
--- a/rpython/jit/metainterp/test/test_rawmem.py
+++ b/rpython/jit/metainterp/test/test_rawmem.py
@@ -89,6 +89,16 @@
'finish': 1})
self.metainterp.staticdata.stats.check_resops({'finish': 1},
omit_finish=False)
+ def test_scoped_alloc_buffer(self):
+ def f():
+ with rffi.scoped_alloc_buffer(42) as p:
+ p.raw[0] = 'X'
+ s = p.str(1)
+ return ord(s[0])
+
+ res = self.interp_operations(f, [])
+ assert res == ord('X')
+
class TestRawMem(RawMemTests, LLJitMixin):
diff --git a/rpython/rtyper/lltypesystem/rffi.py
b/rpython/rtyper/lltypesystem/rffi.py
--- a/rpython/rtyper/lltypesystem/rffi.py
+++ b/rpython/rtyper/lltypesystem/rffi.py
@@ -822,6 +822,8 @@
free_nonmovingbuffer._annenforceargs_ = [strtype, None, bool, bool]
# int -> (char*, str, int)
+ # Can't inline this because of the raw address manipulation.
+ @jit.dont_look_inside
def alloc_buffer(count):
"""
Returns a (raw_buffer, gc_buffer, case_num) triple,
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit