From 9a079c7c4e8960582fda8902616e5253b3ad2f3a Mon Sep 17 00:00:00 2001 From: Pauli Virtanen Date: Sun, 6 Dec 2009 12:14:16 +0000 Subject: 3K: core: bytes vs. str fixes in memmap.py --- numpy/core/memmap.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'numpy/core/memmap.py') 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': -- cgit v1.2.1