make _tkinter._flatten check the result of PySequence_Size for errors #3880
diff --git a/Modules/_tkinter.c b/Modules/_tkinter.c
index 93e7edc..6e89f2f 100644
--- a/Modules/_tkinter.c
+++ b/Modules/_tkinter.c
@@ -2908,7 +2908,9 @@
 		return NULL;
 
 	context.maxsize = PySequence_Size(item);
-	if (context.maxsize <= 0)
+	if (context.maxsize < 0)
+		return NULL;
+	if (context.maxsize == 0)
 		return PyTuple_New(0);
 	
 	context.tuple = PyTuple_New(context.maxsize);