Issue #16013: Fix CSV Reader parsing issue with ending quote characters. Patch by Serhiy Storchaka.
diff --git a/Modules/_csv.c b/Modules/_csv.c
index 6c564d7..88d4f97 100644
--- a/Modules/_csv.c
+++ b/Modules/_csv.c
@@ -759,9 +759,13 @@
         lineobj = PyIter_Next(self->input_iter);
         if (lineobj == NULL) {
             /* End of input OR exception */
-            if (!PyErr_Occurred() && self->field_len != 0)
-                PyErr_Format(error_obj,
-                             "newline inside string");
+            if (!PyErr_Occurred() && (self->field_len != 0 ||
+                                      self->state == IN_QUOTED_FIELD)) {
+                if (self->dialect->strict)
+                    PyErr_SetString(error_obj, "unexpected end of data");
+                else if (parse_save_field(self) >= 0)
+                    break;
+            }
             return NULL;
         }
         if (!PyUnicode_Check(lineobj)) {