summaryrefslogtreecommitdiffstats
path: root/Objects/listobject.c
diff options
context:
space:
mode:
Diffstat (limited to 'Objects/listobject.c')
-rw-r--r--Objects/listobject.c27
1 files changed, 17 insertions, 10 deletions
diff --git a/Objects/listobject.c b/Objects/listobject.c
index 1e885f9..56785e5 100644
--- a/Objects/listobject.c
+++ b/Objects/listobject.c
@@ -383,18 +383,11 @@ list_dealloc(PyObject *self)
}
static PyObject *
-list_repr(PyObject *self)
+list_repr_impl(PyListObject *v)
{
- PyListObject *v = (PyListObject *)self;
- Py_ssize_t i;
PyObject *s;
_PyUnicodeWriter writer;
-
- if (Py_SIZE(v) == 0) {
- return PyUnicode_FromString("[]");
- }
-
- i = Py_ReprEnter((PyObject*)v);
+ Py_ssize_t i = Py_ReprEnter((PyObject*)v);
if (i != 0) {
return i > 0 ? PyUnicode_FromString("[...]") : NULL;
}
@@ -439,10 +432,24 @@ error:
return NULL;
}
+static PyObject *
+list_repr(PyObject *self)
+{
+ if (PyList_GET_SIZE(self) == 0) {
+ return PyUnicode_FromString("[]");
+ }
+ PyListObject *v = (PyListObject *)self;
+ PyObject *ret = NULL;
+ Py_BEGIN_CRITICAL_SECTION(v);
+ ret = list_repr_impl(v);
+ Py_END_CRITICAL_SECTION();
+ return ret;
+}
+
static Py_ssize_t
list_length(PyObject *a)
{
- return Py_SIZE(a);
+ return PyList_GET_SIZE(a);
}
static int