Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 14124a5

Browse filesBrowse files
committed
Remove C checks for PY3K macro.
1 parent 919bc86 commit 14124a5
Copy full SHA for 14124a5
Expand file treeCollapse file tree

12 files changed

+26
-289
lines changed

‎lib/matplotlib/tri/_tri_wrapper.cpp

Copy file name to clipboardExpand all lines: lib/matplotlib/tri/_tri_wrapper.cpp
+4-20Lines changed: 4 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -494,7 +494,6 @@ static PyTypeObject* PyTrapezoidMapTriFinder_init_type(PyObject* m, PyTypeObject
494494

495495
extern "C" {
496496

497-
#if PY3K
498497
static struct PyModuleDef moduledef = {
499498
PyModuleDef_HEAD_INIT,
500499
"_tri",
@@ -507,44 +506,29 @@ static struct PyModuleDef moduledef = {
507506
NULL
508507
};
509508

510-
#define INITERROR return NULL
511-
512509
PyMODINIT_FUNC PyInit__tri(void)
513-
514-
#else
515-
#define INITERROR return
516-
517-
PyMODINIT_FUNC init_tri(void)
518-
#endif
519-
520510
{
521511
PyObject *m;
522512

523-
#if PY3K
524513
m = PyModule_Create(&moduledef);
525-
#else
526-
m = Py_InitModule3("_tri", NULL, NULL);
527-
#endif
528514

529515
if (m == NULL) {
530-
INITERROR;
516+
return NULL;
531517
}
532518

533519
if (!PyTriangulation_init_type(m, &PyTriangulationType)) {
534-
INITERROR;
520+
return NULL;
535521
}
536522
if (!PyTriContourGenerator_init_type(m, &PyTriContourGeneratorType)) {
537-
INITERROR;
523+
return NULL;
538524
}
539525
if (!PyTrapezoidMapTriFinder_init_type(m, &PyTrapezoidMapTriFinderType)) {
540-
INITERROR;
526+
return NULL;
541527
}
542528

543529
import_array();
544530

545-
#if PY3K
546531
return m;
547-
#endif
548532
}
549533

550534
} // extern "C"

‎src/_backend_agg_wrapper.cpp

Copy file name to clipboardExpand all lines: src/_backend_agg_wrapper.cpp
+3-24Lines changed: 3 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -586,13 +586,8 @@ PyRendererAgg_get_content_extents(PyRendererAgg *self, PyObject *args, PyObject
586586

587587
static PyObject *PyRendererAgg_buffer_rgba(PyRendererAgg *self, PyObject *args, PyObject *kwds)
588588
{
589-
#if PY3K
590589
return PyBytes_FromStringAndSize((const char *)self->x->pixBuffer,
591590
self->x->get_width() * self->x->get_height() * 4);
592-
#else
593-
return PyBuffer_FromReadWriteMemory(self->x->pixBuffer,
594-
self->x->get_width() * self->x->get_height() * 4);
595-
#endif
596591
}
597592

598593
int PyRendererAgg_get_buffer(PyRendererAgg *self, Py_buffer *buf, int flags)
@@ -724,7 +719,6 @@ static PyTypeObject *PyRendererAgg_init_type(PyObject *m, PyTypeObject *type)
724719

725720
extern "C" {
726721

727-
#if PY3K
728722
static struct PyModuleDef moduledef = {
729723
PyModuleDef_HEAD_INIT,
730724
"_backend_agg",
@@ -737,42 +731,27 @@ static struct PyModuleDef moduledef = {
737731
NULL
738732
};
739733

740-
#define INITERROR return NULL
741-
742734
PyMODINIT_FUNC PyInit__backend_agg(void)
743-
744-
#else
745-
#define INITERROR return
746-
747-
PyMODINIT_FUNC init_backend_agg(void)
748-
#endif
749-
750735
{
751736
PyObject *m;
752737

753-
#if PY3K
754738
m = PyModule_Create(&moduledef);
755-
#else
756-
m = Py_InitModule3("_backend_agg", NULL, NULL);
757-
#endif
758739

759740
if (m == NULL) {
760-
INITERROR;
741+
return NULL;
761742
}
762743

763744
import_array();
764745

765746
if (!PyRendererAgg_init_type(m, &PyRendererAggType)) {
766-
INITERROR;
747+
return NULL;
767748
}
768749

769750
if (!PyBufferRegion_init_type(m, &PyBufferRegionType)) {
770-
INITERROR;
751+
return NULL;
771752
}
772753

773-
#if PY3K
774754
return m;
775-
#endif
776755
}
777756

778757
} // extern "C"

‎src/_contour_wrapper.cpp

Copy file name to clipboardExpand all lines: src/_contour_wrapper.cpp
+2-18Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,6 @@ static PyTypeObject* PyQuadContourGenerator_init_type(PyObject* m, PyTypeObject*
154154

155155
extern "C" {
156156

157-
#if PY3K
158157
static struct PyModuleDef moduledef = {
159158
PyModuleDef_HEAD_INIT,
160159
"_contour",
@@ -167,38 +166,23 @@ static struct PyModuleDef moduledef = {
167166
NULL
168167
};
169168

170-
#define INITERROR return NULL
171-
172169
PyMODINIT_FUNC PyInit__contour(void)
173-
174-
#else
175-
#define INITERROR return
176-
177-
PyMODINIT_FUNC init_contour(void)
178-
#endif
179-
180170
{
181171
PyObject *m;
182172

183-
#if PY3K
184173
m = PyModule_Create(&moduledef);
185-
#else
186-
m = Py_InitModule3("_contour", NULL, NULL);
187-
#endif
188174

189175
if (m == NULL) {
190-
INITERROR;
176+
return NULL;
191177
}
192178

193179
if (!PyQuadContourGenerator_init_type(m, &PyQuadContourGeneratorType)) {
194-
INITERROR;
180+
return NULL;
195181
}
196182

197183
import_array();
198184

199-
#if PY3K
200185
return m;
201-
#endif
202186
}
203187

204188
} // extern "C"

‎src/_image_wrapper.cpp

Copy file name to clipboardExpand all lines: src/_image_wrapper.cpp
+2-18Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -437,7 +437,6 @@ static PyMethodDef module_functions[] = {
437437

438438
extern "C" {
439439

440-
#if PY3K
441440
static struct PyModuleDef moduledef = {
442441
PyModuleDef_HEAD_INIT,
443442
"_image",
@@ -450,27 +449,14 @@ static struct PyModuleDef moduledef = {
450449
NULL
451450
};
452451

453-
#define INITERROR return NULL
454-
455452
PyMODINIT_FUNC PyInit__image(void)
456-
457-
#else
458-
#define INITERROR return
459-
460-
PyMODINIT_FUNC init_image(void)
461-
#endif
462-
463453
{
464454
PyObject *m;
465455

466-
#if PY3K
467456
m = PyModule_Create(&moduledef);
468-
#else
469-
m = Py_InitModule3("_image", module_functions, NULL);
470-
#endif
471457

472458
if (m == NULL) {
473-
INITERROR;
459+
return NULL;
474460
}
475461

476462
if (PyModule_AddIntConstant(m, "NEAREST", NEAREST) ||
@@ -491,14 +477,12 @@ PyMODINIT_FUNC init_image(void)
491477
PyModule_AddIntConstant(m, "LANCZOS", LANCZOS) ||
492478
PyModule_AddIntConstant(m, "BLACKMAN", BLACKMAN) ||
493479
PyModule_AddIntConstant(m, "_n_interpolation", _n_interpolation)) {
494-
INITERROR;
480+
return NULL;
495481
}
496482

497483
import_array();
498484

499-
#if PY3K
500485
return m;
501-
#endif
502486
}
503487

504488
} // extern "C"

‎src/_macosx.m

Copy file name to clipboardExpand all lines: src/_macosx.m
+1-63Lines changed: 1 addition & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,6 @@
55

66
#define PYOSINPUTHOOK_REPETITIVE 1 /* Remove this once Python is fixed */
77

8-
#if PY_MAJOR_VERSION >= 3
9-
#define PY3K 1
10-
#else
11-
#define PY3K 0
12-
#endif
13-
148
/* Proper way to check for the OS X version we are compiling for, from
159
http://developer.apple.com/documentation/DeveloperTools/Conceptual/cross_development */
1610
#if __MAC_OS_X_VERSION_MIN_REQUIRED >= 1060
@@ -325,13 +319,8 @@ static CGFloat _get_device_scale(CGContextRef cr)
325319
static PyObject*
326320
FigureCanvas_repr(FigureCanvas* self)
327321
{
328-
#if PY3K
329322
return PyUnicode_FromFormat("FigureCanvas object %p wrapping NSView %p",
330323
(void*)self, (void*)(self->view));
331-
#else
332-
return PyString_FromFormat("FigureCanvas object %p wrapping NSView %p",
333-
(void*)self, (void*)(self->view));
334-
#endif
335324
}
336325

337326
static PyObject*
@@ -730,13 +719,8 @@ static CGFloat _get_device_scale(CGContextRef cr)
730719
static PyObject*
731720
FigureManager_repr(FigureManager* self)
732721
{
733-
#if PY3K
734722
return PyUnicode_FromFormat("FigureManager object %p wrapping NSWindow %p",
735723
(void*) self, (void*)(self->window));
736-
#else
737-
return PyString_FromFormat("FigureManager object %p wrapping NSWindow %p",
738-
(void*) self, (void*)(self->window));
739-
#endif
740724
}
741725

742726
static void
@@ -1197,11 +1181,7 @@ -(void)save_figure:(id)sender
11971181
static PyObject*
11981182
NavigationToolbar_repr(NavigationToolbar* self)
11991183
{
1200-
#if PY3K
12011184
return PyUnicode_FromFormat("NavigationToolbar object %p", (void*)self);
1202-
#else
1203-
return PyString_FromFormat("NavigationToolbar object %p", (void*)self);
1204-
#endif
12051185
}
12061186

12071187
static char NavigationToolbar_doc[] =
@@ -1743,11 +1723,7 @@ -(void)save_figure:(id)sender
17431723
static PyObject*
17441724
NavigationToolbar2_repr(NavigationToolbar2* self)
17451725
{
1746-
#if PY3K
17471726
return PyUnicode_FromFormat("NavigationToolbar2 object %p", (void*)self);
1748-
#else
1749-
return PyString_FromFormat("NavigationToolbar2 object %p", (void*)self);
1750-
#endif
17511727
}
17521728

17531729
static char NavigationToolbar2_doc[] =
@@ -1758,11 +1734,7 @@ -(void)save_figure:(id)sender
17581734
{
17591735
const char* message;
17601736

1761-
#if PY3K
17621737
if(!PyArg_ParseTuple(args, "y", &message)) return NULL;
1763-
#else
1764-
if(!PyArg_ParseTuple(args, "s", &message)) return NULL;
1765-
#endif
17661738

17671739
NSText* messagebox = self->messagebox;
17681740

@@ -1869,11 +1841,7 @@ -(void)save_figure:(id)sender
18691841
unsigned int n = [filename length];
18701842
unichar* buffer = malloc(n*sizeof(unichar));
18711843
[filename getCharacters: buffer];
1872-
#if PY3K
1873-
PyObject* string = PyUnicode_FromKindAndData(PyUnicode_2BYTE_KIND, buffer, n);
1874-
#else
1875-
PyObject* string = PyUnicode_FromUnicode(buffer, n);
1876-
#endif
1844+
PyObject* string = PyUnicode_FromKindAndData(PyUnicode_2BYTE_KIND, buffer, n);
18771845
free(buffer);
18781846
return string;
18791847
}
@@ -2855,13 +2823,8 @@ - (int)index
28552823
static PyObject*
28562824
Timer_repr(Timer* self)
28572825
{
2858-
#if PY3K
28592826
return PyUnicode_FromFormat("Timer object %p wrapping CFRunLoopTimerRef %p",
28602827
(void*) self, (void*)(self->timer));
2861-
#else
2862-
return PyString_FromFormat("Timer object %p wrapping CFRunLoopTimerRef %p",
2863-
(void*) self, (void*)(self->timer));
2864-
#endif
28652828
}
28662829

28672830
static char Timer_doc[] =
@@ -3092,8 +3055,6 @@ static bool verify_framework(void)
30923055
{NULL, NULL, 0, NULL}/* sentinel */
30933056
};
30943057

3095-
#if PY3K
3096-
30973058
static struct PyModuleDef moduledef = {
30983059
PyModuleDef_HEAD_INIT,
30993060
"_macosx",
@@ -3107,11 +3068,6 @@ static bool verify_framework(void)
31073068
};
31083069

31093070
PyObject* PyInit__macosx(void)
3110-
3111-
#else
3112-
3113-
void init_macosx(void)
3114-
#endif
31153071
{
31163072
PyObject *module;
31173073

@@ -3120,31 +3076,15 @@ void init_macosx(void)
31203076
|| PyType_Ready(&NavigationToolbarType) < 0
31213077
|| PyType_Ready(&NavigationToolbar2Type) < 0
31223078
|| PyType_Ready(&TimerType) < 0)
3123-
#if PY3K
31243079
return NULL;
3125-
#else
3126-
return;
3127-
#endif
31283080

31293081
NSApp = [NSApplication sharedApplication];
31303082

31313083
if (!verify_framework())
3132-
#if PY3K
31333084
return NULL;
3134-
#else
3135-
return;
3136-
#endif
31373085

3138-
#if PY3K
31393086
module = PyModule_Create(&moduledef);
31403087
if (module==NULL) return NULL;
3141-
#else
3142-
module = Py_InitModule4("_macosx",
3143-
methods,
3144-
"Mac OS X native backend",
3145-
NULL,
3146-
PYTHON_API_VERSION);
3147-
#endif
31483088

31493089
Py_INCREF(&FigureCanvasType);
31503090
Py_INCREF(&FigureManagerType);
@@ -3168,7 +3108,5 @@ void init_macosx(void)
31683108
name: NSWorkspaceDidLaunchApplicationNotification
31693109
object: nil];
31703110
[pool release];
3171-
#if PY3K
31723111
return module;
3173-
#endif
31743112
}

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.