Repository: opendilab/treevalue (language: python)

Issue:
Error when setting a raw-wrapped value
```
>>> from treevalue import FastTreeValue, raw
>>> f['a'] =  raw({'a': 1})
>>> f
<FastTreeValue 0x7f17e8153080>
└── 'a' --> <treevalue.tree.common.base.RawWrapper object at 0x7f17e8146fd0>
```

This is wrong, the correct one should be

```
>>> from treevalue import FastTreeValue, raw
>>> f['a'] =  raw({'a': 1})
>>> f
<FastTreeValue 0x7f17e8153080>
└── 'a' --> {'a': 1}
```


Discussion / hints:

Fix patch:
diff --git a/treevalue/tree/common/storage.pyx b/treevalue/tree/common/storage.pyx
index a0c512de25..7cf28ae157 100644
--- a/treevalue/tree/common/storage.pyx
+++ b/treevalue/tree/common/storage.pyx
@@ -20,7 +20,7 @@ cdef class TreeStorage:
         return ({},), {}
 
     cpdef public void set(self, str key, object value) except *:
-        self.map[key] = value
+        self.map[key] = unraw(value)
 
     # get and get_or_default is designed separately due to the consideration of performance
     cpdef public object get(self, str key):


Test patch:
diff --git a/test/tree/common/test_storage.py b/test/tree/common/test_storage.py
index 621f37947d..a1942a4987 100644
--- a/test/tree/common/test_storage.py
+++ b/test/tree/common/test_storage.py
@@ -258,6 +258,12 @@ def test_set(self):
         t.set('0' * 1000, 235)
         assert t.get('0' * 1000) == 235
 
+        t.set('ff', raw(1))
+        assert t.get('ff') == 1
+
+        t.set('fff', raw({'x': 1, 'y': 2}))
+        assert t.get('fff') == {'x': 1, 'y': 2}
+
     def test_del_(self):
         t = create_storage({'a': 1, 'b': 2, 'c': raw({'x': 3, 'y': 4}), 'd': {'x': 3, 'y': 4}})
         t.del_('c')
diff --git a/test/tree/tree/test_tree.py b/test/tree/tree/test_tree.py
index 109846a97c..397147555e 100644
--- a/test/tree/tree/test_tree.py
+++ b/test/tree/tree/test_tree.py
@@ -140,6 +140,12 @@ def test_tree_value_operate(self):
         with pytest.raises(AttributeError):
             del tv1._property__data
 
+        tv1.ff = raw(1)
+        assert tv1.ff == 1
+        tv1.fff = raw({'x': 1, 'y': 2})
+        assert isinstance(tv1.fff, dict)
+        assert tv1.fff == {'x': 1, 'y': 2}
+
     def test_tree_value_operate_with_item(self):
         tv1 = TreeValue({'a': 1, 'b': 2, 'c': {'x': 2, 'y': 3}})
         tv2 = TreeValue(tv1)