aboutsummaryrefslogtreecommitdiffstats
path: root/mako/util.py
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2013-02-20 21:24:49 -0500
committerMike Bayer <mike_mp@zzzcomputing.com>2013-02-20 21:24:49 -0500
commit779e1f330ee112500f862d5fdf056654abd48d37 (patch)
treeb17a43b3a7e6fcf6ec04de57f803551266302eb0 /mako/util.py
parentb809f95b4e5327b8dab10c923226ae6047399404 (diff)
downloadexternal_python_mako-779e1f330ee112500f862d5fdf056654abd48d37.tar.gz
external_python_mako-779e1f330ee112500f862d5fdf056654abd48d37.tar.bz2
external_python_mako-779e1f330ee112500f862d5fdf056654abd48d37.zip
- [bug] Fixed bug whereby an exception in Python 3
against a module compiled to the filesystem would fail trying to produce a RichTraceback due to the content being in bytes. [ticket:209]
Diffstat (limited to 'mako/util.py')
-rw-r--r--mako/util.py11
1 files changed, 11 insertions, 0 deletions
diff --git a/mako/util.py b/mako/util.py
index f54fda2..87be71b 100644
--- a/mako/util.py
+++ b/mako/util.py
@@ -353,6 +353,17 @@ def read_file(path, mode='rb'):
finally:
fp.close()
+def read_python_file(path):
+ fp = open(path, "rb")
+ try:
+ encoding = parse_encoding(fp)
+ data = fp.read()
+ if encoding:
+ data = data.decode(encoding)
+ return data
+ finally:
+ fp.close()
+
def load_module(module_id, path):
fp = open(path, 'rb')
try: