summaryrefslogtreecommitdiff
path: root/Python/sysmodule.c
diff options
context:
space:
mode:
authorGeorg Brandl <georg@python.org>2009-01-14 00:08:09 +0000
committerGeorg Brandl <georg@python.org>2009-01-14 00:08:09 +0000
commit686d53eed3c9b009397164a5190c16b8b1e0bdb2 (patch)
treea92fc2c1b07e9a91ab2966b7d3ab96600299bbed /Python/sysmodule.c
parent8b9ccadb15f433ca0129562c838740b1ee5724ef (diff)
downloadcpython-git-686d53eed3c9b009397164a5190c16b8b1e0bdb2.tar.gz
Merged revisions 68521,68527,68534-68536,68540,68547,68552,68563,68570,68572,68575,68579-68580,68584 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk ........ r68521 | hirokazu.yamamoto | 2009-01-11 04:28:13 +0100 (So, 11 Jan 2009) | 1 line Fixed version number in build_ssl.bat. ........ r68527 | martin.v.loewis | 2009-01-11 10:43:55 +0100 (So, 11 Jan 2009) | 2 lines Issue #4895: Use _strdup on Windows CE. ........ r68534 | gregory.p.smith | 2009-01-11 18:53:33 +0100 (So, 11 Jan 2009) | 2 lines correct email address ........ r68535 | gregory.p.smith | 2009-01-11 18:57:54 +0100 (So, 11 Jan 2009) | 9 lines Update the documentation for binascii and zlib crc32/adler32 functions to better describe the signed vs unsigned return value behavior on different platforms and versions of python. Mention the workaround to make them all return the same thing by using & 0xffffffff. Fixes issue4903. Also needs to be merged into release26-maint, release30-maint, & py3k. ........ r68536 | benjamin.peterson | 2009-01-11 20:48:15 +0100 (So, 11 Jan 2009) | 1 line add email addresses ........ r68540 | martin.v.loewis | 2009-01-12 08:57:11 +0100 (Mo, 12 Jan 2009) | 2 lines Issue #4915: Port sysmodule to Windows CE. ........ r68547 | kristjan.jonsson | 2009-01-12 19:09:27 +0100 (Mo, 12 Jan 2009) | 1 line Add tests for invalid format specifiers in strftime, and for handling of invalid file descriptors in the os module. ........ r68552 | vinay.sajip | 2009-01-12 21:36:18 +0100 (Mo, 12 Jan 2009) | 1 line Minor changes/corrections in markup. ........ r68563 | benjamin.peterson | 2009-01-13 02:49:10 +0100 (Di, 13 Jan 2009) | 1 line small logic correction ........ r68570 | raymond.hettinger | 2009-01-13 10:08:32 +0100 (Di, 13 Jan 2009) | 5 lines Issue 4922: Incorrect comments for MutableSet.add() and MutableSet.discard(). Needs to be backported to 2.6 and forward ported to 3.0 and 3.1. ........ r68572 | andrew.kuchling | 2009-01-13 14:40:54 +0100 (Di, 13 Jan 2009) | 1 line Note that first coord. is left alone ........ r68575 | thomas.heller | 2009-01-13 18:32:28 +0100 (Di, 13 Jan 2009) | 1 line Fix refcount leak in error cases. Bug found by coverity. ........ r68579 | benjamin.peterson | 2009-01-13 22:42:23 +0100 (Di, 13 Jan 2009) | 1 line make bytearrayobject.o depend on the stringlib #4936 ........ r68580 | benjamin.peterson | 2009-01-13 22:43:11 +0100 (Di, 13 Jan 2009) | 1 line add bytearrayobject.h to PYTHON_HEADERS ........ r68584 | benjamin.peterson | 2009-01-13 23:22:41 +0100 (Di, 13 Jan 2009) | 1 line de-spacify ........
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 4bd0e01eb9..ff7157fc65 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),