diff Python/sysmodule.c @ 25666:4a825b902310 legacy-trunk

Add os.path.supports_unicode_filenames for all platforms, sys.getwindowsversion() on Windows (new enahanced Tim-proof <wink> version), and fix test_pep277.py in a few minor ways. Including doc and NEWS entries.
author Mark Hammond <mhammond@skippinet.com.au>
date Tue, 08 Oct 2002 02:44:31 +0000
parents 3a26e352f0a6
children 585a6460f577
line wrap: on
line diff
--- a/Python/sysmodule.c	Mon Oct 07 19:01:07 2002 +0000
+++ b/Python/sysmodule.c	Tue Oct 08 02:44:31 2002 +0000
@@ -20,6 +20,11 @@
 
 #include "osdefs.h"
 
+#ifdef MS_WINDOWS
+#define WIN32_LEAN_AND_MEAN
+#include "windows.h"
+#endif /* MS_WINDOWS */
+
 #ifdef MS_COREDLL
 extern void *PyWin_DLLhModule;
 /* A string loaded from the DLL at startup: */
@@ -404,6 +409,34 @@
 recursion from causing an overflow of the C stack and crashing Python."
 );
 
+#ifdef MS_WINDOWS
+PyDoc_STRVAR(getwindowsversion_doc,
+"getwindowsversion()\n\
+\n\
+Return information about the running version of Windows.\n\
+The result is a tuple of (major, minor, build, platform, text)\n\
+All elements are numbers, except text which is a string.\n\
+Platform may be 0 for win32s, 1 for Windows 9x/ME, 2 for Windows NT/2000/XP\n\
+"
+);
+
+static PyObject *
+sys_getwindowsversion(PyObject *self)
+{
+	OSVERSIONINFO ver;
+	ver.dwOSVersionInfoSize = sizeof(ver);
+	if (!GetVersionEx(&ver))
+		return PyErr_SetFromWindowsErr(0);
+	return Py_BuildValue("HHHHs",
+	                     ver.dwMajorVersion,
+	                     ver.dwMinorVersion,
+	                     ver.dwBuildNumber,
+	                     ver.dwPlatformId,
+	                     ver.szCSDVersion);
+}
+
+#endif /* MS_WINDOWS */
+
 #ifdef HAVE_DLOPEN
 static PyObject *
 sys_setdlopenflags(PyObject *self, PyObject *args)
@@ -570,6 +603,10 @@
 	{"getrecursionlimit", (PyCFunction)sys_getrecursionlimit, METH_NOARGS,
 	 getrecursionlimit_doc},
 	{"_getframe", sys_getframe, METH_VARARGS, getframe_doc},
+#ifdef MS_WINDOWS
+	{"getwindowsversion", (PyCFunction)sys_getwindowsversion, METH_NOARGS,
+	 getwindowsversion_doc},
+#endif /* MS_WINDOWS */
 #ifdef USE_MALLOPT
 	{"mdebug",	sys_mdebug, METH_VARARGS},
 #endif