Ticket #207: representer.py.patch

File representer.py.patch, 2.1 KB (added by terence@…, 3 years ago)

patch file to improve error message

  • lib/yaml/representer.py

     
    244244        return self.represent_mapping(tag, state, flow_style=flow_style) 
    245245 
    246246    def represent_undefined(self, data): 
    247         raise RepresenterError("cannot represent an object: %s" % data) 
     247        raise RepresenterError("cannot represent object %r of %r" 
     248                               % (data, type(data))) 
    248249 
    249250SafeRepresenter.add_representer(type(None), 
    250251        SafeRepresenter.represent_none) 
     
    409410        elif hasattr(data, '__reduce__'): 
    410411            reduce = data.__reduce__() 
    411412        else: 
    412             raise RepresenterError("cannot represent object: %r" % data) 
     413            raise RepresenterError("cannot represent object %r of %r" 
     414                                   % (data, type(data))) 
    413415        reduce = (list(reduce)+[None]*5)[:5] 
    414416        function, args, state, listitems, dictitems = reduce 
    415417        args = list(args) 
  • lib3/yaml/representer.py

     
    224224        return self.represent_mapping(tag, state, flow_style=flow_style) 
    225225 
    226226    def represent_undefined(self, data): 
    227         raise RepresenterError("cannot represent an object: %s" % data) 
     227        raise RepresenterError("cannot represent object %r of %r" 
     228                               % (data, type(data))) 
    228229 
    229230SafeRepresenter.add_representer(type(None), 
    230231        SafeRepresenter.represent_none) 
     
    314315        elif hasattr(data, '__reduce__'): 
    315316            reduce = data.__reduce__() 
    316317        else: 
    317             raise RepresenterError("cannot represent object: %r" % data) 
     318            raise RepresenterError("cannot represent object %r of %r" 
     319                                   % (data, type(data))) 
    318320        reduce = (list(reduce)+[None]*5)[:5] 
    319321        function, args, state, listitems, dictitems = reduce 
    320322        args = list(args)