Skip to content

Commit 192f67e

Browse files
mdboomddale
authored andcommitted
Fix compilation in Python 2.x
svn path=/branches/py3k/; revision=8556
1 parent 9e2805a commit 192f67e

3 files changed

Lines changed: 12 additions & 10 deletions

File tree

setupext.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -134,8 +134,10 @@
134134

135135
defines = [
136136
('PY_ARRAY_UNIQUE_SYMBOL', 'MPL_ARRAY_API'),
137-
('PYCXX_ISO_CPP_LIB', '1'),
138-
('PYCXX_PYTHON_2TO3', '1')]
137+
('PYCXX_ISO_CPP_LIB', '1')]
138+
139+
if sys.hexversion >= 0x03000000:
140+
defines.append(('PYCXX_PYTHON_2TO3', '1'))
139141

140142
setup_cfg = os.environ.get('MPLSETUPCFG', 'setup.cfg')
141143
# Based on the contents of setup.cfg, determine the build options

src/_backend_agg.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ void
212212
GCAgg::_set_antialiased(const Py::Object& gc)
213213
{
214214
_VERBOSE("GCAgg::antialiased");
215-
isaa = gc.getAttr("_antialiased").as_bool();
215+
isaa = Py::Boolean(gc.getAttr("_antialiased"));
216216
}
217217

218218

@@ -1521,7 +1521,7 @@ RendererAgg::_draw_path_collection_generic
15211521

15221522
if (check_snap)
15231523
{
1524-
gc.isaa = antialiaseds[i % Naa].as_bool();
1524+
gc.isaa = Py::Boolean(antialiaseds[i % Naa]);
15251525

15261526
transformed_path_t tpath(path, trans);
15271527
nan_removed_t nan_removed(tpath, true, has_curves);
@@ -1540,7 +1540,7 @@ RendererAgg::_draw_path_collection_generic
15401540
}
15411541
else
15421542
{
1543-
gc.isaa = antialiaseds[i % Naa].as_bool();
1543+
gc.isaa = Py::Boolean(antialiaseds[i % Naa]);
15441544

15451545
transformed_path_t tpath(path, trans);
15461546
nan_removed_t nan_removed(tpath, true, has_curves);
@@ -1753,8 +1753,8 @@ RendererAgg::draw_quad_mesh(const Py::Tuple& args)
17531753
Py::Object offsets_obj = args[5];
17541754
agg::trans_affine offset_trans = py_to_agg_transformation_matrix(args[6].ptr());
17551755
Py::Object facecolors_obj = args[7];
1756-
bool antialiased = args[8].as_bool();
1757-
bool showedges = args[9].as_bool();
1756+
bool antialiased = Py::Boolean(args[8]);
1757+
bool showedges = Py::Boolean(args[9]);
17581758
bool free_edgecolors = false;
17591759

17601760
QuadMeshGenerator path_generator(mesh_width, mesh_height, coordinates.ptr());

src/_path.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -385,7 +385,7 @@ _path_module::update_path_extents(const Py::Tuple& args)
385385
"Must pass Bbox object as arg 3 of update_path_extents");
386386
}
387387
Py::Object minpos_obj = args[3];
388-
bool ignore = args[4].as_bool();
388+
bool ignore = Py::Boolean(args[4]);
389389

390390
double xm, ym;
391391
PyArrayObject* input_minpos = NULL;
@@ -605,7 +605,7 @@ _path_module::point_in_path_collection(const Py::Tuple& args)
605605
Py::SeqBase<Py::Object> transforms_obj = args[5];
606606
Py::SeqBase<Py::Object> offsets_obj = args[6];
607607
agg::trans_affine offset_trans = py_to_agg_transformation_matrix(args[7].ptr());
608-
bool filled = args[8].as_bool();
608+
bool filled = Py::Boolean(args[8]);
609609

610610
PyArrayObject* offsets = (PyArrayObject*)PyArray_FromObject(
611611
offsets_obj.ptr(), PyArray_DOUBLE, 0, 2);
@@ -934,7 +934,7 @@ _path_module::clip_path_to_rect(const Py::Tuple &args)
934934

935935
PathIterator path(args[0]);
936936
Py::Object bbox_obj = args[1];
937-
bool inside = args[2].as_bool();
937+
bool inside = Py::Boolean(args[2]);
938938

939939
double x0, y0, x1, y1;
940940
if (!py_convert_bbox(bbox_obj.ptr(), x0, y0, x1, y1))

0 commit comments

Comments
 (0)