diff options
author | Pauli Virtanen <pav@iki.fi> | 2009-12-06 12:14:16 +0000 |
---|---|---|
committer | Pauli Virtanen <pav@iki.fi> | 2009-12-06 12:14:16 +0000 |
commit | 9a079c7c4e8960582fda8902616e5253b3ad2f3a (patch) | |
tree | c47188fc90f5762c9400c428170f5b7637ae0d51 /numpy/core/memmap.py | |
parent | 1e6fbd050c42ece2c2d14598a5c32f101aba5d81 (diff) | |
download | numpy-9a079c7c4e8960582fda8902616e5253b3ad2f3a.tar.gz |
3K: core: bytes vs. str fixes in memmap.py
Diffstat (limited to 'numpy/core/memmap.py')
-rw-r--r-- | numpy/core/memmap.py | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/numpy/core/memmap.py b/numpy/core/memmap.py index 996d5562c..ed888a040 100644 --- a/numpy/core/memmap.py +++ b/numpy/core/memmap.py @@ -4,6 +4,8 @@ import warnings from numeric import uint8, ndarray, dtype import sys +from numpy.compat import asbytes + dtypedescr = dtype valid_filemodes = ["r", "c", "r+", "w+"] writeable_filemodes = ["r+","w+"] @@ -174,7 +176,7 @@ class memmap(ndarray): if hasattr(filename,'read'): fid = filename else: - fid = file(filename, (mode == 'c' and 'r' or mode)+'b') + fid = open(filename, (mode == 'c' and 'r' or mode)+'b') if (mode == 'w+') and shape is None: raise ValueError, "shape must be given" @@ -203,7 +205,7 @@ class memmap(ndarray): if mode == 'w+' or (mode == 'r+' and flen < bytes): fid.seek(bytes - 1, 0) - fid.write(chr(0)) + fid.write(asbytes('\0')) fid.flush() if mode == 'c': |