gh-101819: Remove _PyWindowsConsoleIO_Type from the Windows DLL (GH-101904)

Automerge-Triggered-By: GH:erlend-aasland
This commit is contained in:
Erlend E. Aasland 2023-02-15 14:07:59 +01:00 committed by GitHub
parent c7766245c1
commit eb0c485b6c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 29 additions and 14 deletions

View file

@ -10,7 +10,7 @@
#ifdef MS_WINDOWS
#include "pycore_fileutils.h" // _Py_get_osfhandle()
#include "..\modules\_io\_iomodule.h"
#include "pycore_runtime.h" // _Py_ID()
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
@ -51,7 +51,14 @@ _testconsole_write_input_impl(PyObject *module, PyObject *file,
{
INPUT_RECORD *rec = NULL;
if (!PyWindowsConsoleIO_Check(file)) {
PyTypeObject *winconsoleio_type = (PyTypeObject *)_PyImport_GetModuleAttr(
&_Py_ID(_io), &_Py_ID(_WindowsConsoleIO));
if (winconsoleio_type == NULL) {
return NULL;
}
int is_subclass = PyObject_TypeCheck(file, winconsoleio_type);
Py_DECREF(winconsoleio_type);
if (!is_subclass) {
PyErr_SetString(PyExc_TypeError, "expected raw console object");
return NULL;
}