@@ -1812,8 +1812,7 @@ delta_richcompare(PyObject *self, PyObject *other, int op)
18121812 return diff_to_bool (diff , op );
18131813 }
18141814 else {
1815- Py_INCREF (Py_NotImplemented );
1816- return Py_NotImplemented ;
1815+ Py_RETURN_NOTIMPLEMENTED ;
18171816 }
18181817}
18191818
@@ -1911,10 +1910,8 @@ delta_remainder(PyObject *left, PyObject *right)
19111910 PyObject * pyus_remainder ;
19121911 PyObject * remainder ;
19131912
1914- if (!PyDelta_Check (left ) || !PyDelta_Check (right )) {
1915- Py_INCREF (Py_NotImplemented );
1916- return Py_NotImplemented ;
1917- }
1913+ if (!PyDelta_Check (left ) || !PyDelta_Check (right ))
1914+ Py_RETURN_NOTIMPLEMENTED ;
19181915
19191916 pyus_left = delta_to_microseconds ((PyDateTime_Delta * )left );
19201917 if (pyus_left == NULL )
@@ -1949,10 +1946,8 @@ delta_divmod(PyObject *left, PyObject *right)
19491946 PyObject * delta ;
19501947 PyObject * result ;
19511948
1952- if (!PyDelta_Check (left ) || !PyDelta_Check (right )) {
1953- Py_INCREF (Py_NotImplemented );
1954- return Py_NotImplemented ;
1955- }
1949+ if (!PyDelta_Check (left ) || !PyDelta_Check (right ))
1950+ Py_RETURN_NOTIMPLEMENTED ;
19561951
19571952 pyus_left = delta_to_microseconds ((PyDateTime_Delta * )left );
19581953 if (pyus_left == NULL )
@@ -2546,10 +2541,9 @@ add_date_timedelta(PyDateTime_Date *date, PyDateTime_Delta *delta, int negate)
25462541static PyObject *
25472542date_add (PyObject * left , PyObject * right )
25482543{
2549- if (PyDateTime_Check (left ) || PyDateTime_Check (right )) {
2550- Py_INCREF (Py_NotImplemented );
2551- return Py_NotImplemented ;
2552- }
2544+ if (PyDateTime_Check (left ) || PyDateTime_Check (right ))
2545+ Py_RETURN_NOTIMPLEMENTED ;
2546+
25532547 if (PyDate_Check (left )) {
25542548 /* date + ??? */
25552549 if (PyDelta_Check (right ))
@@ -2568,17 +2562,15 @@ date_add(PyObject *left, PyObject *right)
25682562 (PyDateTime_Delta * ) left ,
25692563 0 );
25702564 }
2571- Py_INCREF (Py_NotImplemented );
2572- return Py_NotImplemented ;
2565+ Py_RETURN_NOTIMPLEMENTED ;
25732566}
25742567
25752568static PyObject *
25762569date_subtract (PyObject * left , PyObject * right )
25772570{
2578- if (PyDateTime_Check (left ) || PyDateTime_Check (right )) {
2579- Py_INCREF (Py_NotImplemented );
2580- return Py_NotImplemented ;
2581- }
2571+ if (PyDateTime_Check (left ) || PyDateTime_Check (right ))
2572+ Py_RETURN_NOTIMPLEMENTED ;
2573+
25822574 if (PyDate_Check (left )) {
25832575 if (PyDate_Check (right )) {
25842576 /* date - date */
@@ -2597,8 +2589,7 @@ date_subtract(PyObject *left, PyObject *right)
25972589 1 );
25982590 }
25992591 }
2600- Py_INCREF (Py_NotImplemented );
2601- return Py_NotImplemented ;
2592+ Py_RETURN_NOTIMPLEMENTED ;
26022593}
26032594
26042595
@@ -2715,10 +2706,8 @@ date_richcompare(PyObject *self, PyObject *other, int op)
27152706 _PyDateTime_DATE_DATASIZE );
27162707 return diff_to_bool (diff , op );
27172708 }
2718- else {
2719- Py_INCREF (Py_NotImplemented );
2720- return Py_NotImplemented ;
2721- }
2709+ else
2710+ Py_RETURN_NOTIMPLEMENTED ;
27222711}
27232712
27242713static PyObject *
@@ -3215,10 +3204,8 @@ static PyObject *
32153204timezone_richcompare (PyDateTime_TimeZone * self ,
32163205 PyDateTime_TimeZone * other , int op )
32173206{
3218- if (op != Py_EQ && op != Py_NE ) {
3219- Py_INCREF (Py_NotImplemented );
3220- return Py_NotImplemented ;
3221- }
3207+ if (op != Py_EQ && op != Py_NE )
3208+ Py_RETURN_NOTIMPLEMENTED ;
32223209 return delta_richcompare (self -> offset , other -> offset , op );
32233210}
32243211
@@ -3664,10 +3651,8 @@ time_richcompare(PyObject *self, PyObject *other, int op)
36643651 PyObject * offset1 , * offset2 ;
36653652 int diff ;
36663653
3667- if (! PyTime_Check (other )) {
3668- Py_INCREF (Py_NotImplemented );
3669- return Py_NotImplemented ;
3670- }
3654+ if (! PyTime_Check (other ))
3655+ Py_RETURN_NOTIMPLEMENTED ;
36713656
36723657 if (GET_TIME_TZINFO (self ) == GET_TIME_TZINFO (other )) {
36733658 diff = memcmp (((PyDateTime_Time * )self )-> data ,
@@ -4356,8 +4341,7 @@ datetime_add(PyObject *left, PyObject *right)
43564341 (PyDateTime_Delta * ) left ,
43574342 1 );
43584343 }
4359- Py_INCREF (Py_NotImplemented );
4360- return Py_NotImplemented ;
4344+ Py_RETURN_NOTIMPLEMENTED ;
43614345}
43624346
43634347static PyObject *
@@ -4559,8 +4543,7 @@ datetime_richcompare(PyObject *self, PyObject *other, int op)
45594543 Py_RETURN_TRUE ;
45604544 return cmperror (self , other );
45614545 }
4562- Py_INCREF (Py_NotImplemented );
4563- return Py_NotImplemented ;
4546+ Py_RETURN_NOTIMPLEMENTED ;
45644547 }
45654548
45664549 if (GET_DT_TZINFO (self ) == GET_DT_TZINFO (other )) {
0 commit comments