[pypy-commit] pypy rw-PyString_AS_STRING: only use AS_STRING for non-interned access
mattip
pypy.commits at gmail.com
Tue Jun 14 18:09:33 EDT 2016
Author: Matti Picus <matti.picus at gmail.com>
Branch: rw-PyString_AS_STRING
Changeset: r85173:ed79f1e7c24f
Date: 2016-06-15 00:48 +0300
http://bitbucket.org/pypy/pypy/changeset/ed79f1e7c24f/
Log: only use AS_STRING for non-interned access
diff --git a/pypy/module/cpyext/src/stringobject.c b/pypy/module/cpyext/src/stringobject.c
--- a/pypy/module/cpyext/src/stringobject.c
+++ b/pypy/module/cpyext/src/stringobject.c
@@ -107,7 +107,7 @@
if (!string)
return NULL;
- s = PyString_AsString(string);
+ s = PyString_AS_STRING(string);
for (f = format; *f; f++) {
if (*f == '%') {
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
@@ -80,7 +80,7 @@
if (t == NULL)
return NULL;
Py_DECREF(t);
- c = PyString_AsString(s);
+ c = PyString_AS_STRING(s);
c[0] = 'a';
c[1] = 'b';
c[2] = 0;
@@ -445,22 +445,22 @@
def test_string_resize(self, space, api):
py_str = new_empty_str(space, 10)
ar = lltype.malloc(PyObjectP.TO, 1, flavor='raw')
- py_str.c_buffer[0] = 'a'
- py_str.c_buffer[1] = 'b'
- py_str.c_buffer[2] = 'c'
+ py_str.c_sval[0] = 'a'
+ py_str.c_sval[1] = 'b'
+ py_str.c_sval[2] = 'c'
ar[0] = rffi.cast(PyObject, py_str)
api._PyString_Resize(ar, 3)
py_str = rffi.cast(PyStringObject, ar[0])
assert py_str.c_ob_size == 3
- assert py_str.c_buffer[1] == 'b'
- assert py_str.c_buffer[3] == '\x00'
+ assert py_str.c_sval[1] == 'b'
+ assert py_str.c_sval[3] == '\x00'
# the same for growing
ar[0] = rffi.cast(PyObject, py_str)
api._PyString_Resize(ar, 10)
py_str = rffi.cast(PyStringObject, ar[0])
assert py_str.c_ob_size == 10
- assert py_str.c_buffer[1] == 'b'
- assert py_str.c_buffer[10] == '\x00'
+ assert py_str.c_sval[1] == 'b'
+ assert py_str.c_sval[10] == '\x00'
Py_DecRef(space, ar[0])
lltype.free(ar, flavor='raw')
More information about the pypy-commit
mailing list