Skip to content

Commit b9f90ae

Browse files
Remove @deleter from setters which check for NULL themselves
They raised AttributeError for deletion, and this is now done by the generated code.
1 parent 8d93465 commit b9f90ae

8 files changed

Lines changed: 53 additions & 46 deletions

File tree

Modules/_asynciomodule.c

Lines changed: 4 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1372,23 +1372,18 @@ _asyncio_Future__asyncio_future_blocking_get_impl(FutureObj *self)
13721372
/*[clinic input]
13731373
@critical_section
13741374
@setter
1375-
@deleter
13761375
_asyncio.Future._asyncio_future_blocking
13771376
[clinic start generated code]*/
13781377

13791378
static int
13801379
_asyncio_Future__asyncio_future_blocking_set_impl(FutureObj *self,
13811380
PyObject *value)
1382-
/*[clinic end generated code: output=0686d1cb024a7453 input=68cea090c8793dd4]*/
1381+
/*[clinic end generated code: output=0686d1cb024a7453 input=3fd4a5f95df788b7]*/
13831382

13841383
{
13851384
if (future_ensure_alive(self)) {
13861385
return -1;
13871386
}
1388-
if (value == NULL) {
1389-
PyErr_SetString(PyExc_AttributeError, "cannot delete attribute");
1390-
return -1;
1391-
}
13921387

13931388
int is_true = PyObject_IsTrue(value);
13941389
if (is_true < 0) {
@@ -1421,18 +1416,13 @@ _asyncio_Future__log_traceback_get_impl(FutureObj *self)
14211416
/*[clinic input]
14221417
@critical_section
14231418
@setter
1424-
@deleter
14251419
_asyncio.Future._log_traceback
14261420
[clinic start generated code]*/
14271421

14281422
static int
14291423
_asyncio_Future__log_traceback_set_impl(FutureObj *self, PyObject *value)
1430-
/*[clinic end generated code: output=9ce8e19504f42f54 input=469dbdd15343d39f]*/
1424+
/*[clinic end generated code: output=9ce8e19504f42f54 input=30ac8217754b08c2]*/
14311425
{
1432-
if (value == NULL) {
1433-
PyErr_SetString(PyExc_AttributeError, "cannot delete attribute");
1434-
return -1;
1435-
}
14361426
int is_true = PyObject_IsTrue(value);
14371427
if (is_true < 0) {
14381428
return -1;
@@ -1587,18 +1577,13 @@ _asyncio_Future__cancel_message_get_impl(FutureObj *self)
15871577
/*[clinic input]
15881578
@critical_section
15891579
@setter
1590-
@deleter
15911580
_asyncio.Future._cancel_message
15921581
[clinic start generated code]*/
15931582

15941583
static int
15951584
_asyncio_Future__cancel_message_set_impl(FutureObj *self, PyObject *value)
1596-
/*[clinic end generated code: output=0854b2f77bff2209 input=68b3a24731dfb629]*/
1585+
/*[clinic end generated code: output=0854b2f77bff2209 input=f461d17f2d891fad]*/
15971586
{
1598-
if (value == NULL) {
1599-
PyErr_SetString(PyExc_AttributeError, "cannot delete attribute");
1600-
return -1;
1601-
}
16021587
Py_INCREF(value);
16031588
Py_XSETREF(self->fut_cancel_msg, value);
16041589
return 0;
@@ -2446,18 +2431,13 @@ _asyncio_Task__log_destroy_pending_get_impl(TaskObj *self)
24462431
/*[clinic input]
24472432
@critical_section
24482433
@setter
2449-
@deleter
24502434
_asyncio.Task._log_destroy_pending
24512435
[clinic start generated code]*/
24522436

24532437
static int
24542438
_asyncio_Task__log_destroy_pending_set_impl(TaskObj *self, PyObject *value)
2455-
/*[clinic end generated code: output=7ebc030bb92ec5ce input=31af83e8bf57ac6f]*/
2439+
/*[clinic end generated code: output=7ebc030bb92ec5ce input=49b759c97d1216a4]*/
24562440
{
2457-
if (value == NULL) {
2458-
PyErr_SetString(PyExc_AttributeError, "cannot delete attribute");
2459-
return -1;
2460-
}
24612441
int is_true = PyObject_IsTrue(value);
24622442
if (is_true < 0) {
24632443
return -1;

Modules/_ctypes/_ctypes.c

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1481,22 +1481,17 @@ class _ctypes.PyCArrayType_Type "CDataObject *" "clinic_state()->PyCArrayType_Ty
14811481
/*[clinic input]
14821482
@critical_section
14831483
@setter
1484-
@deleter
14851484
_ctypes.PyCArrayType_Type.raw
14861485
[clinic start generated code]*/
14871486

14881487
static int
14891488
_ctypes_PyCArrayType_Type_raw_set_impl(CDataObject *self, PyObject *value)
1490-
/*[clinic end generated code: output=cf9b2a9fd92e9ecb input=13881e1662127207]*/
1489+
/*[clinic end generated code: output=cf9b2a9fd92e9ecb input=a3717561efc45efd]*/
14911490
{
14921491
char *ptr;
14931492
Py_ssize_t size;
14941493
Py_buffer view;
14951494

1496-
if (value == NULL) {
1497-
PyErr_SetString(PyExc_AttributeError, "cannot delete attribute");
1498-
return -1;
1499-
}
15001495
if (PyObject_GetBuffer(value, &view, PyBUF_SIMPLE) < 0)
15011496
return -1;
15021497
size = view.len;

Modules/_ctypes/clinic/_ctypes.c.h

Lines changed: 7 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Modules/_io/clinic/textio.c.h

Lines changed: 7 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Modules/_io/textio.c

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3399,20 +3399,15 @@ _io_TextIOWrapper__CHUNK_SIZE_get_impl(textio *self)
33993399
/*[clinic input]
34003400
@critical_section
34013401
@setter
3402-
@deleter
34033402
_io.TextIOWrapper._CHUNK_SIZE
34043403
[clinic start generated code]*/
34053404

34063405
static int
34073406
_io_TextIOWrapper__CHUNK_SIZE_set_impl(textio *self, PyObject *value)
3408-
/*[clinic end generated code: output=edb86d2db660a5ab input=e7c44a734efeddc3]*/
3407+
/*[clinic end generated code: output=edb86d2db660a5ab input=32fc99861db02a0a]*/
34093408
{
34103409
Py_ssize_t n;
34113410
CHECK_ATTACHED_INT(self);
3412-
if (value == NULL) {
3413-
PyErr_SetString(PyExc_AttributeError, "cannot delete attribute");
3414-
return -1;
3415-
}
34163411
n = PyNumber_AsSsize_t(value, PyExc_ValueError);
34173412
if (n == -1 && PyErr_Occurred())
34183413
return -1;

Modules/clinic/_asynciomodule.c.h

Lines changed: 25 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Objects/clinic/frameobject.c.h

Lines changed: 7 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Objects/frameobject.c

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1643,19 +1643,14 @@ static bool frame_is_suspended(PyFrameObject *frame)
16431643
/*[clinic input]
16441644
@critical_section
16451645
@setter
1646-
@deleter
16471646
frame.f_lineno as frame_lineno
16481647
[clinic start generated code]*/
16491648

16501649
static int
16511650
frame_lineno_set_impl(PyFrameObject *self, PyObject *value)
1652-
/*[clinic end generated code: output=e64c86ff6be64292 input=c814c375c6bd16ba]*/
1651+
/*[clinic end generated code: output=e64c86ff6be64292 input=36ed3c896b27fb91]*/
16531652
{
16541653
PyCodeObject *code = _PyFrame_GetCode(self->f_frame);
1655-
if (value == NULL) {
1656-
PyErr_SetString(PyExc_AttributeError, "cannot delete attribute");
1657-
return -1;
1658-
}
16591654
/* f_lineno must be an integer. */
16601655
if (!PyLong_CheckExact(value)) {
16611656
PyErr_SetString(PyExc_ValueError,

0 commit comments

Comments
 (0)