From 000e374b6ced8a9c8b38cebfd9709ec3010df643 Mon Sep 17 00:00:00 2001 From: Ray Speth Date: Thu, 18 Jul 2013 19:07:10 +0000 Subject: [PATCH] [ctml_writer] Fix a Python 2.6 compatibility issue Python 2.6 needs some extra help when trying to execute code containing Windows (CRLF) line endings. --- interfaces/python/ctml_writer.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/interfaces/python/ctml_writer.py b/interfaces/python/ctml_writer.py index 2bf5fc13e..cdf1f7260 100644 --- a/interfaces/python/ctml_writer.py +++ b/interfaces/python/ctml_writer.py @@ -2528,13 +2528,13 @@ def convert(filename, outName=None): root, _ = os.path.splitext(base) dataset(root) try: - with open(filename) as f: + with open(filename, 'rU') as f: code = compile(f.read(), filename, 'exec') exec(code) except SyntaxError as err: # Show more context than the default SyntaxError message # to help see problems in multi-line statements - text = open(filename).readlines() + text = open(filename, 'rU').readlines() print('%s in "%s" on line %i:\n' % (err.__class__.__name__, err.filename, err.lineno)) @@ -2549,7 +2549,7 @@ def convert(filename, outName=None): except TypeError as err: import traceback - text = open(filename).readlines() + text = open(filename, 'rU').readlines() tb = traceback.extract_tb(sys.exc_info()[2]) lineno = tb[-1][1]