Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

back to unicode in decode_config #45

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions src/dynamic_reconfigure/encoding.py
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,12 @@ def add_params(group, descr):
return d

def decode_config(msg, description = None):
if sys.version < '3':
for s in msg.strs:
try:
s.value.decode('ascii')
except UnicodeDecodeError:
s.value=s.value.decode('utf-8')
d = Config([(kv.name, kv.value) for kv in msg.bools + msg.ints + msg.strs + msg.doubles])
if not msg.groups == [] and description is not None:
d["groups"] = get_tree(msg)
Expand Down
16 changes: 15 additions & 1 deletion test/simple_python_client_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,21 @@ def testmultibytestring(self):

config = client.get_configuration(timeout=5)

self.assertEqual("いろは", config['mstr_'])
self.assertEqual(u"いろは", config['mstr_'])
self.assertEqual(u"いろは", rospy.get_param('/ref_server/mstr_'))

str_ = u"にほへ"

client.update_configuration(
{"mstr_": str_}
)

rospy.sleep(1.0)

config = client.get_configuration(timeout=5)

self.assertEqual(u"にほへ", config['mstr_'])
self.assertEqual(u"にほへ", rospy.get_param('/ref_server/mstr_'))

if __name__ == "__main__":
import rostest
Expand Down