/mandos/trunk

To get this branch, use:
bzr branch http://bzr.recompile.se/loggerhead/mandos/trunk

« back to all changes in this revision

Viewing changes to mandos

  • Committer: Teddy Hogeborn
  • Date: 2016-03-12 20:23:15 UTC
  • Revision ID: teddy@recompile.se-20160312202315-hu7b87ivetlxqbw3
Server: Fix minor thing with Python 3 compatibility

Fix another small thing with unpickling string values.

* mandos (main): When restoring pickled client data, only decode byte
                 string for "host" key if it really is a byte string.

Show diffs side-by-side

added added

removed removed

Lines of Context:
3066
3066
                                      else key): value
3067
3067
                                     for key, value in
3068
3068
                                     bytes_clients_data.items() }
 
3069
                    del bytes_clients_data
3069
3070
                    for key in clients_data:
3070
3071
                        value = { (k.decode("utf-8")
3071
3072
                                   if isinstance(k, bytes) else k): v
3083
3084
                            if isinstance(value[k], bytes):
3084
3085
                                value[k] = value[k].decode("utf-8")
3085
3086
                    ## old_client_settings
3086
 
                    # .keys
 
3087
                    # .keys()
3087
3088
                    old_client_settings = {
3088
3089
                        (key.decode("utf-8")
3089
3090
                         if isinstance(key, bytes)
3090
3091
                         else key): value
3091
3092
                        for key, value in
3092
3093
                        bytes_old_client_settings.items() }
 
3094
                    del bytes_old_client_settings
3093
3095
                    # .host
3094
3096
                    for value in old_client_settings.values():
3095
 
                        value["host"] = value["host"].decode("utf-8")
 
3097
                        if isinstance(value["host"], bytes):
 
3098
                            value["host"] = (value["host"]
 
3099
                                             .decode("utf-8"))
3096
3100
            os.remove(stored_state_path)
3097
3101
        except IOError as e:
3098
3102
            if e.errno == errno.ENOENT: