Added some additional checks for sys.std?? is None, see #1440
diff --git a/Modules/_ctypes/callbacks.c b/Modules/_ctypes/callbacks.c
index 9f5e5d0..9e1aa4f 100644
--- a/Modules/_ctypes/callbacks.c
+++ b/Modules/_ctypes/callbacks.c
@@ -17,7 +17,7 @@
 	va_start(marker, msg);
 	vsnprintf(buf, sizeof(buf), msg, marker);
 	va_end(marker);
-	if (f)
+	if (f != NULL && f != Py_None)
 		PyFile_WriteString(buf, f);
 	PyErr_Print();
 }
diff --git a/Modules/_cursesmodule.c b/Modules/_cursesmodule.c
index cf412d8..3a88360 100644
--- a/Modules/_cursesmodule.c
+++ b/Modules/_cursesmodule.c
@@ -2010,7 +2010,7 @@
 
 		sys_stdout = PySys_GetObject("stdout");
 
-		if (sys_stdout == NULL) {
+		if (sys_stdout == NULL || sys_stdout == Py_None) {
 			PyErr_SetString(
 				PyCursesError,
 				"lost sys.stdout");
diff --git a/Modules/threadmodule.c b/Modules/threadmodule.c
index 62ea660..876d5e2 100644
--- a/Modules/threadmodule.c
+++ b/Modules/threadmodule.c
@@ -429,7 +429,7 @@
 			PySys_WriteStderr(
 				"Unhandled exception in thread started by ");
 			file = PySys_GetObject("stderr");
-			if (file)
+			if (file != NULL && file != Py_None)
 				PyFile_WriteObject(boot->func, file, 0);
 			else
 				PyObject_Print(boot->func, stderr, 0);