Mercurial > cpython-lru_cache-weakref
comparison Python/sysmodule.c @ 35673:612a12178e47 legacy-trunk
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.
Will backport.
| author | Neal Norwitz <nnorwitz@gmail.com> |
|---|---|
| date | Mon, 03 Oct 2005 00:54:56 +0000 |
| parents | 1b25fe8834ae |
| children | bc4fbbb2db30 1c4d192f1568 |
comparison
equal
deleted
inserted
replaced
| 35671:5d5236eae8bd | 35673:612a12178e47 |
|---|---|
| 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 |
