Kaydet (Commit) 85e7a0f6 authored tarafından Stephan Bergmann's avatar Stephan Bergmann Kaydeden (comit) Michael Stahl

fdo#59728: Fix encoding of .py files as UTF-8 for Python 3

...where it could default to something like CP 1252 instead on Windows, while
keeping backwards compatibility for now with running under Python 2 (where
things apparently worked well with the original code).

Change-Id: I0ddd06771a36e1cd2cc2ce78abd8bd667db7778f
(cherry picked from commit c2445b03)
Reviewed-on: https://gerrit.libreoffice.org/1829Reviewed-by: 's avatarMichael Stahl <mstahl@redhat.com>
Tested-by: 's avatarMichael Stahl <mstahl@redhat.com>
üst fc4b3a04
......@@ -90,7 +90,10 @@ class Loader( XImplementationLoader, XServiceInfo, unohelper.Base ):
# read the file
filename = unohelper.fileUrlToSystemPath( url )
fileHandle = open( filename )
if sys.version >= '3':
fileHandle = open( filename, encoding='utf_8' )
else:
fileHandle = open( filename )
src = fileHandle.read().replace("\r","")
if not src.endswith( "\n" ):
src = src + "\n"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment