8000 BUG: fix np.save issue with python 2.7.5 by charris · Pull Request #10539 · numpy/numpy · GitHub
[go: up one dir, main page]

Skip to content

BUG: fix np.save issue with python 2.7.5 #10539

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Feb 7, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions numpy/lib/format.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
string = asstr(s) + "\n"
for token in tokenize.generate_tokens(StringIO(string).readline):
token_type = token[0]
token_string = token[1]
if (last_token_was_number and
Expand All @@ -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):
Expand Down
0