a1295cb177
Downloaded from https://www.python.org/ftp/python/3.10.14/Python-3.10.14.tar.xz * external/python3/macos-11.patch.0 should be long obsolete by now Change-Id: I454851f7684e699519370bdbbcd9bb9a2cccd077 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/170051 Tested-by: Jenkins Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
43 lines
1.7 KiB
Text
43 lines
1.7 KiB
Text
--- Python/pylifecycle.c 2024-03-27 14:34:43.905367358 +0000
|
|
+++ Python/pylifecycle.c 2024-03-27 14:40:16.339134322 +0000
|
|
@@ -1789,6 +1789,20 @@
|
|
if (!is_valid_fd(fd))
|
|
Py_RETURN_NONE;
|
|
|
|
+ /* Check that stdin, etc 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. */
|
|
+#ifndef MS_WINDOWS
|
|
+ struct _Py_stat_struct sb;
|
|
+ if (_Py_fstat_noraise(fd, &sb) == 0 &&
|
|
+ S_ISDIR(sb.st_mode)) {
|
|
+ // "name" is a directory, cannot continue
|
|
+ Py_RETURN_NONE;
|
|
+ }
|
|
+#endif
|
|
+
|
|
/* stdin is always opened in buffered mode, first because it shouldn't
|
|
make a difference in common use cases, second because TextIOWrapper
|
|
depends on the presence of a read1() method which only exists on
|
|
@@ -2335,19 +2335,6 @@
|
|
PyStatus res = _PyStatus_OK();
|
|
const PyConfig *config = _PyInterpreterState_GetConfig(tstate->interp);
|
|
|
|
- /* 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. */
|
|
-#ifndef MS_WINDOWS
|
|
- struct _Py_stat_struct sb;
|
|
- if (_Py_fstat_noraise(fileno(stdin), &sb) == 0 &&
|
|
- S_ISDIR(sb.st_mode)) {
|
|
- return _PyStatus_ERR("<stdin> is a directory, cannot continue");
|
|
- }
|
|
-#endif
|
|
-
|
|
if (!(iomod = PyImport_ImportModule("io"))) {
|
|
goto error;
|
|
}
|