diff options
author | Julian Taylor <juliantaylor108@gmail.com> | 2014-10-15 20:54:32 +0200 |
---|---|---|
committer | Julian Taylor <juliantaylor108@gmail.com> | 2014-10-15 20:54:32 +0200 |
commit | e2218a6984b756a1806041f8fb6869f63365ad10 (patch) | |
tree | e58de5e02290277f1a23d3e545b4d3d6a37cff2f /numpy/lib | |
parent | fd06081e5cb484e9acda1db5c92574ac3d740bb4 (diff) | |
parent | a8e027ff49fdfdce4d845eef7e1f8cd939ae840a (diff) | |
download | numpy-e2218a6984b756a1806041f8fb6869f63365ad10.tar.gz |
Merge pull request #5183 from charris/fix-npy-header-write
BUG: Fix writing of intrinsic long integers in python2 npy files.
Diffstat (limited to 'numpy/lib')
-rw-r--r-- | numpy/lib/format.py | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/numpy/lib/format.py b/numpy/lib/format.py index 7c8dfbafa..b93f86ca3 100644 --- a/numpy/lib/format.py +++ b/numpy/lib/format.py @@ -298,7 +298,8 @@ def _write_array_header(fp, d, version=None): # can take advantage of our premature optimization. current_header_len = MAGIC_LEN + 2 + len(header) + 1 # 1 for the newline topad = 16 - (current_header_len % 16) - header = asbytes(header + ' '*topad + '\n') + header = header + ' '*topad + '\n' + header = asbytes(_filter_header(header)) if len(header) >= (256*256) and version == (1, 0): raise ValueError("header does not fit inside %s bytes required by the" @@ -433,7 +434,7 @@ def _filter_header(s): from io import StringIO else: from StringIO import StringIO - + tokens = [] last_token_was_number = False for token in tokenize.generate_tokens(StringIO(asstr(s)).read): @@ -448,7 +449,7 @@ def _filter_header(s): last_token_was_number = (token_type == tokenize.NUMBER) return tokenize.untokenize(tokens) - + def _read_array_header(fp, version): """ see read_array_header_1_0 |