@@ -1160,18 +1160,11 @@ PyType_Spec bytesio_spec = {
11601160 */
11611161
11621162static int
1163- bytesiobuf_getbuffer (PyObject * op , Py_buffer * view , int flags )
1163+ bytesiobuf_getbuffer_lock_held (PyObject * op , Py_buffer * view , int flags )
11641164{
11651165 bytesiobuf * obj = bytesiobuf_CAST (op );
11661166 bytesio * b = bytesio_CAST (obj -> source );
11671167
1168- if (view == NULL ) {
1169- PyErr_SetString (PyExc_BufferError ,
1170- "bytesiobuf_getbuffer: view==NULL argument is obsolete" );
1171- return -1 ;
1172- }
1173-
1174- /* assertion not above because of test_pep3118_obsolete_write_locks() */
11751168 _Py_CRITICAL_SECTION_ASSERT_OBJECT_LOCKED (b );
11761169
11771170 if (FT_ATOMIC_LOAD_SSIZE_RELAXED (b -> exports ) == 0 && SHARED_BUF (b )) {
@@ -1187,6 +1180,24 @@ bytesiobuf_getbuffer(PyObject *op, Py_buffer *view, int flags)
11871180 return 0 ;
11881181}
11891182
1183+ static int
1184+ bytesiobuf_getbuffer (PyObject * op , Py_buffer * view , int flags )
1185+ {
1186+ if (view == NULL ) {
1187+ PyErr_SetString (PyExc_BufferError ,
1188+ "bytesiobuf_getbuffer: view==NULL argument is obsolete" );
1189+ return -1 ;
1190+ }
1191+
1192+ bytesiobuf * obj = bytesiobuf_CAST (op );
1193+ bytesio * b = bytesio_CAST (obj -> source );
1194+ int ret ;
1195+ Py_BEGIN_CRITICAL_SECTION (b );
1196+ ret = bytesiobuf_getbuffer_lock_held (op , view , flags );
1197+ Py_END_CRITICAL_SECTION ();
1198+ return ret ;
1199+ }
1200+
11901201static void
11911202bytesiobuf_releasebuffer (PyObject * op , Py_buffer * Py_UNUSED (view ))
11921203{
0 commit comments