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: Write file failed on OS X 10.15.4
Type: behavior Stage: resolved
Components: IO, macOS Versions: Python 3.7
Status: closed Resolution: not a bug
Dependencies: Superseder:
Assigned To: Nosy List: ned.deily, remi.lapeyre, ronaldoussoren, 韩振宇
Priority: normal Keywords:

Created on 2020-05-02 11:49 by 韩振宇, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Messages (3)
msg367927 - (view) Author: 韩振宇 (韩振宇) Date: 2020-05-02 11:49
When I write a long file using write() function, the resulting file is truncated into some specific level when the file is newly establised. However, when the file is existing, the full length can be achieved.

Here is the example code:

f = open('test_output','w')
length = 195364
for i in range(length):

On my macOS 10.15.4 and conda virtual environment
conda create -n test python=3.7.4

When the test_output file is not existing, the content of the file is truncated into 195280, while i is 195364 after the writing process.

Then I re-run the code without deleting the file, the output is normal.
msg367928 - (view) Author: Rémi Lapeyre (remi.lapeyre) * Date: 2020-05-02 12:09
Hi, I can't reproduce the issue but the fact that you did not close the file is suspicious. What does 

with open('test_output','w') as f:
    length = 195364
    for i in range(length):

msg367929 - (view) Author: 韩振宇 (韩振宇) Date: 2020-05-02 12:34
After f.close() it apperas. That's my fault. Thank you.
Date User Action Args
2022-04-11 14:59:30adminsetgithub: 84656
2020-05-02 12:43:11韩振宇setstatus: open -> closed
stage: resolved
2020-05-02 12:34:32韩振宇setresolution: not a bug
2020-05-02 12:34:23韩振宇setmessages: + msg367929
2020-05-02 12:09:33remi.lapeyresetnosy: + remi.lapeyre
messages: + msg367928
2020-05-02 11:50:59韩振宇setnosy: + ronaldoussoren, ned.deily
type: behavior
components: + macOS
2020-05-02 11:49:13韩振宇create