Skip to content

read() reports FILE_NOT_FOUND status for unrelated file I/O errors #578

Description

@bhuvan-somisetty

Hi @pradeeban, found a small bug while reading through concore_base.py's file-based read().

When the port file fails to open, FileNotFoundError is handled separately, but any other error (permission denied, reading a directory, a corrupted file that can't decode, etc.) falls into the generic except and still sets last_read_status = "FILE_NOT_FOUND", even though the file exists and something else went wrong.

Kind of defeats the purpose of read_with_status() (#390/#498), which exists so callers know why they got default data. In a control loop, "no data yet" and "something's actually broken" aren't the same thing.

Also, the docstring lists EMPTY_DATA as a possible status, but nothing in the file ever sets it. Looks like stale documentation.

tests/test_read_status.py doesn't cover this case either.

Happy to send a PR: proper status for that branch, fix the EMPTY_DATA docstring, and a regression test.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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