summaryrefslogtreecommitdiffstats
path: root/Python/sysmodule.c
diff options
context:
space:
mode:
authorMartin v. Löwis <martin@v.loewis.de>2009-01-12 07:57:11 (GMT)
committerMartin v. Löwis <martin@v.loewis.de>2009-01-12 07:57:11 (GMT)
commit1b3bef21b061a1543591d6d67d5501a4469504e9 (patch)
treeb1551120867ad32c93b19c3e8c2800ad5c4b1bcb /Python/sysmodule.c
parent51a37034db7f6984a7588d262461f8518c4f6ae3 (diff)
downloadcpython-1b3bef21b061a1543591d6d67d5501a4469504e9.zip
cpython-1b3bef21b061a1543591d6d67d5501a4469504e9.tar.gz
cpython-1b3bef21b061a1543591d6d67d5501a4469504e9.tar.bz2
Issue #4915: Port sysmodule to Windows CE.
Diffstat (limited to 'Python/sysmodule.c')
-rw-r--r--Python/sysmodule.c15
1 files changed, 12 insertions, 3 deletions
diff --git a/Python/sysmodule.c b/Python/sysmodule.c
index 4bd0e01..ff7157f 100644
--- a/Python/sysmodule.c
+++ b/Python/sysmodule.c
@@ -1296,8 +1296,13 @@ _PySys_Init(void)
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)) {
@@ -1307,6 +1312,7 @@ _PySys_Init(void)
exit(EXIT_FAILURE);
}
}
+#endif
/* Closing the standard FILE* if sys.std* goes aways causes problems
* for embedded Python usages. Closing them when somebody explicitly
@@ -1526,7 +1532,7 @@ PySys_SetArgv(int argc, char **argv)
{
#if defined(HAVE_REALPATH)
char fullpath[MAXPATHLEN];
-#elif defined(MS_WINDOWS)
+#elif defined(MS_WINDOWS) && !defined(MS_WINCE)
char fullpath[MAX_PATH];
#endif
PyObject *av = makeargvobject(argc, argv);
@@ -1571,7 +1577,10 @@ PySys_SetArgv(int argc, char **argv)
#if SEP == '\\' /* Special case for MS filename syntax */
if (argc > 0 && argv0 != NULL && strcmp(argv0, "-c") != 0) {
char *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. */
char *ptemp;
if (GetFullPathName(argv0,
sizeof(fullpath),