| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent ea720fe commit 762bf40
20 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1097,6 +1097,9 @@ PyAPI_FUNC(void) _Py_add_one_to_index_F(int nd, Py_ssize_t *index, | |||
| 1097 | 1097 | const Py_ssize_t *shape); | |
| 1098 | 1098 | PyAPI_FUNC(void) _Py_add_one_to_index_C(int nd, Py_ssize_t *index, | |
| 1099 | 1099 | const Py_ssize_t *shape); | |
| 1100 | + | ||
| 1101 | + /* Convert Python int to Py_ssize_t. Do nothing if the argument is None. */ | ||
| 1102 | + PyAPI_FUNC(int) _Py_convert_optional_to_ssize_t(PyObject *, void *); | ||
| 1100 | 1103 | #endif /* !Py_LIMITED_API */ | |
| 1101 | 1104 | ||
| 1102 | 1105 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -541,30 +541,6 @@ PyNumber_AsOff_t(PyObject *item, PyObject *err) | |||
| 541 | 541 | } | |
| 542 | 542 | ||
| 543 | 543 | ||
| 544 | - /* Basically the "n" format code with the ability to turn None into -1. */ | ||
| 545 | - int | ||
| 546 | - _PyIO_ConvertSsize_t(PyObject *obj, void *result) { | ||
| 547 | - Py_ssize_t limit; | ||
| 548 | - if (obj == Py_None) { | ||
| 549 | - limit = -1; | ||
| 550 | - } | ||
| 551 | - else if (PyIndex_Check(obj)) { | ||
| 552 | - limit = PyNumber_AsSsize_t(obj, PyExc_OverflowError); | ||
| 553 | - if (limit == -1 && PyErr_Occurred()) { | ||
| 554 | - return 0; | ||
| 555 | - } | ||
| 556 | - } | ||
| 557 | - else { | ||
| 558 | - PyErr_Format(PyExc_TypeError, | ||
| 559 | - "argument should be integer or None, not '%.200s'", | ||
| 560 | - Py_TYPE(obj)->tp_name); | ||
| 561 | - return 0; | ||
| 562 | - } | ||
| 563 | - *((Py_ssize_t *)result) = limit; | ||
| 564 | - return 1; | ||
| 565 | - } | ||
| 566 | - | ||
| 567 | - | ||
| 568 | 544 | _PyIO_State * | |
| 569 | 545 | _PyIO_get_module_state(void) | |
| 570 | 546 | { | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -27,8 +27,6 @@ PyAPI_DATA(PyObject *) _PyWindowsConsoleIO_Type; | |||
| 27 | 27 | #endif /* MS_WINDOWS */ | |
| 28 | 28 | #endif /* Py_LIMITED_API */ | |
| 29 | 29 | ||
| 30 | - extern int _PyIO_ConvertSsize_t(PyObject *, void *); | ||
| 31 | - | ||
| 32 | 30 | /* These functions are used as METH_NOARGS methods, are normally called | |
| 33 | 31 | * with args=NULL, and return a new reference. | |
| 34 | 32 | * BUT when args=Py_True is passed, they return a borrowed reference. | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -24,13 +24,6 @@ class _io.BufferedRandom "buffered *" "&PyBufferedRandom_Type" | |||
| 24 | 24 | [clinic start generated code]*/ | |
| 25 | 25 | /*[clinic end generated code: output=da39a3ee5e6b4b0d input=59460b9c5639984d]*/ | |
| 26 | 26 | ||
| 27 | - /*[python input] | ||
| 28 | - class io_ssize_t_converter(CConverter): | ||
| 29 | - type = 'Py_ssize_t' | ||
| 30 | - converter = '_PyIO_ConvertSsize_t' | ||
| 31 | - [python start generated code]*/ | ||
| 32 | - /*[python end generated code: output=da39a3ee5e6b4b0d input=d0a811d3cbfd1b33]*/ | ||
| 33 | - | ||
| 34 | 27 | _Py_IDENTIFIER(close); | |
| 35 | 28 | _Py_IDENTIFIER(_dealloc_warn); | |
| 36 | 29 | _Py_IDENTIFIER(flush); | |
@@ -892,13 +885,13 @@ _io__Buffered_peek_impl(buffered *self, Py_ssize_t size) | |||
| 892 | 885 | ||
| 893 | 886 | /*[clinic input] | |
| 894 | 887 | _io._Buffered.read | |
| 895 | - size as n: io_ssize_t = -1 | ||
| 888 | + size as n: Py_ssize_t(accept={int, NoneType}) = -1 | ||
| 896 | 889 | / | |
| 897 | 890 | [clinic start generated code]*/ | |
| 898 | 891 | ||
| 899 | 892 | static PyObject * | |
| 900 | 893 | _io__Buffered_read_impl(buffered *self, Py_ssize_t n) | |
| 901 | - /*[clinic end generated code: output=f41c78bb15b9bbe9 input=c0939ec7f9e9354f]*/ | ||
| 894 | + /*[clinic end generated code: output=f41c78bb15b9bbe9 input=7df81e82e08a68a2]*/ | ||
| 902 | 895 | { | |
| 903 | 896 | PyObject *res; | |
| 904 | 897 | ||
@@ -1206,13 +1199,13 @@ _buffered_readline(buffered *self, Py_ssize_t limit) | |||
| 1206 | 1199 | ||
| 1207 | 1200 | /*[clinic input] | |
| 1208 | 1201 | _io._Buffered.readline | |
| 1209 | - size: io_ssize_t = -1 | ||
| 1202 | + size: Py_ssize_t(accept={int, NoneType}) = -1 | ||
| 1210 | 1203 | / | |
| 1211 | 1204 | [clinic start generated code]*/ | |
| 1212 | 1205 | ||
| 1213 | 1206 | static PyObject * | |
| 1214 | 1207 | _io__Buffered_readline_impl(buffered *self, Py_ssize_t size) | |
| 1215 | - /*[clinic end generated code: output=24dd2aa6e33be83c input=ff1e0df821cb4e5c]*/ | ||
| 1208 | + /*[clinic end generated code: output=24dd2aa6e33be83c input=673b6240e315ef8a]*/ | ||
| 1216 | 1209 | { | |
| 1217 | 1210 | CHECK_INITIALIZED(self) | |
| 1218 | 1211 | return _buffered_readline(self, size); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -8,13 +8,6 @@ class _io.BytesIO "bytesio *" "&PyBytesIO_Type" | |||
| 8 | 8 | [clinic start generated code]*/ | |
| 9 | 9 | /*[clinic end generated code: output=da39a3ee5e6b4b0d input=7f50ec034f5c0b26]*/ | |
| 10 | 10 | ||
| 11 | - /*[python input] | ||
| 12 | - class io_ssize_t_converter(CConverter): | ||
| 13 | - type = 'Py_ssize_t' | ||
| 14 | - converter = '_PyIO_ConvertSsize_t' | ||
| 15 | - [python start generated code]*/ | ||
| 16 | - /*[python end generated code: output=da39a3ee5e6b4b0d input=d0a811d3cbfd1b33]*/ | ||
| 17 | - | ||
| 18 | 11 | typedef struct { | |
| 19 | 12 | PyObject_HEAD | |
| 20 | 13 | PyObject *buf; | |
@@ -381,7 +374,7 @@ read_bytes(bytesio *self, Py_ssize_t size) | |||
| 381 | 374 | ||
| 382 | 375 | /*[clinic input] | |
| 383 | 376 | _io.BytesIO.read | |
| 384 | - size: io_ssize_t = -1 | ||
| 377 | + size: Py_ssize_t(accept={int, NoneType}) = -1 | ||
| 385 | 378 | / | |
| 386 | 379 | ||
| 387 | 380 | Read at most size bytes, returned as a bytes object. | |
@@ -392,7 +385,7 @@ Return an empty bytes object at EOF. | |||
| 392 | 385 | ||
| 393 | 386 | static PyObject * | |
| 394 | 387 | _io_BytesIO_read_impl(bytesio *self, Py_ssize_t size) | |
| 395 | - /*[clinic end generated code: output=9cc025f21c75bdd2 input=c81ec53b8f2cc3cf]*/ | ||
| 388 | + /*[clinic end generated code: output=9cc025f21c75bdd2 input=74344a39f431c3d7]*/ | ||
| 396 | 389 | { | |
| 397 | 390 | Py_ssize_t n; | |
| 398 | 391 | ||
@@ -412,7 +405,7 @@ _io_BytesIO_read_impl(bytesio *self, Py_ssize_t size) | |||
| 412 | 405 | ||
| 413 | 406 | /*[clinic input] | |
| 414 | 407 | _io.BytesIO.read1 | |
| 415 | - size: io_ssize_t = -1 | ||
| 408 | + size: Py_ssize_t(accept={int, NoneType}) = -1 | ||
| 416 | 409 | / | |
| 417 | 410 | ||
| 418 | 411 | Read at most size bytes, returned as a bytes object. | |
@@ -423,14 +416,14 @@ Return an empty bytes object at EOF. | |||
| 423 | 416 | ||
| 424 | 417 | static PyObject * | |
| 425 | 418 | _io_BytesIO_read1_impl(bytesio *self, Py_ssize_t size) | |
| 426 | - /*[clinic end generated code: output=d0f843285aa95f1c input=67cf18b142111664]*/ | ||
| 419 | + /*[clinic end generated code: output=d0f843285aa95f1c input=440a395bf9129ef5]*/ | ||
| 427 | 420 | { | |
| 428 | 421 | return _io_BytesIO_read_impl(self, size); | |
| 429 | 422 | } | |
| 430 | 423 | ||
| 431 | 424 | /*[clinic input] | |
| 432 | 425 | _io.BytesIO.readline | |
| 433 | - size: io_ssize_t = -1 | ||
| 426 | + size: Py_ssize_t(accept={int, NoneType}) = -1 | ||
| 434 | 427 | / | |
| 435 | 428 | ||
| 436 | 429 | Next line from the file, as a bytes object. | |
@@ -442,7 +435,7 @@ Return an empty bytes object at EOF. | |||
| 442 | 435 | ||
| 443 | 436 | static PyObject * | |
| 444 | 437 | _io_BytesIO_readline_impl(bytesio *self, Py_ssize_t size) | |
| 445 | - /*[clinic end generated code: output=4bff3c251df8ffcd input=7c95bd3f9e9d1646]*/ | ||
| 438 | + /*[clinic end generated code: output=4bff3c251df8ffcd input=e7c3fbd1744e2783]*/ | ||
| 446 | 439 | { | |
| 447 | 440 | Py_ssize_t n; | |
| 448 | 441 | ||
@@ -556,7 +549,7 @@ _io_BytesIO_readinto_impl(bytesio *self, Py_buffer *buffer) | |||
| 556 | 549 | ||
| 557 | 550 | /*[clinic input] | |
| 558 | 551 | _io.BytesIO.truncate | |
| 559 | - size as arg: object = None | ||
| 552 | + size: Py_ssize_t(accept={int, NoneType}, c_default="self->pos") = None | ||
| 560 | 553 | / | |
| 561 | 554 | ||
| 562 | 555 | Truncate the file to at most size bytes. | |
@@ -566,31 +559,12 @@ The current file position is unchanged. Returns the new size. | |||
| 566 | 559 | [clinic start generated code]*/ | |
| 567 | 560 | ||
| 568 | 561 | static PyObject * | |
| 569 | - _io_BytesIO_truncate_impl(bytesio *self, PyObject *arg) | ||
| 570 | - /*[clinic end generated code: output=81e6be60e67ddd66 input=11ed1966835462ba]*/ | ||
| 562 | + _io_BytesIO_truncate_impl(bytesio *self, Py_ssize_t size) | ||
| 563 | + /*[clinic end generated code: output=9ad17650c15fa09b input=423759dd42d2f7c1]*/ | ||
| 571 | 564 | { | |
| 572 | - Py_ssize_t size; | ||
| 573 | - | ||
| 574 | 565 | CHECK_CLOSED(self); | |
| 575 | 566 | CHECK_EXPORTS(self); | |
| 576 | 567 | ||
| 577 | - if (arg == Py_None) { | ||
| 578 | - /* Truncate to current position if no argument is passed. */ | ||
| 579 | - size = self->pos; | ||
| 580 | - } | ||
| 581 | - else if (PyIndex_Check(arg)) { | ||
| 582 | - size = PyNumber_AsSsize_t(arg, PyExc_OverflowError); | ||
| 583 | - if (size == -1 && PyErr_Occurred()) { | ||
| 584 | - return NULL; | ||
| 585 | - } | ||
| 586 | - } | ||
| 587 | - else { | ||
| 588 | - PyErr_Format(PyExc_TypeError, | ||
| 589 | - "argument should be integer or None, not '%.200s'", | ||
| 590 | - Py_TYPE(arg)->tp_name); | ||
| 591 | - return NULL; | ||
| 592 | - } | ||
| 593 | - | ||
| 594 | 568 | if (size < 0) { | |
| 595 | 569 | PyErr_Format(PyExc_ValueError, | |
| 596 | 570 | "negative size value %zd", size); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -134,7 +134,7 @@ _io__Buffered_read(buffered *self, PyObject **args, Py_ssize_t nargs, PyObject * | |||
| 134 | 134 | Py_ssize_t n = -1; | |
| 135 | 135 | ||
| 136 | 136 | if (!_PyArg_ParseStack(args, nargs, "|O&:read", | |
| 137 | - _PyIO_ConvertSsize_t, &n)) { | ||
| 137 | + _Py_convert_optional_to_ssize_t, &n)) { | ||
| 138 | 138 | goto exit; | |
| 139 | 139 | } | |
| 140 | 140 | ||
@@ -258,7 +258,7 @@ _io__Buffered_readline(buffered *self, PyObject **args, Py_ssize_t nargs, PyObje | |||
| 258 | 258 | Py_ssize_t size = -1; | |
| 259 | 259 | ||
| 260 | 260 | if (!_PyArg_ParseStack(args, nargs, "|O&:readline", | |
| 261 | - _PyIO_ConvertSsize_t, &size)) { | ||
| 261 | + _Py_convert_optional_to_ssize_t, &size)) { | ||
| 262 | 262 | goto exit; | |
| 263 | 263 | } | |
| 264 | 264 | ||
@@ -500,4 +500,4 @@ _io_BufferedRandom___init__(PyObject *self, PyObject *args, PyObject *kwargs) | |||
| 500 | 500 | exit: | |
| 501 | 501 | return return_value; | |
| 502 | 502 | } | |
| 503 | - /*[clinic end generated code: output=e37b969b1acaa09c input=a9049054013a1b77]*/ | ||
| 503 | + /*[clinic end generated code: output=3cf3262c9b157dc1 input=a9049054013a1b77]*/ | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -170,7 +170,7 @@ _io_BytesIO_read(bytesio *self, PyObject **args, Py_ssize_t nargs, PyObject *kwn | |||
| 170 | 170 | Py_ssize_t size = -1; | |
| 171 | 171 | ||
| 172 | 172 | if (!_PyArg_ParseStack(args, nargs, "|O&:read", | |
| 173 | - _PyIO_ConvertSsize_t, &size)) { | ||
| 173 | + _Py_convert_optional_to_ssize_t, &size)) { | ||
| 174 | 174 | goto exit; | |
| 175 | 175 | } | |
| 176 | 176 | ||
@@ -205,7 +205,7 @@ _io_BytesIO_read1(bytesio *self, PyObject **args, Py_ssize_t nargs, PyObject *kw | |||
| 205 | 205 | Py_ssize_t size = -1; | |
| 206 | 206 | ||
| 207 | 207 | if (!_PyArg_ParseStack(args, nargs, "|O&:read1", | |
| 208 | - _PyIO_ConvertSsize_t, &size)) { | ||
| 208 | + _Py_convert_optional_to_ssize_t, &size)) { | ||
| 209 | 209 | goto exit; | |
| 210 | 210 | } | |
| 211 | 211 | ||
@@ -241,7 +241,7 @@ _io_BytesIO_readline(bytesio *self, PyObject **args, Py_ssize_t nargs, PyObject | |||
| 241 | 241 | Py_ssize_t size = -1; | |
| 242 | 242 | ||
| 243 | 243 | if (!_PyArg_ParseStack(args, nargs, "|O&:readline", | |
| 244 | - _PyIO_ConvertSsize_t, &size)) { | ||
| 244 | + _Py_convert_optional_to_ssize_t, &size)) { | ||
| 245 | 245 | goto exit; | |
| 246 | 246 | } | |
| 247 | 247 | ||
@@ -339,24 +339,23 @@ PyDoc_STRVAR(_io_BytesIO_truncate__doc__, | |||
| 339 | 339 | {"truncate", (PyCFunction)_io_BytesIO_truncate, METH_FASTCALL, _io_BytesIO_truncate__doc__}, | |
| 340 | 340 | ||
| 341 | 341 | static PyObject * | |
| 342 | - _io_BytesIO_truncate_impl(bytesio *self, PyObject *arg); | ||
| 342 | + _io_BytesIO_truncate_impl(bytesio *self, Py_ssize_t size); | ||
| 343 | 343 | ||
| 344 | 344 | static PyObject * | |
| 345 | 345 | _io_BytesIO_truncate(bytesio *self, PyObject **args, Py_ssize_t nargs, PyObject *kwnames) | |
| 346 | 346 | { | |
| 347 | 347 | PyObject *return_value = NULL; | |
| 348 | - PyObject *arg = Py_None; | ||
| 348 | + Py_ssize_t size = self->pos; | ||
| 349 | 349 | ||
| 350 | - if (!_PyArg_UnpackStack(args, nargs, "truncate", | ||
| 351 | - 0, 1, | ||
| 352 | - &arg)) { | ||
| 350 | + if (!_PyArg_ParseStack(args, nargs, "|O&:truncate", | ||
| 351 | + _Py_convert_optional_to_ssize_t, &size)) { | ||
| 353 | 352 | goto exit; | |
| 354 | 353 | } | |
| 355 | 354 | ||
| 356 | 355 | if (!_PyArg_NoStackKeywords("truncate", kwnames)) { | |
| 357 | 356 | goto exit; | |
| 358 | 357 | } | |
| 359 | - return_value = _io_BytesIO_truncate_impl(self, arg); | ||
| 358 | + return_value = _io_BytesIO_truncate_impl(self, size); | ||
| 360 | 359 | ||
| 361 | 360 | exit: | |
| 362 | 361 | return return_value; | |
@@ -469,4 +468,4 @@ _io_BytesIO___init__(PyObject *self, PyObject *args, PyObject *kwargs) | |||
| 469 | 468 | exit: | |
| 470 | 469 | return return_value; | |
| 471 | 470 | } | |
| 472 | - /*[clinic end generated code: output=74a856733a5d55b0 input=a9049054013a1b77]*/ | ||
| 471 | + /*[clinic end generated code: output=733795434f838b71 input=a9049054013a1b77]*/ | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -214,7 +214,7 @@ _io_FileIO_read(fileio *self, PyObject **args, Py_ssize_t nargs, PyObject *kwnam | |||
| 214 | 214 | Py_ssize_t size = -1; | |
| 215 | 215 | ||
| 216 | 216 | if (!_PyArg_ParseStack(args, nargs, "|O&:read", | |
| 217 | - _PyIO_ConvertSsize_t, &size)) { | ||
| 217 | + _Py_convert_optional_to_ssize_t, &size)) { | ||
| 218 | 218 | goto exit; | |
| 219 | 219 | } | |
| 220 | 220 | ||
@@ -385,4 +385,4 @@ _io_FileIO_isatty(fileio *self, PyObject *Py_UNUSED(ignored)) | |||
| 385 | 385 | #ifndef _IO_FILEIO_TRUNCATE_METHODDEF | |
| 386 | 386 | #define _IO_FILEIO_TRUNCATE_METHODDEF | |
| 387 | 387 | #endif /* !defined(_IO_FILEIO_TRUNCATE_METHODDEF) */ | |
| 388 | - /*[clinic end generated code: output=034d782a0daa82bd input=a9049054013a1b77]*/ | ||
| 388 | + /*[clinic end generated code: output=a4044e2d878248d0 input=a9049054013a1b77]*/ | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -186,7 +186,7 @@ _io__IOBase_readline(PyObject *self, PyObject **args, Py_ssize_t nargs, PyObject | |||
| 186 | 186 | Py_ssize_t limit = -1; | |
| 187 | 187 | ||
| 188 | 188 | if (!_PyArg_ParseStack(args, nargs, "|O&:readline", | |
| 189 | - _PyIO_ConvertSsize_t, &limit)) { | ||
| 189 | + _Py_convert_optional_to_ssize_t, &limit)) { | ||
| 190 | 190 | goto exit; | |
| 191 | 191 | } | |
| 192 | 192 | ||
@@ -222,7 +222,7 @@ _io__IOBase_readlines(PyObject *self, PyObject **args, Py_ssize_t nargs, PyObjec | |||
| 222 | 222 | Py_ssize_t hint = -1; | |
| 223 | 223 | ||
| 224 | 224 | if (!_PyArg_ParseStack(args, nargs, "|O&:readlines", | |
| 225 | - _PyIO_ConvertSsize_t, &hint)) { | ||
| 225 | + _Py_convert_optional_to_ssize_t, &hint)) { | ||
| 226 | 226 | goto exit; | |
| 227 | 227 | } | |
| 228 | 228 | ||
@@ -291,4 +291,4 @@ _io__RawIOBase_readall(PyObject *self, PyObject *Py_UNUSED(ignored)) | |||
| 291 | 291 | { | |
| 292 | 292 | return _io__RawIOBase_readall_impl(self); | |
| 293 | 293 | } | |
| 294 | - /*[clinic end generated code: output=1bcece367fc7b0cd input=a9049054013a1b77]*/ | ||
| 294 | + /*[clinic end generated code: output=d3f59c135231baae input=a9049054013a1b77]*/ | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -60,7 +60,7 @@ _io_StringIO_read(stringio *self, PyObject **args, Py_ssize_t nargs, PyObject *k | |||
| 60 | 60 | Py_ssize_t size = -1; | |
| 61 | 61 | ||
| 62 | 62 | if (!_PyArg_ParseStack(args, nargs, "|O&:read", | |
| 63 | - _PyIO_ConvertSsize_t, &size)) { | ||
| 63 | + _Py_convert_optional_to_ssize_t, &size)) { | ||
| 64 | 64 | goto exit; | |
| 65 | 65 | } | |
| 66 | 66 | ||
@@ -94,7 +94,7 @@ _io_StringIO_readline(stringio *self, PyObject **args, Py_ssize_t nargs, PyObjec | |||
| 94 | 94 | Py_ssize_t size = -1; | |
| 95 | 95 | ||
| 96 | 96 | if (!_PyArg_ParseStack(args, nargs, "|O&:readline", | |
| 97 | - _PyIO_ConvertSsize_t, &size)) { | ||
| 97 | + _Py_convert_optional_to_ssize_t, &size)) { | ||
| 98 | 98 | goto exit; | |
| 99 | 99 | } | |
| 100 | 100 | ||
@@ -121,24 +121,23 @@ PyDoc_STRVAR(_io_StringIO_truncate__doc__, | |||
| 121 | 121 | {"truncate", (PyCFunction)_io_StringIO_truncate, METH_FASTCALL, _io_StringIO_truncate__doc__}, | |
| 122 | 122 | ||
| 123 | 123 | static PyObject * | |
| 124 | - _io_StringIO_truncate_impl(stringio *self, PyObject *arg); | ||
| 124 | + _io_StringIO_truncate_impl(stringio *self, Py_ssize_t size); | ||
| 125 | 125 | ||
| 126 | 126 | static PyObject * | |
| 127 | 127 | _io_StringIO_truncate(stringio *self, PyObject **args, Py_ssize_t nargs, PyObject *kwnames) | |
| 128 | 128 | { | |
| 129 | 129 | PyObject *return_value = NULL; | |
| 130 | - PyObject *arg = Py_None; | ||
| 130 | + Py_ssize_t size = self->pos; | ||
| 131 | 131 | ||
| 132 | - if (!_PyArg_UnpackStack(args, nargs, "truncate", | ||
| 133 | - 0, 1, | ||
| 134 | - &arg)) { | ||
| 132 | + if (!_PyArg_ParseStack(args, nargs, "|O&:truncate", | ||
| 133 | + _Py_convert_optional_to_ssize_t, &size)) { | ||
| 135 | 134 | goto exit; | |
| 136 | 135 | } | |
| 137 | 136 | ||
| 138 | 137 | if (!_PyArg_NoStackKeywords("truncate", kwnames)) { | |
| 139 | 138 | goto exit; | |
| 140 | 139 | } | |
| 141 | - return_value = _io_StringIO_truncate_impl(self, arg); | ||
| 140 | + return_value = _io_StringIO_truncate_impl(self, size); | ||
| 142 | 141 | ||
| 143 | 142 | exit: | |
| 144 | 143 | return return_value; | |
@@ -303,4 +302,4 @@ _io_StringIO_seekable(stringio *self, PyObject *Py_UNUSED(ignored)) | |||
| 303 | 302 | { | |
| 304 | 303 | return _io_StringIO_seekable_impl(self); | |
| 305 | 304 | } | |
| 306 | - /*[clinic end generated code: output=965fe9cb0d11511a input=a9049054013a1b77]*/ | ||
| 305 | + /*[clinic end generated code: output=03429d95ed7cd92f input=a9049054013a1b77]*/ | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments