Skip to content

Commit dc4d015

Browse files
committed
Merge pull request #38 from ingokeck/master
Fix for get_pyobject() and add_pyobject() failing
2 parents 3128d4b + d9f8c9d commit dc4d015

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

ipfsApi/utils.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ def parse_pyobj(pickled):
7272
[1, 2, 3, True, 4.5, None, 6000.0]
7373
"""
7474
if isinstance(pickled, six.text_type):
75-
pickled = pickled.encode('ascii')
75+
pickled = pickled.encode('latin_1')
7676
return pickle.loads(pickled)
7777

7878

test/functional/tests.py

+9-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# _*_ coding: utf-8 -*-
12
import os
23
import unittest
34

@@ -6,6 +7,7 @@
67

78
HERE = os.path.dirname(os.path.abspath(__file__))
89

10+
911
class IpfsApiTest(unittest.TestCase):
1012

1113
api = ipfsApi.Client()
@@ -38,7 +40,7 @@ class IpfsApiTest(unittest.TestCase):
3840
u'Name': u'popoiopiu'},
3941
{u'Hash': u'QmVkNdzCBukBRdpyFiKPyL2R15qPExMr9rV9RFV2kf9eeV',
4042
u'Name': u''}]
41-
43+
4244
## test_add_multiple_from_dirname
4345
fake_dir_test2 = 'fake_dir/test2'
4446
fake_dir_res = [{u'Hash': u'QmNuvmuFeeWWpxjCQwLkHshr8iqhGLWXFzSGzafBeawTTZ',
@@ -106,6 +108,12 @@ def test_add_recursive(self):
106108
sorted(self.fake_dir_recursive_res,
107109
key=lambda x: x['Name']))
108110

111+
def test_add_get_pyobject(self):
112+
data = [-1, 3.14, u'Hän€', b'23' ]
113+
res = self.api.add_pyobj(data)
114+
self.assertEqual(data,
115+
self.api.get_pyobj(res))
116+
109117

110118
if __name__ == "__main__":
111119
unittest.main()

0 commit comments

Comments
 (0)