Skip to content

read_delim (and friends) looks for file when given literal data #1063

@ceresek

Description

@ceresek

The read_delim function accepts literal data when the file argument contains a newline, however, it will still attempt to access a file whose name is the literal data. This is because read_delimited will call empty_file on the literal data, which will (on Linux) end up calling the stat syscall.

Easily reproduced with:

[bash] strace -e trace=stat R
[r] library ('readr')
[r] read_delim ('this\nshould\nnot\nhappen', delim = ',')
[console] stat("this\nshould\nnot\nhappen", 0x7ffd6298e220) = -1 ENOENT (No such file or directory)

The function works in that it then correctly parses the literal data, but it is still strange that it should use the literal data to access the file system. (In general, it feels like doing autodetect on the file argument rather than distinguishing files, links and literal data through different arguments is somewhat fragile, and perhaps even not very useful.)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions