| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Sorry, something went wrong.
Make sure that a writer can be modified before writing into it. On Free Threading, _PyUnicodeWriter_CanWrite() fails if called from a thread other than the one which created the writer. Document that PyUnicodeWriter is not thread safe. Add also singletons tests to test_capi.test_unicode.
Documentation build overview1 file changed ± c-api/unicode.html |
Sorry, something went wrong.
|
Oh, on Free Threading, PyUnicodeWriter_CanWrite() assertion fails in TestCSV.test_concurrent_writer_writerow() of test_free_threading.test_csv: ../cpython-ro-srcdir/Objects/unicode_writer.c:354: _PyUnicodeWriter_WriteStr: Assertion `_PyUnicodeWriter_CanWrite(writer)' failed. Code: def test_concurrent_writer_writerow(self):
output_stream = io.StringIO()
writer = csv.writer(output_stream)
row_per_thread = 10
expected_rows = []
def write_row():
for i in range(row_per_thread):
writer.writerow([i, i, i])
expected_rows.append(f"{i},{i},{i}")
run_concurrently(worker_func=write_row, nthreads=NTHREADS)
# Rewind to the start of the stream and parse the rows
output_stream.seek(0)
output_rows = [line.strip() for line in output_stream.readlines()]
self.assertEqual(len(output_rows), NTHREADS * row_per_thread)
self.assertListEqual(sorted(output_rows), sorted(expected_rows))csv is implemented with io.StringIO which uses PyUnicodeWriter but uses a critical section to make sure that the PyUnicodeWriter is not used by two threads at the same time. |
Sorry, something went wrong.
Check PyUnicode_CheckExact() earlier in _PyUnicode_IsModifiable().
|
I pushed a fix for test_free_threading: do not check _PyObject_IsUniquelyReferenced() in _PyUnicodeWriter_CanWrite(). It's ok to use PyUnicodeWriter from different threads, since the caller can have its own lock, as io.StringIO does. |
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
Make sure that a writer can be modified before writing into it. On Free Threading, _PyUnicodeWriter_CanWrite() fails if called from a thread other than the one which created the writer.
Document that PyUnicodeWriter is not thread safe.
Add also singletons tests to test_capi.test_unicode.