Author: Armin Rigo <[email protected]>
Branch:
Changeset: r97025:2315521d2c5d
Date: 2019-07-25 14:07 +0200
http://bitbucket.org/pypy/pypy/changeset/2315521d2c5d/
Log: Fix for 19e211d4c76b (oops, sorry)
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
@@ -1365,12 +1365,11 @@
class scoped_nonmoving_unicodebuffer:
def __init__(self, data):
- self.data = data
+ self.buf, self.llobj, self.flag = get_nonmoving_unicodebuffer_ll(data)
def __enter__(self):
- self.buf, self.flag = get_nonmoving_unicodebuffer(self.data)
return self.buf
def __exit__(self, *args):
- free_nonmoving_unicodebuffer(self.data, self.buf, self.flag)
+ free_nonmoving_unicodebuffer_ll(self.buf, self.llobj, self.flag)
__init__._always_inline_ = 'try'
__enter__._always_inline_ = 'try'
__exit__._always_inline_ = 'try'
diff --git a/rpython/rtyper/lltypesystem/test/test_rffi.py
b/rpython/rtyper/lltypesystem/test/test_rffi.py
--- a/rpython/rtyper/lltypesystem/test/test_rffi.py
+++ b/rpython/rtyper/lltypesystem/test/test_rffi.py
@@ -917,6 +917,15 @@
assert buf[2] == 'r'
assert buf[3] == '\x00'
+def test_scoped_nonmoving_unicodebuffer():
+ s = u'bar'
+ with scoped_nonmoving_unicodebuffer(s) as buf:
+ assert buf[0] == u'b'
+ assert buf[1] == u'a'
+ assert buf[2] == u'r'
+ with py.test.raises(IndexError):
+ buf[3]
+
def test_wcharp2utf8n():
w = 'hello\x00\x00\x00\x00'
u, i = wcharp2utf8n(w, len(w))
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit