pylibfdt: Test fdt.setprop take bytes on Python 3, add error handling

Signed-off-by: Petr Viktorin <pviktori@redhat.com>
Message-Id: <20190218164856.23861-3-frenzy@frenzy.cz>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
This commit is contained in:
Petr Viktorin
2019-02-18 17:48:54 +01:00
committed by David Gibson
parent cb0f454f73
commit 364631626b
2 changed files with 11 additions and 5 deletions

View File

@@ -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 */