mirror of
https://github.com/kovidgoyal/kitty
synced 2026-07-22 00:08:04 +02:00
Correct types for various PyArg_ParseTuple/Py_BuildValue calls
Debian's [mips] build failed one of the font tests:
FAIL: test_sprite_map (kitty_tests.fonts.Rendering)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/<<PKGBUILDDIR>>/kitty_tests/fonts.py", line 48, in test_sprite_map
self.ae(test_sprite_position_for(0, 1), (0, 1, 1))
self = <kitty_tests.fonts.Rendering testMethod=test_sprite_map>
AssertionError: Tuples differ: (0, 0, 0) != (0, 1, 1)
First differing element 1:
0
1
- (0, 0, 0)
? ^ ^
+ (0, 1, 1)
? ^ ^
This was due to test_sprite_position_for() using the "I" code to parse
into an unsigned short. Since mips is big endian, the "wrong" byte was
stored into extra_glyphs.data.
This commit changes all similar data type mismatches that were found
from auditing calls to PyArg_ParseTuple/Py_BuildValue.
[mips]: https://buildd.debian.org/status/fetch.php?pkg=kitty&arch=mips&ver=0.9.0-1&stamp=1524126606&raw=0
This commit is contained in:
@@ -873,9 +873,10 @@ new(PyTypeObject UNUSED *type, PyObject UNUSED *args, PyObject UNUSED *kwds) {
|
||||
static inline PyObject*
|
||||
image_as_dict(Image *img) {
|
||||
#define U(x) #x, img->x
|
||||
return Py_BuildValue("{sI sI sI sI sI sI sH sH sN}",
|
||||
U(texture_id), U(client_id), U(width), U(height), U(internal_id), U(refcnt), U(data_loaded),
|
||||
"is_4byte_aligned", img->load_data.is_4byte_aligned,
|
||||
return Py_BuildValue("{sI sI sI sI sI sI sO sO sN}",
|
||||
U(texture_id), U(client_id), U(width), U(height), U(internal_id), U(refcnt),
|
||||
"data_loaded", img->data_loaded ? Py_True : Py_False,
|
||||
"is_4byte_aligned", img->load_data.is_4byte_aligned ? Py_True : Py_False,
|
||||
"data", Py_BuildValue("y#", img->load_data.data, img->load_data.data_sz)
|
||||
);
|
||||
#undef U
|
||||
|
||||
Reference in New Issue
Block a user