summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStephan Bergmann <sbergman@redhat.com>2013-01-23 17:58:25 +0100
committerPetr Mladek <pmladek@suse.cz>2013-01-28 15:38:02 +0000
commit355f644fb1d987947d63f2aa7e6a8f59d8337324 (patch)
tree50e92c8f01edc5bc3fe7d27c1d739de275166268
parent2f8abaad2830530ad299221d72964894d5ddb402 (diff)
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 c2445b03f4d27bbd7e14c4322704ce89b582839b) Reviewed-on: https://gerrit.libreoffice.org/1829 Reviewed-by: Michael Stahl <mstahl@redhat.com> Tested-by: Michael Stahl <mstahl@redhat.com> (cherry picked from commit 85e7a0f6cd9b311e6734e747b03ad0a736ff6dbd) Reviewed-on: https://gerrit.libreoffice.org/1836 Reviewed-by: Noel Power <noel.power@suse.com> Reviewed-by: Eike Rathke <erack@redhat.com> Reviewed-by: Petr Mladek <pmladek@suse.cz> Tested-by: Petr Mladek <pmladek@suse.cz>
-rw-r--r--pyuno/source/loader/pythonloader.py5
1 files changed, 4 insertions, 1 deletions
diff --git a/pyuno/source/loader/pythonloader.py b/pyuno/source/loader/pythonloader.py
index 0330a6e79ef1..de4d630b1ccc 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"