mirror of
https://github.com/python/cpython.git
synced 2025-11-03 19:34:08 +00:00
gh-101819: Remove _testcapi dependencies on specific _io symbols (#101918)
This commit is contained in:
parent
8a2b7ee64d
commit
e8b6aaad2f
2 changed files with 8 additions and 12 deletions
|
|
@ -720,18 +720,10 @@ PyInit__io(void)
|
||||||
// Add types
|
// Add types
|
||||||
for (size_t i=0; i < Py_ARRAY_LENGTH(static_types); i++) {
|
for (size_t i=0; i < Py_ARRAY_LENGTH(static_types); i++) {
|
||||||
PyTypeObject *type = 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) {
|
if (PyModule_AddType(m, type) < 0) {
|
||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
state->initialized = 1;
|
state->initialized = 1;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1448,12 +1448,10 @@ test_from_contiguous(PyObject* self, PyObject *Py_UNUSED(ignored))
|
||||||
}
|
}
|
||||||
|
|
||||||
#if (defined(__linux__) || defined(__FreeBSD__)) && defined(__GNUC__)
|
#if (defined(__linux__) || defined(__FreeBSD__)) && defined(__GNUC__)
|
||||||
extern PyTypeObject _PyBytesIOBuffer_Type;
|
|
||||||
|
|
||||||
static PyObject *
|
static PyObject *
|
||||||
test_pep3118_obsolete_write_locks(PyObject* self, PyObject *Py_UNUSED(ignored))
|
test_pep3118_obsolete_write_locks(PyObject* self, PyObject *Py_UNUSED(ignored))
|
||||||
{
|
{
|
||||||
PyTypeObject *type = &_PyBytesIOBuffer_Type;
|
|
||||||
PyObject *b;
|
PyObject *b;
|
||||||
char *dummy[1];
|
char *dummy[1];
|
||||||
int ret, match;
|
int ret, match;
|
||||||
|
|
@ -1466,7 +1464,13 @@ test_pep3118_obsolete_write_locks(PyObject* self, PyObject *Py_UNUSED(ignored))
|
||||||
goto error;
|
goto error;
|
||||||
|
|
||||||
/* bytesiobuf_getbuffer() */
|
/* bytesiobuf_getbuffer() */
|
||||||
|
PyTypeObject *type = (PyTypeObject *)_PyImport_GetModuleAttrString(
|
||||||
|
"_io", "_BytesIOBuffer");
|
||||||
|
if (type == NULL) {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
b = type->tp_alloc(type, 0);
|
b = type->tp_alloc(type, 0);
|
||||||
|
Py_DECREF(type);
|
||||||
if (b == NULL) {
|
if (b == NULL) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue