Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix File.flush return value for case of zero bytes to flush. #2704

Merged
merged 1 commit into from
May 21, 2018

Conversation

jemc
Copy link
Member

@jemc jemc commented May 20, 2018

Currently, File.flush returns false when the number of bytes pending to write is zero, even though the docstring says that:

    Returns false if the file wasn't opened with write permission.
    Raises an error if not all the bytes were written.
    Returns true if it sent all pending data.

This situation should fall under the true condition - all pending data was successfully written - it's just that the number of bytes was zero. It definitely doesn't fall under the false condition because it has nothing to do with write permissions.

This PR fixes that bug and adds a test.

@jemc jemc added the changelog - fixed Automatically add "Fixed" CHANGELOG entry on merge label May 20, 2018
@jemc jemc force-pushed the fix/file-flush-nothing branch from 32fadf9 to f36e567 Compare May 20, 2018 15:40
@jemc
Copy link
Member Author

jemc commented May 20, 2018

Let's try a different approach in the test and see if it fixes the windows build...

@mfelsche
Copy link
Contributor

What was the actual windows issue?

@jemc
Copy link
Member Author

jemc commented May 21, 2018

I was testing file size after the write, expecting 7 bytes for "foobar\n" and got 8 bytes. Maybe a line endings issue with \r somehow being added?

@jemc jemc merged commit 7348c6c into master May 21, 2018
@jemc jemc deleted the fix/file-flush-nothing branch May 21, 2018 13:45
ponylang-main added a commit that referenced this pull request May 21, 2018
dipinhora pushed a commit to dipinhora/ponyc that referenced this pull request Jun 5, 2018
dipinhora pushed a commit to dipinhora/ponyc that referenced this pull request Jun 5, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
changelog - fixed Automatically add "Fixed" CHANGELOG entry on merge
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants