
Calls that open a file for writing, blanked out
Source:R/code_check.R
dot-code_blank_write_opens.RdPython's open() and MATLAB's fopen() read a file or write one, decided
only by their mode argument. code_file_refs() took the file name in every
such call as an input, so open("out.txt", "w") was reported as a missing
file when the script itself creates it. This replaces the text of each
call that writes with spaces, so its file name is not found; the lines and
their number stay as they were. A call over several lines is judged as a
whole.
Details
The mode is the second argument without a name, or (Python) mode =. The
default modes are those that create the file: Python's w, a and x,
MATLAB's w and a. r+ changes a file that must already exist, so it is
left as an input; .py_open_writes() passes its own modes, which count r+.