Steven D'Aprano <[email protected]> added the comment:
You say:
> after process python3 test_case.py
> json file's content like this
>
> @@@@@@@@@@{"how_dare_you": "how_dare_you"}
I cannot replicate that result.
I created a "data.json" with the following content:
```
>>> with open(FILE_PATH, 'w') as f:
... f.write('{"how_dare_you": "how_dare_you"}\n')
...
33
>>> with open(FILE_PATH, 'r') as f:
... print(f.read())
...
{"how_dare_you": "how_dare_you"}
```
Then I ran your `test` function and the only result was to delete the newline
at the end of the file:
```
>>> test()
beginning tell 0
tell after read 33
tell after delete content 33
content 0
tell after write 65
content 0
>>>
>>> with open(FILE_PATH, 'r') as f:
... print(f.read())
...
{"how_dare_you": "how_dare_you"}
>>>
```
So I cannot replicate your reported bug. There is no sign of any garbage
characters inserted at the start of the file as you state.
----------
nosy: +steven.daprano
_______________________________________
Python tracker <[email protected]>
<https://bugs.python.org/issue42733>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com