On Windows, tempnam() is spelled with a leading underscore.
diff --git a/Modules/posixmodule.c b/Modules/posixmodule.c
index aec8caa..f17b95a 100644
--- a/Modules/posixmodule.c
+++ b/Modules/posixmodule.c
@@ -4211,7 +4211,11 @@
 
     if (!PyArg_ParseTuple(args, "|zz:tempnam", &dir, &pfx))
         return NULL;
+#ifdef MS_WIN32
+    name = _tempnam(dir, pfx);
+#else
     name = tempnam(dir, pfx);
+#endif
     if (name == NULL)
         return PyErr_NoMemory();
     result = PyString_FromString(name);