From 364631626bb78a40c1a1c70d5502ab0e953a7829 Mon Sep 17 00:00:00 2001 From: Petr Viktorin Date: Mon, 18 Feb 2019 17:48:54 +0100 Subject: pylibfdt: Test fdt.setprop take bytes on Python 3, add error handling Signed-off-by: Petr Viktorin Message-Id: <20190218164856.23861-3-frenzy@frenzy.cz> Signed-off-by: David Gibson --- pylibfdt/libfdt.i | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'pylibfdt') diff --git a/pylibfdt/libfdt.i b/pylibfdt/libfdt.i index 084bc5b..4f14403 100644 --- a/pylibfdt/libfdt.i +++ b/pylibfdt/libfdt.i @@ -1084,6 +1084,10 @@ typedef uint32_t fdt32_t; /* typemap used for fdt_setprop() */ %typemap(in) (const void *val) { %#if PY_VERSION_HEX >= 0x03000000 + if (!PyBytes_Check($input)) { + SWIG_exception_fail(SWIG_TypeError, "bytes expected in method '" "$symname" + "', argument " "$argnum"" of type '" "$type""'"); + } $1 = PyBytes_AsString($input); %#else $1 = PyString_AsString($input); /* char *str */ -- cgit v1.1