It will always be a string, because it is created just before this call.
diff --git a/Modules/socketmodule.c b/Modules/socketmodule.c
index 525a19e..0917a31 100644
--- a/Modules/socketmodule.c
+++ b/Modules/socketmodule.c
@@ -1471,7 +1471,7 @@
 	if (buf == NULL)
 		return NULL;
 	Py_BEGIN_ALLOW_THREADS
-	n = recv(s->sock_fd, PyString_AsString(buf), len, flags);
+	n = recv(s->sock_fd, PyString_AS_STRING(buf), len, flags);
 	Py_END_ALLOW_THREADS
 	if (n < 0) {
 		Py_DECREF(buf);