[Python-modules-commits] [fparser] 03/03: Fix for unicode handling in parse()
Alastair McKinstry
mckinstry at moszumanska.debian.org
Mon Sep 18 13:24:31 UTC 2017
This is an automated email from the git hooks/post-receive script.
mckinstry pushed a commit to branch debian/master
in repository fparser.
commit e28b6fe2a476fd3646a53ddeac54258ff1ee141d
Author: Alastair McKinstry <mckinstry at debian.org>
Date: Tue Aug 29 07:08:25 2017 +0100
Fix for unicode handling in parse()
---
debian/patches/python3.patch | 41 ++++++++++++++++++++++++++++++++---------
1 file changed, 32 insertions(+), 9 deletions(-)
diff --git a/debian/patches/python3.patch b/debian/patches/python3.patch
index 1605516..684abe0 100644
--- a/debian/patches/python3.patch
+++ b/debian/patches/python3.patch
@@ -1096,7 +1096,7 @@ Index: fparser-0.0.5/src/fparser/readfortran.py
self.set_mode(isfree, isstrict)
def close_source(self):
-@@ -569,7 +571,7 @@ class FortranReaderBase(object):
+@@ -569,14 +571,17 @@ class FortranReaderBase(object):
if self.isclosed:
return None
try:
@@ -1105,7 +1105,18 @@ Index: fparser-0.0.5/src/fparser/readfortran.py
except StopIteration:
self.isclosed = True
self.close_source()
-@@ -644,7 +646,7 @@ class FortranReaderBase(object):
+ return None
+ self.linecount += 1
+ # expand tabs, replace special symbols, get rid of nl characters
+- line = line.expandtabs().replace('\xa0',' ').rstrip()
++ try:
++ line = line.expandtabs().replace('\xa0',' ').rstrip()
++ except UnicodeDecodeError: # \xa0 isn't valid ascii, py2 may choke
++ line = line.expandtabs().rstrip()
+ self.source_lines.append(line)
+
+ if ignore_comments and _is_fix_comment(line, isstrict=self.isstrict):
+@@ -644,7 +649,7 @@ class FortranReaderBase(object):
if self.reader is not None:
# inside INCLUDE statement
try:
@@ -1114,7 +1125,7 @@ Index: fparser-0.0.5/src/fparser/readfortran.py
except StopIteration:
self.reader = None
item = self._next(ignore_comments)
-@@ -884,7 +886,7 @@ class FortranReaderBase(object):
+@@ -884,7 +889,7 @@ class FortranReaderBase(object):
if m:
newline = m.group('indent')+5*' '+m.group('rest')
self.f2py_comment_lines.append(self.linecount)
@@ -1123,7 +1134,7 @@ Index: fparser-0.0.5/src/fparser/readfortran.py
return newline
return line
-@@ -1180,7 +1182,7 @@ class FortranReaderBase(object):
+@@ -1180,7 +1185,7 @@ class FortranReaderBase(object):
# first line, check for a label
m = _label_re.match(line)
if m:
@@ -1132,7 +1143,7 @@ Index: fparser-0.0.5/src/fparser/readfortran.py
label = int(m.group('label'))
line = line[m.end():]
# check for a construct name
-@@ -1233,7 +1235,7 @@ class FortranReaderBase(object):
+@@ -1233,7 +1238,7 @@ class FortranReaderBase(object):
if name is not None:
self.error('No construct following construct-name.')
if have_comment:
@@ -1141,7 +1152,19 @@ Index: fparser-0.0.5/src/fparser/readfortran.py
return self.comment_item('', startlineno, endlineno)
## FortranReaderBase
-@@ -1286,9 +1288,9 @@ cf2py call me ! hey
+@@ -1262,7 +1267,10 @@ class FortranStringReader(FortranReaderB
+
+ def __init__(self, string, include_dirs = None, source_only = None):
+ self.id = 'string-'+str(id(string))
+- source = StringIO(string)
++ try:
++ source = StringIO(string)
++ except:
++ source = StringIO(unicode(string))
+ isfree, isstrict = get_source_info_str(string)
+ FortranReaderBase.__init__(self, source, isfree, isstrict)
+ if include_dirs is not None:
+@@ -1286,9 +1294,9 @@ cf2py call me ! hey
end
'"""
reader = FortranStringReader(string_f77)
@@ -1153,7 +1176,7 @@ Index: fparser-0.0.5/src/fparser/readfortran.py
filename = tempfile.mktemp()+'.f'
f = open(filename,'w')
-@@ -1297,7 +1299,7 @@ cf2py call me ! hey
+@@ -1297,7 +1305,7 @@ cf2py call me ! hey
reader = FortranFileReader(filename)
for item in reader:
@@ -1162,7 +1185,7 @@ Index: fparser-0.0.5/src/fparser/readfortran.py
def test_pyf():
string_pyf = """! -*- pyf -*-
-@@ -1328,9 +1330,9 @@ end python module foo
+@@ -1328,9 +1336,9 @@ end python module foo
! end of file
"""
reader = FortranStringReader(string_pyf)
@@ -1174,7 +1197,7 @@ Index: fparser-0.0.5/src/fparser/readfortran.py
def test_fix90():
string_fix90 = """c -*- fix -*-
-@@ -1353,16 +1355,16 @@ cComment
+@@ -1353,16 +1361,16 @@ cComment
end
"""
reader = FortranStringReader(string_fix90)
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/python-modules/packages/fparser.git
More information about the Python-modules-commits
mailing list