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.

classification
Title: cygwin treats X and X.exe as the same file
Type: behavior Stage: resolved
Components: Windows Versions: Python 3.6
process
Status: closed Resolution: third party
Dependencies: Superseder:
Assigned To: Nosy List: Anthony Sottile, paul.moore, steve.dower, tim.golden, zach.ware
Priority: normal Keywords:

Created on 2019-01-03 16:53 by Anthony Sottile, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Messages (4)
msg332935 - (view) Author: Anthony Sottile (Anthony Sottile) * Date: 2019-01-03 16:53
>>> with open('f.exe', 'w') as f:
...     f.write('hi')
...
>>> with open('f') as f:
...     print(f.read())
...
hi


`os.path.exists(...)` and others treat them as the same file as well.  It seems the only reliable way to write both files is:

1. write to f.exe
2. write to f.bak
3. move f.bak to f (`os.rename`)
msg332937 - (view) Author: Anthony Sottile (Anthony Sottile) * Date: 2019-01-03 17:06
ah yes, I should include more version information

IEUser@IE11WIN7 ~
$ python --version
Python 2.7.14

IEUser@IE11WIN7 ~
$ python3 --version --version
Python 3.6.4 (default, Jan  7 2018, 17:45:56)
[GCC 6.4.0]


IEUser@IE11WIN7 ~
$ uname -a
CYGWIN_NT-6.1 IE11WIN7 2.11.2(0.329/5/3) 2018-11-08 14:30 i686 Cygwin
msg332938 - (view) Author: Zachary Ware (zach.ware) * (Python committer) Date: 2019-01-03 17:08
This sounds like a Cygwin issue; what can Python do about it?

From a Cygwin shell:

$ ls

$ echo "test.exe" >> test.exe

$ echo "test" >> test

$ cat test
test.exe
test
msg332939 - (view) Author: Anthony Sottile (Anthony Sottile) * Date: 2019-01-03 17:12
hmmm probably nothing in that case -- didn't realize this also happened in the cygwin shell.

insanity.

feel free to close!  thanks!
History
Date User Action Args
2022-04-11 14:59:09adminsetgithub: 79831
2019-01-03 17:13:19zach.waresetstatus: open -> closed
resolution: third party
stage: resolved
2019-01-03 17:12:32Anthony Sottilesetmessages: + msg332939
2019-01-03 17:08:10zach.waresetmessages: + msg332938
2019-01-03 17:06:20Anthony Sottilesetmessages: + msg332937
2019-01-03 16:53:56Anthony Sottilecreate