1 --- Python/pylifecycle.c 2024-03-27 14:34:43.905367358 +0000
2 +++ Python/pylifecycle.c 2024-03-27 14:40:16.339134322 +0000
7 + /* Check that stdin, etc is not a directory
8 + Using shell redirection, you can redirect stdin to a directory,
9 + crashing the Python interpreter. Catch this common mistake here
10 + and output a useful error message. Note that under MS Windows,
11 + the shell already prevents that. */
13 + struct _Py_stat_struct sb;
14 + if (_Py_fstat_noraise(fd, &sb) == 0 &&
15 + S_ISDIR(sb.st_mode)) {
16 + // "name" is a directory, cannot continue
21 /* stdin is always opened in buffered mode, first because it shouldn't
22 make a difference in common use cases, second because TextIOWrapper
23 depends on the presence of a read1() method which only exists on
24 @@ -1854,19 +1868,6 @@
25 PyStatus res = _PyStatus_OK();
26 PyConfig *config = &interp->config;
28 - /* Check that stdin is not a directory
29 - Using shell redirection, you can redirect stdin to a directory,
30 - crashing the Python interpreter. Catch this common mistake here
31 - and output a useful error message. Note that under MS Windows,
32 - the shell already prevents that. */
34 - struct _Py_stat_struct sb;
35 - if (_Py_fstat_noraise(fileno(stdin), &sb) == 0 &&
36 - S_ISDIR(sb.st_mode)) {
37 - return _PyStatus_ERR("<stdin> is a directory, cannot continue");
41 /* Hack to avoid a nasty recursion issue when Python is invoked
42 in verbose mode: pre-import the Latin-1 and UTF-8 codecs */
43 if ((m = PyImport_ImportModule("encodings.utf_8")) == NULL) {