Skip to content

Commit d9d16ae

Browse files
cgohlkemgoacolou
authored andcommitted
Fix building Python integers from size_t values
Use the `n` format specifier instead of `l` to build Python integer or long integer objects from size_t values.
1 parent ea80948 commit d9d16ae

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/_image.cpp

+4-4
Original file line numberDiff line numberDiff line change
@@ -202,10 +202,10 @@ Image::as_rgba_str(const Py::Tuple& args, const Py::Dict& kwargs)
202202
std::pair<agg::int8u*, bool> bufpair = _get_output_buffer();
203203

204204
#if PY3K
205-
Py::Object ret = Py::asObject(Py_BuildValue("lly#", rowsOut, colsOut,
205+
Py::Object ret = Py::asObject(Py_BuildValue("nny#", rowsOut, colsOut,
206206
bufpair.first, colsOut * rowsOut * 4));
207207
#else
208-
Py::Object ret = Py::asObject(Py_BuildValue("lls#", rowsOut, colsOut,
208+
Py::Object ret = Py::asObject(Py_BuildValue("nns#", rowsOut, colsOut,
209209
bufpair.first, colsOut * rowsOut * 4));
210210
#endif
211211

@@ -272,7 +272,7 @@ Image::color_conv(const Py::Tuple& args)
272272
}
273273
#endif
274274

275-
PyObject* o = Py_BuildValue("llN", rowsOut, colsOut, py_buffer);
275+
PyObject* o = Py_BuildValue("nnN", rowsOut, colsOut, py_buffer);
276276
return Py::asObject(o);
277277
}
278278

@@ -290,7 +290,7 @@ Image::buffer_rgba(const Py::Tuple& args)
290290

291291
args.verify_length(0);
292292
int row_len = colsOut * 4;
293-
PyObject* o = Py_BuildValue("lls#", rowsOut, colsOut,
293+
PyObject* o = Py_BuildValue("nns#", rowsOut, colsOut,
294294
rbufOut, row_len * rowsOut);
295295
return Py::asObject(o);
296296
}

0 commit comments

Comments
 (0)