Issue1457

classification
Title: Cannot write an array in a file opened in r+b mode.
Type: behaviour Severity: normal
Components: Any Versions: 2.5.1
Milestone:
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: draghuram, jravon, pjenvey, zyasoft
Priority: Keywords:

Created on 2009-09-03.07:52:01 by jravon, last changed 2009-09-09.03:24:17 by pjenvey.

Files
File name Uploaded Description Edit Remove
t_array.py zyasoft, 2009-09-07.17:25:45 Tests r+b support in array.tofile
Messages
msg5093 (view) Author: Ravon (jravon) Date: 2009-09-03.07:52:01
File f is opened in, r+b mode.
a is an array.
a.tofile() is refused saying that f must be opened in
write or append mode.
msg5095 (view) Author: Raghuram Devarakonda (draghuram) Date: 2009-09-03.13:55:47
How can array (or for that matter, any data) be written to a file if it
is not opened in write mode? What is your point exactly?
msg5104 (view) Author: Jim Baker (zyasoft) Date: 2009-09-04.16:24:31
The file must be opened into a write or append mode, as the error
message indicates, not a read mode.
msg5111 (view) Author: Jim Baker (zyasoft) Date: 2009-09-07.17:25:45
r+b means read binary with possible update. There's difference between
in CPython and Jython as seen in the attached test file. Reopening.

$ python t_array.py
array('i', [1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5])

$ jython t_array.py
Traceback (most recent call last):
  File "t_array.py", line 12, in <module>
    x.tofile(f)
TypeError: file needs to be in write or append mode
msg5120 (view) Author: Philip Jenvey (pjenvey) Date: 2009-09-09.03:24:16
fixed in r6768
History
Date User Action Args
2009-09-09 03:24:17pjenveysetstatus: open -> closed
resolution: accepted -> fixed
messages: + msg5120
nosy: + pjenvey
2009-09-07 17:25:45zyasoftsetstatus: closed -> open
files: + t_array.py
resolution: rejected -> accepted
messages: + msg5111
2009-09-04 16:24:31zyasoftsetstatus: open -> closed
resolution: rejected
messages: + msg5104
nosy: + zyasoft
2009-09-03 13:55:48draghuramsetnosy: + draghuram
messages: + msg5095
2009-09-03 07:52:01jravoncreate