1. pkumar
  2. configobj-py3


zubin71  committed 5db8e0b

encoding before writing to file added in write()

  • Participants
  • Parent commits 702e63d
  • Branches default

Comments (0)

Files changed (1)

File configobj.py

View file
  • Ignore whitespace
 # ConfigObj mailing list:
 # http://lists.sourceforge.net/lists/listinfo/configobj-develop
 # Comments, suggestions and bug reports welcome.
 import pdb
 import os
         self._load(infile, configspec)
     def _load(self, infile, configspec):
         if isinstance(infile, str):
             self.filename = infile
             if os.path.isfile(infile):
     def _parse(self, infile):
         """Actually parse the config file."""
         temp_list_values = self.list_values
         if self.unrepr:
             self.list_values = False
             return out
         if (self.filename is None) and (outfile is None):
             # output a list of lines
             # might need to encode
             # NOTE: This will *screw* UTF16, each line will start with the BOM
                 out[0] = BOM_UTF8 + out[0]
             return out
         # Turn the list to a string, joined with correct newlines
         newline = self.newlines or os.linesep
         output = newline.join(out)
         if self.encoding:
             output = output.encode(self.encoding)
         if self.BOM and ((self.encoding is None) or match_utf8(self.encoding)):
             # Add the UTF8 BOM
             output = BOM_UTF8 + output
         if not output.endswith(newline):
             output += newline
         if outfile is not None:
             h = open(self.filename, 'wb')
+            output = output.encode() # encoding the data to bytes