@@ -248,8 +248,8 @@ created list.
248248
249249 A list builder object.
250250
251- The API is **not thread safe **. To share a builder with multiple threads, a
252- critical section or a lock is needed.
251+ The API is **not thread safe **. To share a builder with multiple threads,
252+ external synchronization is needed.
253253
254254 The instance must be destroyed by :c:func: `PyListBuilder_Finish ` on
255255 success, or :c:func: `PyListBuilder_Discard ` on error.
@@ -293,8 +293,8 @@ created list.
293293
294294.. c :function :: int PyListBuilder_AppendSteal (PyListBuilder *builder, PyObject *item)
295295
296- Similar to :c:func: `PyListBuilder_Append `, but :term: ` steals <steal> ` the
297- reference to *item *, instead of creating a new :term: ` strong reference ` .
296+ Same as :c:func: `PyListBuilder_Append `, except this function
297+ :term: ` steals <steal> ` the reference to *item *.
298298
299299.. c :function :: int PyListBuilder_Extend (PyListBuilder *builder, PyObject *iterable)
300300
@@ -305,7 +305,9 @@ created list.
305305 On error, set an exception, leave the builder unchanged, and return ``-1 ``.
306306
307307 If consuming *iterable * raises an exception, the builder is restored to its
308- previous state: discard added items.
308+ previous state, that is, items added by a failed call are discarded.
309+ However, note that *iterable * is not reverted: items consumed from an
310+ iterator are not added back.
309311
310312.. c :function :: int PyListBuilder_ExtendArray (PyListBuilder *builder, PyObject *const *items, Py_ssize_t nitem)
311313
@@ -317,12 +319,15 @@ created list.
317319
318320 *nitem * must not be negative.
319321
320- If resizing the builder fails (memory allocation failure), the builder is
321- restored to its previous state: discard added items .
322+ On failure, the builder is restored to its previous state. That is, items
323+ added by a failed call are discarded from the builder .
322324
323325.. c :function :: int PyListBuilder_ExtendArraySteal (PyListBuilder *builder, PyObject *const *items, Py_ssize_t nitem)
324326
325- Similar to :c:func: `PyListBuilder_ExtendArray `, but :term: `steal ` references
326- instead of copying references .
327+ Same as :c:func: `PyListBuilder_ExtendArray `, but :term: `steal ` references
328+ instead of copying them .
327329
328- On error, all *items * references are also cleared.
330+ The caller must hold a strong reference to each item in *item *.
331+ Both on success and on error, these references are transferred to the builder;
332+ the caller must not use them after the call.
333+ (To clarify: on error, the references are "lost".)
0 commit comments