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: Windows filepath bug
Type: behavior Stage: resolved
Components: IO, Windows Versions: Python 3.10, Python 3.9, Python 3.8, Python 3.7, Python 3.6
process
Status: closed Resolution: not a bug
Dependencies: Superseder:
Assigned To: Nosy List: eryksun, parsampsh, paul.moore, steve.dower, tim.golden, zach.ware
Priority: normal Keywords:

Created on 2021-03-14 12:54 by parsampsh, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Messages (5)
msg388672 - (view) Author: parsa mpsh (parsampsh) * Date: 2021-03-14 12:54
I was testing my program in github workflow and i detected a bug. i was opening a file in windows:

```
f = open(os.path.dirname(__FILE__) + '/some/file.txt')
```

means the file path will be `C:\some\path/some/file.txt`.

but i received OSError. why? because in the above path, we have both `/` and `\`.

I think this bug should be fixed by converting all of `/`s to `\` in file paths automatic.
msg388673 - (view) Author: parsa mpsh (parsampsh) * Date: 2021-03-14 12:55
Update: i only tested this bug in `3.6` and `3.7` i'm not sure about newer versions. but i think this bug also is in them.
msg388674 - (view) Author: parsa mpsh (parsampsh) * Date: 2021-03-14 12:56
I think this bug should be fixed by converting all of `/`s to `\` in file paths automatic **When os is windows**.
msg388675 - (view) Author: Eryk Sun (eryksun) * (Python triager) Date: 2021-03-14 13:28
"C:\some\path/some/file.txt" is a valid file path. The Windows file API normalizes most paths, except for verbatim paths that start with exactly "\\?\". Path normalization includes replacing forward slashes with backslashes.

If you provide the complete traceback, I may be able to help diagnose the problem, but not here. Please ask for help on https://discuss.python.org/c/users or https://mail.python.org/mailman/listinfo/python-list.
msg388676 - (view) Author: parsa mpsh (parsampsh) * Date: 2021-03-14 16:02
Yes. i checked it more. looks problem was from other thing, not the path.
History
Date User Action Args
2022-04-11 14:59:42adminsetgithub: 87657
2021-03-14 16:02:58parsampshsetmessages: + msg388676
2021-03-14 13:28:27eryksunsetstatus: open -> closed

nosy: + eryksun
messages: + msg388675

resolution: not a bug
stage: resolved
2021-03-14 13:10:46parsampshsetcomponents: + IO
2021-03-14 12:56:55parsampshsetmessages: + msg388674
2021-03-14 12:55:28parsampshsetmessages: + msg388673
2021-03-14 12:54:39parsampshcreate