← index #3086Issue #1519
Off-topic · high · value 0.225
QUERY · ISSUE

open: No support for creating file if doesn't exist, while opening in r/w mode

openby pfalconopened 2017-05-13updated 2017-06-05
enhancement

There doesn't seem to be a mode for CPython3 open() to do subj. The closest one is "a+", but that additionally seeks to the end of file. Now the question is whether "a+" has a relation to POSIX open() mode O_APPEND which stipulates that any write to file opened with it happen at EOF (lseek() for writing is ignored).

Usecase: e.g., opening a file for btree.open().

CANDIDATE · ISSUE

cc3200: socket.makefile() needs to be more CPython compliant

closedby dpgeorgeopened 2015-10-19updated 2017-06-14
ports

socket.makefile() has the following spec:

socket.makefile(mode='r', buffering=None, *, encoding=None, errors=None, newline=None)

The main thing is that it should return a file in text mode by default. But cc3200's socket.makefile takes no args and just returns the socket which is in bytes mode.

unix port has the correct behaviour, by delegating the makefile to the file "open" function. But that only works because of file descriptors.

At the very least I think cc3200 should accept the mode argument and check that it is 'rb' or 'wb' and raise an exception if it's not (meaning that text mode is not supported). Alternatively, a full implementation would require a new socket type that was in text mode, which adds a lot to the code size (maybe there is a better way?).

Keyboard

j / / n
next pair
k / / p
previous pair
1 / / h
show query pane
2 / / l
show candidate pane
c
copy suggested comment
r
toggle reasoning
g i
go to index
?
show this help
esc
close overlays

press ? or esc to close

copied