This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Title: File reading gets stuck if you read at eof on macos
Type: behavior Stage: resolved
Components: IO Versions: Python 2.7
Status: closed Resolution: not a bug
Dependencies: Superseder:
Assigned To: Nosy List: ronaldoussoren, sverrirab
Priority: normal Keywords:

Created on 2018-08-10 11:43 by sverrirab, last changed 2022-04-11 14:59 by admin. This issue is now closed.

File name Uploaded Description Edit sverrirab, 2018-08-10 11:43 simple code that triggers issue
readwrite.c ronaldoussoren, 2018-08-10 13:12
Messages (3)
msg323365 - (view) Author: Sverrir Berg (sverrirab) Date: 2018-08-10 11:43
Reading a file that is at eof causes the file reading to halt indefinitely.
1) open() a file and read() everything from it.
2) call read() a second time - reading nothing (this causes the issue).
3) append to the file (using another file handle or manually).
4) try to read it again - read() always returns nothing.

Attached is a a test causing this - works correctly on Ubuntu 2.7.12/3.5.2, macos 3.7.0, macos PyPy 5.10.0 but fails on macos 2.7.10/2.7.15(brew)

I assume the expected behaviour is the same as on the other versions where you can continue to read from the file when it has been appended to?
msg323367 - (view) Author: Ronald Oussoren (ronaldoussoren) * (Python committer) Date: 2018-08-10 12:05
This is IMHO not a bug in CPython (or even macOS).  On Python 2.7 file I/O is implemented using C's stdio library and that prescribes this behaviour (the "at EOF" state of a file stream is sticky., 2) should unset the "at EOF" flag.
msg323369 - (view) Author: Ronald Oussoren (ronaldoussoren) * (Python committer) Date: 2018-08-10 13:12
For completeness sake I've attached a C program demonstrating the same problem.
Date User Action Args
2022-04-11 14:59:04adminsetgithub: 78552
2021-06-18 17:01:16iritkatrielsetstatus: pending -> closed
stage: resolved
2018-08-10 13:12:19ronaldoussorensetstatus: open -> pending
2018-08-10 13:12:14ronaldoussorensetfiles: + readwrite.c
status: pending -> open
messages: + msg323369
2018-08-10 12:05:54ronaldoussorensetstatus: open -> pending

nosy: + ronaldoussoren
messages: + msg323367

resolution: not a bug
2018-08-10 11:43:14sverrirabcreate