bpo-32381: Add _PyRun_AnyFileObject() (GH-23723)
pymain_run_file() no longer encodes the filename: pass the filename as an object to the new _PyRun_AnyFileObject() function. Add new private functions: * _PyRun_AnyFileObject() * _PyRun_InteractiveLoopObject() * _Py_FdIsInteractive()
This commit is contained in:
@@ -2739,6 +2739,21 @@ Py_FdIsInteractive(FILE *fp, const char *filename)
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
_Py_FdIsInteractive(FILE *fp, PyObject *filename)
|
||||
{
|
||||
if (isatty((int)fileno(fp))) {
|
||||
return 1;
|
||||
}
|
||||
if (!Py_InteractiveFlag) {
|
||||
return 0;
|
||||
}
|
||||
return (filename == NULL) ||
|
||||
(PyUnicode_CompareWithASCIIString(filename, "<stdin>") == 0) ||
|
||||
(PyUnicode_CompareWithASCIIString(filename, "???") == 0);
|
||||
}
|
||||
|
||||
|
||||
/* Wrappers around sigaction() or signal(). */
|
||||
|
||||
PyOS_sighandler_t
|
||||
|
||||
Reference in New Issue
Block a user