From 5b8bc4fe17969385c9ec5fd5be09c27c45ba89d6 Mon Sep 17 00:00:00 2001 From: Robin Dunn Date: Sun, 16 Dec 2012 01:15:21 +0000 Subject: [PATCH] Use textfile_open when loading core.pi to avoid encoding errors in Python3 git-svn-id: https://svn.wxwidgets.org/svn/wx/wxPython/Phoenix/trunk@73194 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- buildtools/config.py | 4 ++-- etgtools/generators.py | 4 ++-- etgtools/tweaker_tools.py | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/buildtools/config.py b/buildtools/config.py index 697e9a12..1f3349a1 100644 --- a/buildtools/config.py +++ b/buildtools/config.py @@ -812,8 +812,8 @@ def myExecfile(filename, ns): def textfile_open(filename, mode='rt'): """ - Simple wrapper around open() that will use codecs.open on Python 2.x and - on Python 2.3 will add the encoding parameter to the normal open(). The + Simple wrapper around open() that will use codecs.open on Python2 and + on Python3 will add the encoding parameter to the normal open(). The mode parameter must include the 't' to put the stream into text mode. """ assert 't' in mode diff --git a/etgtools/generators.py b/etgtools/generators.py index 19888b4c..594287f2 100644 --- a/etgtools/generators.py +++ b/etgtools/generators.py @@ -106,8 +106,8 @@ class Utf8EncodingStream(io.StringIO): def textfile_open(filename, mode='rt'): """ - Simple wrapper around open() that will use codecs.open on Python 2.x and - on Python 2.3 will add the encoding parameter to the normal open(). The + Simple wrapper around open() that will use codecs.open on Python2 and + on Python3 will add the encoding parameter to the normal open(). The mode parameter must include the 't' to put the stream into text mode. """ assert 't' in mode diff --git a/etgtools/tweaker_tools.py b/etgtools/tweaker_tools.py index 5c2b8d4f..139edc8d 100644 --- a/etgtools/tweaker_tools.py +++ b/etgtools/tweaker_tools.py @@ -114,7 +114,7 @@ class FixWxPrefix(object): names.append(item.name) names = list() - text = open('wx/core.pi').read() + text = textfile_open('wx/core.pi').read() parseTree = ast.parse(text, 'wx/core.pi') for item in parseTree.body: _processItem(item, names)