[Numpy-discussion] ANN: Numpy 1.6.0 beta 2

Charles R Harris charlesr.harris at gmail.com
Tue Apr 5 10:12:00 EDT 2011

On Mon, Apr 4, 2011 at 11:22 PM, Chris Barker <Chris.Barker at noaa.gov> wrote:

> On 4/4/11 9:03 PM, josef.pktd at gmail.com wrote:
> > On Mon, Apr 4, 2011 at 11:42 PM, Charles R Harris
> >>>    File "/sw/lib/python2.4/site-packages/numpy/lib/_datasource.py",
> >>> line 477, in open
> >>>      return _file_openers[ext](found, mode=mode)
> >>> IOError: invalid mode: Ub
> >>>
> >>
> >> Guess that wasn't tested before ;) I thought that was strange when I saw
> it.
> >> The source of the problem is line 2035 in npyio.py. Additionally, Since
> >> genloadtxt needs to have byte strings the 'rb" mode should probably be
> used.
> >> That works on linux, both for python 2 and python 3, but doing that
> might
> >> uncover genfromtxt problems on other platforms.
> > "rb" is fine on Windows with python 3.2, (that's what I tested
> > initially for this bug)
> IIUC, "Ub" is undefined -- "U" means universal newlines, which makes no
> sense when used with "b" for binary. I looked at the code a ways back,
> and I can't remember the resolution order, but there isn't any checking
> for incompatible flags.
> I'd expect that genfromtxt, being txt, and line oriented, should use
> 'rU'. but if it wants the raw line endings (why would it?) then rb
> should be fine.
> Note that if you only test with unix (\n) and dos (\r\n) line endings,
> it may work with 'b', if it's splitting on '\n', but not if you try it
> with Mac endings (\r). Of course with OS-X mac endings are getting
> pretty uncommon.
The 'Ub' mode doesn't work for '\r' on python 3. This may be a bug in
python, as it works just fine on python 2.7. It may indeed be desirable to
read the files as text, but that would require more work on both loadtxt and

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/numpy-discussion/attachments/20110405/c7ddc99c/attachment.html>

More information about the NumPy-Discussion mailing list