mirror of
https://github.com/Sei-Lisa/LSL-PyOptimizer
synced 2025-07-01 23:58:20 +00:00
Fix a few violations of our guidelines for Unicode handling.
Also use e.args[0] instead of e[0].
This commit is contained in:
parent
1162c202c4
commit
e2ad14ee1b
1 changed files with 4 additions and 4 deletions
8
main.py
8
main.py
|
@ -33,9 +33,9 @@ def ReportError(script, e):
|
||||||
lastpos = fieldpos(script, '\n', e.lno+1)-1
|
lastpos = fieldpos(script, '\n', e.lno+1)-1
|
||||||
assert lastpos != -1
|
assert lastpos != -1
|
||||||
if lastpos < -1: lastpos = len(script) # may hit EOF
|
if lastpos < -1: lastpos = len(script) # may hit EOF
|
||||||
sys.stderr.write(script[fieldpos(script, '\n', e.lno):lastpos] + '\n')
|
sys.stderr.write(script[fieldpos(script, '\n', e.lno):lastpos].decode('utf8') + u"\n")
|
||||||
sys.stderr.write(' ' * e.cno + '^\n')
|
sys.stderr.write(u" " * e.cno + u"^\n")
|
||||||
sys.stderr.write(e[0] + '\n')
|
sys.stderr.write(e.args[0] + u"\n")
|
||||||
|
|
||||||
class UniConvScript(object):
|
class UniConvScript(object):
|
||||||
"""Converts the script to Unicode, setting the properties required by
|
"""Converts the script to Unicode, setting the properties required by
|
||||||
|
@ -497,7 +497,7 @@ def main(argv):
|
||||||
except EParse as e:
|
except EParse as e:
|
||||||
# We don't call ReportError to prevent problems due to
|
# We don't call ReportError to prevent problems due to
|
||||||
# displaying invalid UTF-8
|
# displaying invalid UTF-8
|
||||||
sys.stderr.write(e[0] + '\n')
|
sys.stderr.write(e.args[0] + u"\n")
|
||||||
return 1
|
return 1
|
||||||
|
|
||||||
if preproc != 'none':
|
if preproc != 'none':
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue