bpo-23867: Argument Clinic: inline parsing code for a single position… · python/cpython@32d96a2 (original) (raw)

`@@ -19,7 +19,13 @@ _io__BufferedIOBase_readinto(PyObject *self, PyObject *arg)

`

19

19

`PyObject *return_value = NULL;

`

20

20

`Py_buffer buffer = {NULL, NULL};

`

21

21

``

22

``

`-

if (!PyArg_Parse(arg, "w*:readinto", &buffer)) {

`

``

22

`+

if (PyObject_GetBuffer(arg, &buffer, PyBUF_WRITABLE) < 0) {

`

``

23

`+

PyErr_Clear();

`

``

24

`+

_PyArg_BadArgument("readinto", "read-write bytes-like object", arg);

`

``

25

`+

goto exit;

`

``

26

`+

}

`

``

27

`+

if (!PyBuffer_IsContiguous(&buffer, 'C')) {

`

``

28

`+

_PyArg_BadArgument("readinto", "contiguous buffer", arg);

`

23

29

` goto exit;

`

24

30

` }

`

25

31

`return_value = _io__BufferedIOBase_readinto_impl(self, &buffer);

`

`@@ -50,7 +56,13 @@ _io__BufferedIOBase_readinto1(PyObject *self, PyObject *arg)

`

50

56

`PyObject *return_value = NULL;

`

51

57

`Py_buffer buffer = {NULL, NULL};

`

52

58

``

53

``

`-

if (!PyArg_Parse(arg, "w*:readinto1", &buffer)) {

`

``

59

`+

if (PyObject_GetBuffer(arg, &buffer, PyBUF_WRITABLE) < 0) {

`

``

60

`+

PyErr_Clear();

`

``

61

`+

_PyArg_BadArgument("readinto1", "read-write bytes-like object", arg);

`

``

62

`+

goto exit;

`

``

63

`+

}

`

``

64

`+

if (!PyBuffer_IsContiguous(&buffer, 'C')) {

`

``

65

`+

_PyArg_BadArgument("readinto1", "contiguous buffer", arg);

`

54

66

` goto exit;

`

55

67

` }

`

56

68

`return_value = _io__BufferedIOBase_readinto1_impl(self, &buffer);

`

`@@ -183,7 +195,13 @@ _io__Buffered_readinto(buffered *self, PyObject *arg)

`

183

195

`PyObject *return_value = NULL;

`

184

196

`Py_buffer buffer = {NULL, NULL};

`

185

197

``

186

``

`-

if (!PyArg_Parse(arg, "w*:readinto", &buffer)) {

`

``

198

`+

if (PyObject_GetBuffer(arg, &buffer, PyBUF_WRITABLE) < 0) {

`

``

199

`+

PyErr_Clear();

`

``

200

`+

_PyArg_BadArgument("readinto", "read-write bytes-like object", arg);

`

``

201

`+

goto exit;

`

``

202

`+

}

`

``

203

`+

if (!PyBuffer_IsContiguous(&buffer, 'C')) {

`

``

204

`+

_PyArg_BadArgument("readinto", "contiguous buffer", arg);

`

187

205

` goto exit;

`

188

206

` }

`

189

207

`return_value = _io__Buffered_readinto_impl(self, &buffer);

`

`@@ -214,7 +232,13 @@ _io__Buffered_readinto1(buffered *self, PyObject *arg)

`

214

232

`PyObject *return_value = NULL;

`

215

233

`Py_buffer buffer = {NULL, NULL};

`

216

234

``

217

``

`-

if (!PyArg_Parse(arg, "w*:readinto1", &buffer)) {

`

``

235

`+

if (PyObject_GetBuffer(arg, &buffer, PyBUF_WRITABLE) < 0) {

`

``

236

`+

PyErr_Clear();

`

``

237

`+

_PyArg_BadArgument("readinto1", "read-write bytes-like object", arg);

`

``

238

`+

goto exit;

`

``

239

`+

}

`

``

240

`+

if (!PyBuffer_IsContiguous(&buffer, 'C')) {

`

``

241

`+

_PyArg_BadArgument("readinto1", "contiguous buffer", arg);

`

218

242

` goto exit;

`

219

243

` }

`

220

244

`return_value = _io__Buffered_readinto1_impl(self, &buffer);

`

`@@ -390,7 +414,11 @@ _io_BufferedWriter_write(buffered *self, PyObject *arg)

`

390

414

`PyObject *return_value = NULL;

`

391

415

`Py_buffer buffer = {NULL, NULL};

`

392

416

``

393

``

`-

if (!PyArg_Parse(arg, "y*:write", &buffer)) {

`

``

417

`+

if (PyObject_GetBuffer(arg, &buffer, PyBUF_SIMPLE) != 0) {

`

``

418

`+

goto exit;

`

``

419

`+

}

`

``

420

`+

if (!PyBuffer_IsContiguous(&buffer, 'C')) {

`

``

421

`+

_PyArg_BadArgument("write", "contiguous buffer", arg);

`

394

422

` goto exit;

`

395

423

` }

`

396

424

`return_value = _io_BufferedWriter_write_impl(self, &buffer);

`

`@@ -476,4 +504,4 @@ io_BufferedRandom___init_(PyObject *self, PyObject *args, PyObject *kwargs)

`

476

504

`exit:

`

477

505

`return return_value;

`

478

506

`}

`

479

``

`-

/[clinic end generated code: output=cb4bf8d50533953b input=a9049054013a1b77]/

`

``

507

`+

/[clinic end generated code: output=40de95d461a20782 input=a9049054013a1b77]/

`