summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorErlend E. Aasland <erlend.aasland@protonmail.com>2023-02-15 10:18:27 (GMT)
committerGitHub <noreply@github.com>2023-02-15 10:18:27 (GMT)
commite8b6aaad2faf11fe315410138a5c5943d610d8d8 (patch)
tree3c679e0d286c6681b8a81b47c6d8900f14895b28
parent8a2b7ee64d1bde762438b458ea7fe88f054a3a88 (diff)
downloadcpython-e8b6aaad2faf11fe315410138a5c5943d610d8d8.zip
cpython-e8b6aaad2faf11fe315410138a5c5943d610d8d8.tar.gz
cpython-e8b6aaad2faf11fe315410138a5c5943d610d8d8.tar.bz2
gh-101819: Remove _testcapi dependencies on specific _io symbols (#101918)
-rw-r--r--Modules/_io/_iomodule.c12
-rw-r--r--Modules/_testcapimodule.c8
2 files changed, 8 insertions, 12 deletions
diff --git a/Modules/_io/_iomodule.c b/Modules/_io/_iomodule.c
index 175fa97..811b1d2 100644
--- a/Modules/_io/_iomodule.c
+++ b/Modules/_io/_iomodule.c
@@ -720,16 +720,8 @@ PyInit__io(void)
// Add types
for (size_t i=0; i < Py_ARRAY_LENGTH(static_types); i++) {
PyTypeObject *type = static_types[i];
- // Private type not exposed in the _io module
- if (type == &_PyBytesIOBuffer_Type) {
- if (PyType_Ready(type) < 0) {
- goto fail;
- }
- }
- else {
- if (PyModule_AddType(m, type) < 0) {
- goto fail;
- }
+ if (PyModule_AddType(m, type) < 0) {
+ goto fail;
}
}
diff --git a/Modules/_testcapimodule.c b/Modules/_testcapimodule.c
index 3c411fa..5610a76 100644
--- a/Modules/_testcapimodule.c
+++ b/Modules/_testcapimodule.c
@@ -1448,12 +1448,10 @@ test_from_contiguous(PyObject* self, PyObject *Py_UNUSED(ignored))
}
#if (defined(__linux__) || defined(__FreeBSD__)) && defined(__GNUC__)
-extern PyTypeObject _PyBytesIOBuffer_Type;
static PyObject *
test_pep3118_obsolete_write_locks(PyObject* self, PyObject *Py_UNUSED(ignored))
{
- PyTypeObject *type = &_PyBytesIOBuffer_Type;
PyObject *b;
char *dummy[1];
int ret, match;
@@ -1466,7 +1464,13 @@ test_pep3118_obsolete_write_locks(PyObject* self, PyObject *Py_UNUSED(ignored))
goto error;
/* bytesiobuf_getbuffer() */
+ PyTypeObject *type = (PyTypeObject *)_PyImport_GetModuleAttrString(
+ "_io", "_BytesIOBuffer");
+ if (type == NULL) {
+ return NULL;
+ }
b = type->tp_alloc(type, 0);
+ Py_DECREF(type);
if (b == NULL) {
return NULL;
}