mirror of
https://github.com/dgibson/dtc.git
synced 2026-04-11 16:37:42 -04:00
pylibfdt: Proper handling of bytes/unicode strings and octal literals
Signed-off-by: Lumir Balhar <lbalhar@redhat.com> Message-Id: <20190218164856.23861-1-frenzy@frenzy.cz> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
This commit is contained in:
parent
78e113e81c
commit
4b68c6b360
2 changed files with 21 additions and 13 deletions
|
|
@ -669,7 +669,7 @@ class Fdt(FdtRo):
|
|||
Raises:
|
||||
FdtException if no parent found or other error occurs
|
||||
"""
|
||||
val = val.encode('utf-8') + '\0'
|
||||
val = val.encode('utf-8') + b'\0'
|
||||
return check_err(fdt_setprop(self._fdt, nodeoffset, prop_name,
|
||||
val, len(val)), quiet)
|
||||
|
||||
|
|
@ -1074,12 +1074,20 @@ typedef uint32_t fdt32_t;
|
|||
if (!$1)
|
||||
$result = Py_None;
|
||||
else
|
||||
$result = Py_BuildValue("s#", $1, *arg4);
|
||||
%#if PY_VERSION_HEX >= 0x03000000
|
||||
$result = Py_BuildValue("y#", $1, *arg4);
|
||||
%#else
|
||||
$result = Py_BuildValue("s#", $1, *arg4);
|
||||
%#endif
|
||||
}
|
||||
|
||||
/* typemap used for fdt_setprop() */
|
||||
%typemap(in) (const void *val) {
|
||||
$1 = PyString_AsString($input); /* char *str */
|
||||
%#if PY_VERSION_HEX >= 0x03000000
|
||||
$1 = PyBytes_AsString($input);
|
||||
%#else
|
||||
$1 = PyString_AsString($input); /* char *str */
|
||||
%#endif
|
||||
}
|
||||
|
||||
/* typemaps used for fdt_next_node() */
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue