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()
diff --git a/Modules/main.c b/Modules/main.c
index 3aa4d91..7ffcb07 100644
--- a/Modules/main.c
+++ b/Modules/main.c
@@ -313,17 +313,8 @@ pymain_run_file(const PyConfig *config, PyCompilerFlags *cf)
     }
     FILE *fp = _Py_wfopen(filename, L"rb");
     if (fp == NULL) {
-        char *cfilename_buffer;
-        const char *cfilename;
-        int err = errno;
-        cfilename_buffer = _Py_EncodeLocaleRaw(filename, NULL);
-        if (cfilename_buffer != NULL)
-            cfilename = cfilename_buffer;
-        else
-            cfilename = "<unprintable file name>";
-        fprintf(stderr, "%ls: can't open file '%s': [Errno %d] %s\n",
-                config->program_name, cfilename, err, strerror(err));
-        PyMem_RawFree(cfilename_buffer);
+        fprintf(stderr, "%ls: can't open file '%ls': [Errno %d] %s\n",
+                config->program_name, filename, errno, strerror(errno));
         return 2;
     }
 
@@ -353,25 +344,15 @@ pymain_run_file(const PyConfig *config, PyCompilerFlags *cf)
         return pymain_exit_err_print();
     }
 
-    PyObject *unicode, *bytes = NULL;
-    const char *filename_str;
-
-    unicode = PyUnicode_FromWideChar(filename, wcslen(filename));
-    if (unicode != NULL) {
-        bytes = PyUnicode_EncodeFSDefault(unicode);
-        Py_DECREF(unicode);
-    }
-    if (bytes != NULL) {
-        filename_str = PyBytes_AsString(bytes);
-    }
-    else {
-        PyErr_Clear();
-        filename_str = "<filename encoding error>";
+    PyObject *filename_obj = PyUnicode_FromWideChar(filename, -1);
+    if (filename_obj == NULL) {
+        PyErr_Print();
+        return -1;
     }
 
     /* PyRun_AnyFileExFlags(closeit=1) calls fclose(fp) before running code */
-    int run = PyRun_AnyFileExFlags(fp, filename_str, 1, cf);
-    Py_XDECREF(bytes);
+    int run = _PyRun_AnyFileObject(fp, filename_obj, 1, cf);
+    Py_XDECREF(filename_obj);
     return (run != 0);
 }