Update of /cvsroot/pywin32/pywin32/Pythonwin/pywin/scintilla
In directory sfp-cvsdas-2.v30.ch3.sourceforge.com:/tmp/cvs-serv11304
Modified Files:
document.py view.py
Log Message:
Bug #2986020 - Attempt to encode script contents before opening file
Index: view.py
===================================================================
RCS file: /cvsroot/pywin32/pywin32/Pythonwin/pywin/scintilla/view.py,v
retrieving revision 1.35
retrieving revision 1.36
diff -C2 -d -r1.35 -r1.36
*** view.py 31 Jan 2009 05:56:01 -0000 1.35
--- view.py 6 May 2010 16:30:20 -0000 1.36
***************
*** 387,398 ****
def SaveTextFile(self, filename):
doc = self.GetDocument()
! # Open in binary mode as scintilla itself ensures the
! # line endings are already appropriate, and our doc save
! # method handles encoding, BOMs, etc.
! f = open(filename, 'wb')
! try:
! doc._SaveTextToFile(self, f)
! finally:
! f.close()
doc.SetModifiedFlag(0)
return 1
--- 387,391 ----
def SaveTextFile(self, filename):
doc = self.GetDocument()
! doc._SaveTextToFile(self, filename)
doc.SetModifiedFlag(0)
return 1
Index: document.py
===================================================================
RCS file: /cvsroot/pywin32/pywin32/Pythonwin/pywin/scintilla/document.py,v
retrieving revision 1.10
retrieving revision 1.11
diff -C2 -d -r1.10 -r1.11
*** document.py 31 Jan 2009 05:28:24 -0000 1.10
--- document.py 6 May 2010 16:30:20 -0000 1.11
***************
*** 134,142 ****
view.SendScintilla(scintillacon.SCI_SETEOLMODE, eol_mode)
! def _SaveTextToFile(self, view, f):
s = view.GetTextRange() # already decoded from scintilla's encoding
source_encoding = None
if self.bom:
- f.write(self.bom)
source_encoding = self.source_encoding
else:
--- 134,141 ----
view.SendScintilla(scintillacon.SCI_SETEOLMODE, eol_mode)
! def _SaveTextToFile(self, view, filename):
s = view.GetTextRange() # already decoded from scintilla's encoding
source_encoding = None
if self.bom:
source_encoding = self.source_encoding
else:
***************
*** 153,160 ****
source_encoding = 'latin1'
! f.write(s.encode(source_encoding))
self.SetModifiedFlag(0)
-
def FinalizeViewCreation(self, view):
pass
--- 152,168 ----
source_encoding = 'latin1'
! ## encode data before opening file so script is not lost if encoding fails
! file_contents = s.encode(source_encoding)
! # Open in binary mode as scintilla itself ensures the
! # line endings are already appropriate
! f = open(filename, 'wb')
! try:
! if self.bom:
! f.write(self.bom)
! f.write(file_contents)
! finally:
! f.close()
self.SetModifiedFlag(0)
def FinalizeViewCreation(self, view):
pass
|