Skip to content

Commit f3b4511

Browse files
committed
MNT: Use Py_RETURN_NONE as appropriate
Simplifies things just a bit.
1 parent 6c77158 commit f3b4511

File tree

1 file changed

+18
-36
lines changed

1 file changed

+18
-36
lines changed

src/_macosx.m

Lines changed: 18 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -348,8 +348,7 @@ static CGFloat _get_device_scale(CGContextRef cr)
348348
[pool release];
349349
}
350350

351-
Py_INCREF(Py_None);
352-
return Py_None;
351+
Py_RETURN_NONE;
353352
}
354353

355354
static PyObject*
@@ -362,8 +361,7 @@ static CGFloat _get_device_scale(CGContextRef cr)
362361
return NULL;
363362
}
364363
[view setNeedsDisplay: YES];
365-
Py_INCREF(Py_None);
366-
return Py_None;
364+
Py_RETURN_NONE;
367365
}
368366

369367
static PyObject*
@@ -376,8 +374,7 @@ static CGFloat _get_device_scale(CGContextRef cr)
376374
return NULL;
377375
}
378376
[view displayIfNeeded];
379-
Py_INCREF(Py_None);
380-
return Py_None;
377+
Py_RETURN_NONE;
381378
}
382379

383380
static PyObject*
@@ -420,8 +417,7 @@ static CGFloat _get_device_scale(CGContextRef cr)
420417
}
421418

422419
[view setRubberband: rubberband];
423-
Py_INCREF(Py_None);
424-
return Py_None;
420+
Py_RETURN_NONE;
425421
}
426422

427423
static PyObject*
@@ -434,8 +430,7 @@ static CGFloat _get_device_scale(CGContextRef cr)
434430
return NULL;
435431
}
436432
[view removeRubberband];
437-
Py_INCREF(Py_None);
438-
return Py_None;
433+
Py_RETURN_NONE;
439434
}
440435

441436
static NSImage* _read_ppm_image(PyObject* obj)
@@ -546,8 +541,7 @@ static CGFloat _get_device_scale(CGContextRef cr)
546541
if (error==0) close(channel[1]);
547542
if (interrupted) raise(SIGINT);
548543

549-
Py_INCREF(Py_None);
550-
return Py_None;
544+
Py_RETURN_NONE;
551545
}
552546

553547
static PyObject*
@@ -563,8 +557,7 @@ static CGFloat _get_device_scale(CGContextRef cr)
563557
data1: 0
564558
data2: 0];
565559
[NSApp postEvent: event atStart: true];
566-
Py_INCREF(Py_None);
567-
return Py_None;
560+
Py_RETURN_NONE;
568561
}
569562

570563
static PyMethodDef FigureCanvas_methods[] = {
@@ -770,8 +763,7 @@ static CGFloat _get_device_scale(CGContextRef cr)
770763
[window orderFrontRegardless];
771764
[pool release];
772765
}
773-
Py_INCREF(Py_None);
774-
return Py_None;
766+
Py_RETURN_NONE;
775767
}
776768

777769
static PyObject*
@@ -785,8 +777,7 @@ static CGFloat _get_device_scale(CGContextRef cr)
785777
[pool release];
786778
self->window = NULL;
787779
}
788-
Py_INCREF(Py_None);
789-
return Py_None;
780+
Py_RETURN_NONE;
790781
}
791782

792783
static PyObject*
@@ -808,8 +799,7 @@ static CGFloat _get_device_scale(CGContextRef cr)
808799
[pool release];
809800
}
810801
PyMem_Free(title);
811-
Py_INCREF(Py_None);
812-
return Py_None;
802+
Py_RETURN_NONE;
813803
}
814804

815805
static PyObject*
@@ -830,8 +820,7 @@ static CGFloat _get_device_scale(CGContextRef cr)
830820
if (result) {
831821
return result;
832822
} else {
833-
Py_INCREF(Py_None);
834-
return Py_None;
823+
Py_RETURN_NONE;
835824
}
836825
}
837826

@@ -1280,8 +1269,7 @@ -(void)save_figure:(id)sender
12801269
[button setEnabled: YES];
12811270
}
12821271
[pool release];
1283-
Py_INCREF(Py_None);
1284-
return Py_None;
1272+
Py_RETURN_NONE;
12851273
}
12861274

12871275
static PyObject*
@@ -1783,8 +1771,7 @@ -(void)save_figure:(id)sender
17831771
[pool release];
17841772
}
17851773

1786-
Py_INCREF(Py_None);
1787-
return Py_None;
1774+
Py_RETURN_NONE;
17881775
}
17891776

17901777
static PyMethodDef NavigationToolbar2_methods[] = {
@@ -1888,8 +1875,7 @@ -(void)save_figure:(id)sender
18881875
free(buffer);
18891876
return string;
18901877
}
1891-
Py_INCREF(Py_None);
1892-
return Py_None;
1878+
Py_RETURN_NONE;
18931879
}
18941880

18951881
static PyObject*
@@ -1906,8 +1892,7 @@ -(void)save_figure:(id)sender
19061892
case 4: break;
19071893
default: return NULL;
19081894
}
1909-
Py_INCREF(Py_None);
1910-
return Py_None;
1895+
Py_RETURN_NONE;
19111896
}
19121897

19131898
@implementation WindowServerConnectionManager
@@ -2845,8 +2830,7 @@ - (int)index
28452830
Py_BEGIN_ALLOW_THREADS
28462831
[NSApp run];
28472832
Py_END_ALLOW_THREADS
2848-
Py_INCREF(Py_None);
2849-
return Py_None;
2833+
Py_RETURN_NONE;
28502834
}
28512835

28522836
typedef struct {
@@ -2971,8 +2955,7 @@ static void context_cleanup(const void* info)
29712955
* the timer lost before we have a chance to decrease the reference count
29722956
* of the attribute */
29732957
self->timer = timer;
2974-
Py_INCREF(Py_None);
2975-
return Py_None;
2958+
Py_RETURN_NONE;
29762959
}
29772960

29782961
static PyObject*
@@ -2983,8 +2966,7 @@ static void context_cleanup(const void* info)
29832966
CFRelease(self->timer);
29842967
self->timer = NULL;
29852968
}
2986-
Py_INCREF(Py_None);
2987-
return Py_None;
2969+
Py_RETURN_NONE;
29882970
}
29892971

29902972
static void

0 commit comments

Comments
 (0)