Issue #6697: Check that _PyUnicode_AsString() result is not NULL in _sqlite

Strip also some trailing spaces
diff --git a/Modules/_sqlite/statement.c b/Modules/_sqlite/statement.c
index 48e039b..c040290 100644
--- a/Modules/_sqlite/statement.c
+++ b/Modules/_sqlite/statement.c
@@ -130,7 +130,10 @@
             break;
         case TYPE_UNICODE:
             string = _PyUnicode_AsString(parameter);
-            rc = sqlite3_bind_text(self->st, pos, string, -1, SQLITE_TRANSIENT);
+            if (string != NULL)
+                rc = sqlite3_bind_text(self->st, pos, string, -1, SQLITE_TRANSIENT);
+            else
+                rc = -1;
             break;
         case TYPE_BUFFER:
             if (PyObject_AsCharBuffer(parameter, &buffer, &buflen) == 0) {