8000 Merge pull request #10524 from pnbat/bugfix · numpy/numpy@1ba96c6 · GitHub
[go: up one dir, main page]

Skip to content

Commit 1ba96c6

Browse files
authored
Merge pull request #10524 from pnbat/bugfix
BUG: fix np.save issue with python 2.7.5
2 parents 92d1759 + 8d5bdd1 commit 1ba96c6

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

numpy/lib/format.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -454,7 +454,9 @@ def _filter_header(s):
454454

455455
tokens = []
456456
last_token_was_number = False
457-
for token in tokenize.generate_tokens(StringIO(asstr(s)).read):
457+
# adding newline as python 2.7.5 workaround
458+
string = asstr(s) + "\n"
459+
for token in tokenize.generate_tokens(StringIO(string).readline):
458460
token_type = token[0]
459461
token_string = token[1]
460462
if (last_token_was_number and
@@ -464,7 +466,8 @@ def _filter_header(s):
464466
else:
465467
tokens.append(token)
466468
last_token_was_number = (token_type == tokenize.NUMBER)
467-
return tokenize.untokenize(tokens)
469+
# removing newline (see above) as python 2.7.5 workaround
470+
return tokenize.untokenize(tokens)[:-1]
468471

469472

470473
def _read_array_header(fp, version):

0 commit comments

Comments
 (0)
0