summaryrefslogtreecommitdiffstats
path: root/PC
diff options
context:
space:
mode:
authorErlend E. Aasland <erlend.aasland@protonmail.com>2023-02-15 13:07:59 (GMT)
committerGitHub <noreply@github.com>2023-02-15 13:07:59 (GMT)
commiteb0c485b6c836abb71932537a5058344d11d7bc8 (patch)
tree6b456f13178753f7af386fb769c5d232e0180fa7 /PC
parentc7766245c14fa03b8afd3aff9be30b13d0069f95 (diff)
downloadcpython-eb0c485b6c836abb71932537a5058344d11d7bc8.zip
cpython-eb0c485b6c836abb71932537a5058344d11d7bc8.tar.gz
cpython-eb0c485b6c836abb71932537a5058344d11d7bc8.tar.bz2
gh-101819: Remove _PyWindowsConsoleIO_Type from the Windows DLL (GH-101904)
Automerge-Triggered-By: GH:erlend-aasland
Diffstat (limited to 'PC')
-rw-r--r--PC/_testconsole.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/PC/_testconsole.c b/PC/_testconsole.c
index a830883..f14a2d4 100644
--- a/PC/_testconsole.c
+++ b/PC/_testconsole.c
@@ -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;
}