summaryrefslogtreecommitdiff
path: root/numpy/lib/format.py
diff options
context:
space:
mode:
authorDennis Weyland <dennisweyland@gmail.com>2018-02-05 00:42:33 +0100
committerDennis Weyland <dennisweyland@gmail.com>2018-02-05 06:04:41 +0100
commit81c4b5ae13540655c3faeadc645fc1dfbe9ffe82 (patch)
tree9023c15d10ec6e091d628292d673478c469b38fe /numpy/lib/format.py
parent92d1759b95a882facafd0d3545ca353232944b79 (diff)
downloadnumpy-81c4b5ae13540655c3faeadc645fc1dfbe9ffe82.tar.gz
python 2.7.5 bugfix
Diffstat (limited to 'numpy/lib/format.py')
-rw-r--r--numpy/lib/format.py7
1 files changed, 5 insertions, 2 deletions
diff --git a/numpy/lib/format.py b/numpy/lib/format.py
index 84af2afc8..89a8cb42f 100644
--- a/numpy/lib/format.py
+++ b/numpy/lib/format.py
@@ -454,7 +454,9 @@ def _filter_header(s):
tokens = []
last_token_was_number = False
- for token in tokenize.generate_tokens(StringIO(asstr(s)).read):
+ # adding newline as python 2.7.5 workaround
+ s += "\n"
+ for token in tokenize.generate_tokens(StringIO(asstr(s)).readline):
token_type = token[0]
token_string = token[1]
if (last_token_was_number and
@@ -464,7 +466,8 @@ def _filter_header(s):
else:
tokens.append(token)
last_token_was_number = (token_type == tokenize.NUMBER)
- return tokenize.untokenize(tokens)
+ # removing newline (see above) as python 2.7.5 workaround
+ return tokenize.untokenize(tokens)[:-1]
def _read_array_header(fp, version):