Issue #1950: Fixed misusage of PyUnicode_AsString().
diff --git a/Modules/datetimemodule.c b/Modules/datetimemodule.c
index 711adba..e64b230 100644
--- a/Modules/datetimemodule.c
+++ b/Modules/datetimemodule.c
@@ -1217,10 +1217,9 @@
 	assert(object && format && timetuple);
 	assert(PyUnicode_Check(format));
 	/* Convert the input format to a C string and size */
-	pin = PyUnicode_AsString(format);
+	pin = PyUnicode_AsStringAndSize(format, &flen);
 	if (!pin)
 		return NULL;
-	flen = PyUnicode_GetSize(format);
 
 	/* Give up if the year is before 1900.
 	 * Python strftime() plays games with the year, and different