@@ -907,7 +907,7 @@ def set_context_menu_from_file(self, file_path, menu='graph'):
907907 if not file .is_file ():
908908 raise IOError ('file doesn\' t exist: "{}"' .format (file ))
909909
910- with file .open () as f :
910+ with file .open (encoding = 'utf8' ) as f :
911911 data = json .load (f )
912912 context_menu = self .get_context_menu (menu )
913913 self ._deserialize_context_menu (context_menu , data , file )
@@ -1727,8 +1727,12 @@ def _serialize(self, nodes):
17271727 serial_data ['graph' ]['pipe_style' ] = self .pipe_style ()
17281728
17291729 # connection constrains.
1730- serial_data ['graph' ]['accept_connection_types' ] = self .model .accept_connection_types
1731- serial_data ['graph' ]['reject_connection_types' ] = self .model .reject_connection_types
1730+ serial_data ['graph' ]['accept_connection_types' ] = {
1731+ k : list (v ) for k , v in self .model .accept_connection_types .items ()
1732+ }
1733+ serial_data ['graph' ]['reject_connection_types' ] = {
1734+ k : list (v ) for k , v in self .model .reject_connection_types .items ()
1735+ }
17321736
17331737 # serialize nodes.
17341738 for n in nodes :
@@ -1798,9 +1802,13 @@ def _deserialize(self, data, relative_pos=False, pos=None):
17981802
17991803 # connection constrains.
18001804 elif attr_name == 'accept_connection_types' :
1801- self .model .accept_connection_types = attr_value
1805+ self .model .accept_connection_types = {
1806+ k : set (v ) for k , v in attr_value .items ()
1807+ }
18021808 elif attr_name == 'reject_connection_types' :
1803- self .model .reject_connection_types = attr_value
1809+ self .model .reject_connection_types = {
1810+ k : set (v ) for k , v in attr_value .items ()
1811+ }
18041812
18051813 # build the nodes.
18061814 nodes = {}
0 commit comments