Changeset 361 for pyyaml/trunk/lib3/yaml

Show
Ignore:
Timestamp:
08/30/09 15:32:07 (3 years ago)
Author:
xi
Message:

Fixed Python 3.1 incompatibility issues.

Location:
pyyaml/trunk/lib3/yaml
Files:
3 modified

Legend:

Unmodified
Added
Removed
  • pyyaml/trunk/lib3/yaml/constructor.py

    r329 r361  
    286286                    node.start_mark) 
    287287        try: 
    288             return base64.decodestring(value) 
     288            if hasattr(base64, 'decodebytes'): 
     289                return base64.decodebytes(value) 
     290            else: 
     291                return base64.decodestring(value) 
    289292        except binascii.Error as exc: 
    290293            raise ConstructorError(None, None, 
     
    478481                    node.start_mark) 
    479482        try: 
    480             return base64.decodestring(value) 
     483            if hasattr(base64, 'decodebytes'): 
     484                return base64.decodebytes(value) 
     485            else: 
     486                return base64.decodestring(value) 
    481487        except binascii.Error as exc: 
    482488            raise ConstructorError(None, None, 
  • pyyaml/trunk/lib3/yaml/reader.py

    r328 r361  
    157157                            'strict', self.eof) 
    158158                except UnicodeDecodeError as exc: 
    159                     character = exc.object[exc.start] 
     159                    character = self.raw_buffer[exc.start] 
    160160                    if self.stream is not None: 
    161161                        position = self.stream_pointer-len(self.raw_buffer)+exc.start 
  • pyyaml/trunk/lib3/yaml/representer.py

    r328 r361  
    145145 
    146146    def represent_binary(self, data): 
    147         data = base64.encodestring(data).decode('ascii') 
     147        if hasattr(base64, 'encodebytes'): 
     148            data = base64.encodebytes(data).decode('ascii') 
     149        else: 
     150            data = base64.encodestring(data).decode('ascii') 
    148151        return self.represent_scalar('tag:yaml.org,2002:binary', data, style='|') 
    149152