[Libreoffice-commits] .: pyuno/source
Libreoffice Gerrit user
logerrit at kemper.freedesktop.org
Wed Jan 23 09:00:45 PST 2013
pyuno/source/loader/pythonloader.py | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
New commits:
commit c2445b03f4d27bbd7e14c4322704ce89b582839b
Author: Stephan Bergmann <sbergman at redhat.com>
Date: Wed Jan 23 17:58:25 2013 +0100
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
diff --git a/pyuno/source/loader/pythonloader.py b/pyuno/source/loader/pythonloader.py
index 6d8ca97..3074d0f 100644
--- a/pyuno/source/loader/pythonloader.py
+++ b/pyuno/source/loader/pythonloader.py
@@ -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"
More information about the Libreoffice-commits
mailing list