[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.
This commit is contained in:
parent
a20fd58000
commit
000e374b6c
1 changed files with 3 additions and 3 deletions
|
|
@ -2528,13 +2528,13 @@ def convert(filename, outName=None):
|
||||||
root, _ = os.path.splitext(base)
|
root, _ = os.path.splitext(base)
|
||||||
dataset(root)
|
dataset(root)
|
||||||
try:
|
try:
|
||||||
with open(filename) as f:
|
with open(filename, 'rU') as f:
|
||||||
code = compile(f.read(), filename, 'exec')
|
code = compile(f.read(), filename, 'exec')
|
||||||
exec(code)
|
exec(code)
|
||||||
except SyntaxError as err:
|
except SyntaxError as err:
|
||||||
# Show more context than the default SyntaxError message
|
# Show more context than the default SyntaxError message
|
||||||
# to help see problems in multi-line statements
|
# 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__,
|
print('%s in "%s" on line %i:\n' % (err.__class__.__name__,
|
||||||
err.filename,
|
err.filename,
|
||||||
err.lineno))
|
err.lineno))
|
||||||
|
|
@ -2549,7 +2549,7 @@ def convert(filename, outName=None):
|
||||||
except TypeError as err:
|
except TypeError as err:
|
||||||
import traceback
|
import traceback
|
||||||
|
|
||||||
text = open(filename).readlines()
|
text = open(filename, 'rU').readlines()
|
||||||
tb = traceback.extract_tb(sys.exc_info()[2])
|
tb = traceback.extract_tb(sys.exc_info()[2])
|
||||||
lineno = tb[-1][1]
|
lineno = tb[-1][1]
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue