On Mon, Feb 03, 2014 at 08:11:35PM +0100, Hilko Bengen wrote:
This fixes Github issue #2 reported by "kupiakos".
<
https://github.com/libguestfs/hivex/issues/2>
Thanks for fixing this.
To the reporter: It's the first time I've seen this bug report.
Github doesn't seem to generate any message when an issue is filed (or
if it does, it went to a spam folder somewhere) and you should use
https://bugzilla.redhat.com for bug reports for hivex/libguestfs.
generator/generator.ml | 2 +-
python/t/210-setvalue.py | 26 +++++++++++++++++---------
2 files changed, 18 insertions(+), 10 deletions(-)
diff --git a/generator/generator.ml b/generator/generator.ml
index 908c5f3..02aaf12 100755
--- a/generator/generator.ml
+++ b/generator/generator.ml
@@ -2981,7 +2981,7 @@ put_val_type (char *val, size_t len, hive_type t)
{
PyObject *r = PyTuple_New (2);
PyTuple_SetItem (r, 0, PyLong_FromLong ((long) t));
- PyTuple_SetItem (r, 1, PyUnicode_DecodeUTF8 (val, len, NULL));
+ PyTuple_SetItem (r, 1, PyBytes_FromStringAndSize (val, len));
return r;
}
diff --git a/python/t/210-setvalue.py b/python/t/210-setvalue.py
index 2ee7ac5..8e7ed5c 100644
--- a/python/t/210-setvalue.py
+++ b/python/t/210-setvalue.py
@@ -19,6 +19,14 @@ import sys
import os
import hivex
+if sys.version >= '3':
+ import codecs
+ def b(x):
+ return codecs.encode(x)
+else:
+ def b(x):
+ return x
+
srcdir = os.environ["srcdir"]
if not srcdir:
srcdir = "."
@@ -32,27 +40,27 @@ assert root
h.node_add_child (root, "B")
-b = h.node_get_child (root, "B")
-assert b
+B = h.node_get_child (root, "B")
+assert B
values = [
{ "key": "Key1", "t": 3, "value":
"ABC" },
{ "key": "Key2", "t": 3, "value":
"DEF" }
]
-h.node_set_values (b, values)
+h.node_set_values (B, values)
value1 = { "key": "Key3", "t": 3, "value":
"GHI" }
-h.node_set_value (b, value1)
+h.node_set_value (B, value1)
value1 = { "key": "Key1", "t": 3, "value":
"JKL" }
-h.node_set_value (b, value1)
+h.node_set_value (B, value1)
-val = h.node_get_value (b, "Key1")
+val = h.node_get_value (B, "Key1")
t_data = h.value_value (val)
assert t_data[0] == 3
-assert t_data[1] == "JKL"
+assert t_data[1] == b("JKL")
-val = h.node_get_value (b, "Key3")
+val = h.node_get_value (B, "Key3")
t_data = h.value_value (val)
assert t_data[0] == 3
-assert t_data[1] == "GHI"
+assert t_data[1] == b("GHI")
ACK.
Rich.
--
Richard Jones, Virtualization Group, Red Hat
http://people.redhat.com/~rjones
virt-df lists disk usage of guests without needing to install any
software inside the virtual machine. Supports Linux and Windows.
http://people.redhat.com/~rjones/virt-df/