diff options
author | Lumir Balhar <lbalhar@redhat.com> | 2019-02-18 17:48:52 +0100 |
---|---|---|
committer | David Gibson <david@gibson.dropbear.id.au> | 2019-02-19 13:43:27 +1100 |
commit | 4b68c6b3605ac3ef47e1594c0cde415f6f286134 (patch) | |
tree | f09cf36e1c4fda50b58b893e947bcf87891c66b7 /pylibfdt/libfdt.i | |
parent | 78e113e81c9d33d0f33704b187a46399d5a75419 (diff) | |
download | dtc-4b68c6b3605ac3ef47e1594c0cde415f6f286134.zip dtc-4b68c6b3605ac3ef47e1594c0cde415f6f286134.tar.gz dtc-4b68c6b3605ac3ef47e1594c0cde415f6f286134.tar.bz2 |
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>
Diffstat (limited to 'pylibfdt/libfdt.i')
-rw-r--r-- | pylibfdt/libfdt.i | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/pylibfdt/libfdt.i b/pylibfdt/libfdt.i index 462b5b0..6f1f1dc 100644 --- a/pylibfdt/libfdt.i +++ b/pylibfdt/libfdt.i @@ -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() */ |