Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit e8b6aaa

Browse filesBrowse files
gh-101819: Remove _testcapi dependencies on specific _io symbols (#101918)
1 parent 8a2b7ee commit e8b6aaa
Copy full SHA for e8b6aaa

File tree

2 files changed

+8
-12
lines changed
Filter options

2 files changed

+8
-12
lines changed

‎Modules/_io/_iomodule.c

Copy file name to clipboardExpand all lines: Modules/_io/_iomodule.c
+2-10Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -720,16 +720,8 @@ PyInit__io(void)
720720
// Add types
721721
for (size_t i=0; i < Py_ARRAY_LENGTH(static_types); i++) {
722722
PyTypeObject *type = static_types[i];
723-
// Private type not exposed in the _io module
724-
if (type == &_PyBytesIOBuffer_Type) {
725-
if (PyType_Ready(type) < 0) {
726-
goto fail;
727-
}
728-
}
729-
else {
730-
if (PyModule_AddType(m, type) < 0) {
731-
goto fail;
732-
}
723+
if (PyModule_AddType(m, type) < 0) {
724+
goto fail;
733725
}
734726
}
735727

‎Modules/_testcapimodule.c

Copy file name to clipboardExpand all lines: Modules/_testcapimodule.c
+6-2Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1448,12 +1448,10 @@ test_from_contiguous(PyObject* self, PyObject *Py_UNUSED(ignored))
14481448
}
14491449

14501450
#if (defined(__linux__) || defined(__FreeBSD__)) && defined(__GNUC__)
1451-
extern PyTypeObject _PyBytesIOBuffer_Type;
14521451

14531452
static PyObject *
14541453
test_pep3118_obsolete_write_locks(PyObject* self, PyObject *Py_UNUSED(ignored))
14551454
{
1456-
PyTypeObject *type = &_PyBytesIOBuffer_Type;
14571455
PyObject *b;
14581456
char *dummy[1];
14591457
int ret, match;
@@ -1466,7 +1464,13 @@ test_pep3118_obsolete_write_locks(PyObject* self, PyObject *Py_UNUSED(ignored))
14661464
goto error;
14671465

14681466
/* bytesiobuf_getbuffer() */
1467+
PyTypeObject *type = (PyTypeObject *)_PyImport_GetModuleAttrString(
1468+
"_io", "_BytesIOBuffer");
1469+
if (type == NULL) {
1470+
return NULL;
1471+
}
14691472
b = type->tp_alloc(type, 0);
1473+
Py_DECREF(type);
14701474
if (b == NULL) {
14711475
return NULL;
14721476
}

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.