Ignore:
Timestamp:
04/18/06 15:33:16 (8 years ago)
Author:
xi
Message:

Fix bugs in emitter and representer.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • pyyaml/trunk/lib/yaml/representer.py

    r139 r143  
    6464        data_types = type(data).__mro__ 
    6565        if type(data) is self.instance_type: 
    66             data_types = self.get_classobj_bases(data.__class__)+data_types 
     66            data_types = self.get_classobj_bases(data.__class__)+list(data_types) 
    6767        for data_type in data_types: 
    6868            if data_type in self.yaml_representers: 
     
    292292 
    293293    def represent_complex(self, data): 
    294         if data.real != 0.0: 
     294        if data.imag == 0.0: 
     295            data = u'%r' % data.real 
     296        elif data.real == 0.0: 
     297            data = u'%rj' % data.imag 
     298        elif data.imag > 0: 
    295299            data = u'%r+%rj' % (data.real, data.imag) 
    296300        else: 
    297             data = u'%rj' % data.imag 
     301            data = u'%r%rj' % (data.real, data.imag) 
    298302        return self.represent_scalar(u'tag:yaml.org,2002:python/complex', data) 
    299303 
Note: See TracChangeset for help on using the changeset viewer.