[Python-checkins] r68541 - in python/branches/py3k: Misc/NEWS Python/sysmodule.c

martin.v.loewis python-checkins at python.org
Mon Jan 12 08:59:10 CET 2009


Author: martin.v.loewis
Date: Mon Jan 12 08:59:10 2009
New Revision: 68541

Log:
Merged revisions 68540 via svnmerge from 
svn+ssh://pythondev@svn.python.org/python/trunk

........
  r68540 | martin.v.loewis | 2009-01-12 08:57:11 +0100 (Mo, 12 Jan 2009) | 2 lines
  
  Issue #4915: Port sysmodule to Windows CE.
........


Modified:
   python/branches/py3k/   (props changed)
   python/branches/py3k/Misc/NEWS
   python/branches/py3k/Python/sysmodule.c

Modified: python/branches/py3k/Misc/NEWS
==============================================================================
--- python/branches/py3k/Misc/NEWS	(original)
+++ python/branches/py3k/Misc/NEWS	Mon Jan 12 08:59:10 2009
@@ -12,6 +12,8 @@
 Core and Builtins
 -----------------
 
+- Issue #4915: Port sysmodule to Windows CE.
+
 - Issue #4868: utf-8, utf-16 and latin1 decoding are now 2x to 4x faster. The
   common cases are optimized thanks to a dedicated fast path and a moderate
   amount of loop unrolling.

Modified: python/branches/py3k/Python/sysmodule.c
==============================================================================
--- python/branches/py3k/Python/sysmodule.c	(original)
+++ python/branches/py3k/Python/sysmodule.c	Mon Jan 12 08:59:10 2009
@@ -1257,8 +1257,13 @@
 		PyDict_SetItemString(sysdict, key, v);	\
 	Py_XDECREF(v)
 
+	/* Check that stdin is not a directory
+	Using shell redirection, you can redirect stdin to a directory,
+	crashing the Python interpreter. Catch this common mistake here
+	and output a useful error message. Note that under MS Windows,
+	the shell already prevents that. */
+#if !defined(MS_WINDOWS)
 	{
-		/* XXX: does this work on Win/Win64? (see posix_fstat) */
 		struct stat sb;
 		if (fstat(fileno(stdin), &sb) == 0 &&
 		    S_ISDIR(sb.st_mode)) {
@@ -1268,6 +1273,7 @@
 			exit(EXIT_FAILURE);
 		}
 	}
+#endif
 
         /* stdin/stdout/stderr are now set by pythonrun.c */
 
@@ -1483,7 +1489,7 @@
 {
 #if defined(HAVE_REALPATH)
 	wchar_t fullpath[MAXPATHLEN];
-#elif defined(MS_WINDOWS)
+#elif defined(MS_WINDOWS) && !defined(MS_WINCE)
 	wchar_t fullpath[MAX_PATH];
 #endif
 	PyObject *av = makeargvobject(argc, argv);
@@ -1529,7 +1535,10 @@
 #if SEP == '\\' /* Special case for MS filename syntax */
 		if (argc > 0 && argv0 != NULL && wcscmp(argv0, L"-c") != 0) {
 			wchar_t *q;
-#ifdef MS_WINDOWS
+#if defined(MS_WINDOWS) && !defined(MS_WINCE)
+			/* This code here replaces the first element in argv with the full
+			path that it represents. Under CE, there are no relative paths so
+			the argument must be the full path anyway. */
 			wchar_t *ptemp;
 			if (GetFullPathNameW(argv0,
 					   sizeof(fullpath)/sizeof(fullpath[0]),


More information about the Python-checkins mailing list