comparison Python/sysmodule.c @ 35676:e1df48f2847a 2.4

Backport: SF bug #887946, segfault if redirecting directory Also provide a warning if a directory is passed on the command line. Add minimal command line test.
author Neal Norwitz <nnorwitz@gmail.com>
date Mon, 03 Oct 2005 01:03:46 +0000
parents 35c43674083a
children bc4fbbb2db30 1c4d192f1568
comparison
equal deleted inserted replaced
35675:9d43381c184c 35676:e1df48f2847a
944 char buf[10]; 944 char buf[10];
945 #endif 945 #endif
946 946
947 m = Py_InitModule3("sys", sys_methods, sys_doc); 947 m = Py_InitModule3("sys", sys_methods, sys_doc);
948 sysdict = PyModule_GetDict(m); 948 sysdict = PyModule_GetDict(m);
949
950 {
951 /* XXX: does this work on Win/Win64? (see posix_fstat) */
952 struct stat sb;
953 if (fstat(fileno(stdin), &sb) == 0 &&
954 S_ISDIR(sb.st_mode)) {
955 Py_FatalError("<stdin> is a directory");
956 }
957 }
949 958
950 /* Closing the standard FILE* if sys.std* goes aways causes problems 959 /* Closing the standard FILE* if sys.std* goes aways causes problems
951 * for embedded Python usages. Closing them when somebody explicitly 960 * for embedded Python usages. Closing them when somebody explicitly
952 * invokes .close() might be possible, but the FAQ promises they get 961 * invokes .close() might be possible, but the FAQ promises they get
953 * never closed. However, we still need to get write errors when 962 * never closed. However, we still need to get write errors when