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: fnmatch.fnmatch normalizes slashes/backslashes on Windows
Type: behavior Stage: resolved
Components: Documentation, Library (Lib), Windows Versions: Python 3.7, Python 3.6, Python 3.5, Python 2.7
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: docs@python Nosy List: Mariatta, The Compiler, docs@python, eric.araujo, ezio.melotti, georg.brandl, paul.moore, r.david.murray, steve.dower, tim.golden, zach.ware
Priority: normal Keywords: easy

Created on 2015-10-15 06:04 by The Compiler, last changed 2022-04-11 14:58 by admin. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 1535 merged cheryl.sabella, 2017-05-10 14:42
PR 2065 merged Mariatta, 2017-06-10 04:42
PR 2066 merged Mariatta, 2017-06-10 04:44
PR 2067 merged Mariatta, 2017-06-10 04:50
Messages (9)
msg253030 - (view) Author: Florian Bruhin (The Compiler) * Date: 2015-10-15 06:04
On Windows 8:

>>> fnmatch.fnmatch(r'foo\bar', 'foo/bar')
True
>>> fnmatch.fnmatchcase(r'foo\bar', 'foo/bar')
False

This is due to fnmatch calling os.path.normpath on the arguments (to get the case-sensitivity of the filesystem), which on Windows *also* happens to normalize / to \.

It's probably a bad idea to change the behaviour now, but I think at least this should be clarified in the docs.
msg253040 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2015-10-15 10:56
I think the existing behavior is the desirable behavior, but in any case as you say it is too late to change it.  The docs should indeed be clarified by changing the wording to indicate that fnmatch calls normcase but fnmatchcase does not, with a link to normcase (which in turn documents the windows behavior).
msg293423 - (view) Author: Florian Bruhin (The Compiler) * Date: 2017-05-10 14:57
https://github.com/python/cpython/pull/1535 seems to be the correct PR, not 1634.
msg293427 - (view) Author: Mariatta (Mariatta) * (Python committer) Date: 2017-05-10 15:46
Yes, PR 1535 is indeed linked to this issue, if you're reading it from the bug tracker.

The pull request number you see from the notification email (+1634) refers to the pull_request item in the bug tracker (https://bugs.python.org/pull_request1634).

This number is different than the pull request # on GitHub.

Hope this clarifies it :)

See also discussions about it:
https://github.com/python/core-workflow/issues/35
http://psf.upfronthosting.co.za/roundup/meta/issue624
(I was confused about it too)
msg295609 - (view) Author: Mariatta (Mariatta) * (Python committer) Date: 2017-06-10 04:42
New changeset e5f6e86c48c7b2eb9e1d6a0e72867b4d8b4720f3 by Mariatta (csabella) in branch 'master':
bpo-25409: Clarify fnmatch and fnmatchcase documentation (GH-1535)
https://github.com/python/cpython/commit/e5f6e86c48c7b2eb9e1d6a0e72867b4d8b4720f3
msg295638 - (view) Author: Mariatta (Mariatta) * (Python committer) Date: 2017-06-10 14:25
New changeset 76eabd3a21dc578de6093d45dd8d69a5ec4b9afe by Mariatta in branch '3.6':
bpo-25409: Clarify fnmatch and fnmatchcase documentation (GH-1535) (GH-2065)
https://github.com/python/cpython/commit/76eabd3a21dc578de6093d45dd8d69a5ec4b9afe
msg295639 - (view) Author: Mariatta (Mariatta) * (Python committer) Date: 2017-06-10 14:26
New changeset 656f232131e7a49800662119c7f9b8078729e697 by Mariatta in branch '3.5':
bpo-25409: Clarify fnmatch and fnmatchcase documentation (GH-1535) (GH-2066)
https://github.com/python/cpython/commit/656f232131e7a49800662119c7f9b8078729e697
msg295640 - (view) Author: Mariatta (Mariatta) * (Python committer) Date: 2017-06-10 14:26
New changeset 9660a7e4bbc3932846fcde0e31856b5b3908b834 by Mariatta in branch '2.7':
bpo-25409: Clarify fnmatch and fnmatchcase documentation (GH-1535) (GH-2067)
https://github.com/python/cpython/commit/9660a7e4bbc3932846fcde0e31856b5b3908b834
msg295641 - (view) Author: Mariatta (Mariatta) * (Python committer) Date: 2017-06-10 14:27
This has been fixed, and backported to 2.7, 3.5, and 3.6.

Thanks :)
History
Date User Action Args
2022-04-11 14:58:22adminsetgithub: 69595
2017-06-10 14:27:45Mariattasetstatus: open -> closed
resolution: fixed
messages: + msg295641

stage: patch review -> resolved
2017-06-10 14:26:41Mariattasetmessages: + msg295640
2017-06-10 14:26:11Mariattasetmessages: + msg295639
2017-06-10 14:25:35Mariattasetmessages: + msg295638
2017-06-10 04:50:08Mariattasetpull_requests: + pull_request2131
2017-06-10 04:44:43Mariattasetpull_requests: + pull_request2130
2017-06-10 04:42:54Mariattasetpull_requests: + pull_request2129
2017-06-10 04:42:13Mariattasetmessages: + msg295609
2017-05-10 15:46:35Mariattasetversions: + Python 3.7, - Python 3.4
nosy: + Mariatta

messages: + msg293427

stage: needs patch -> patch review
2017-05-10 14:57:06The Compilersetmessages: + msg293423
2017-05-10 14:42:58cheryl.sabellasetpull_requests: + pull_request1634
2016-01-01 04:12:53ezio.melottisetkeywords: + easy
assignee: docs@python

components: + Documentation, Windows
nosy: + docs@python
2015-10-15 10:56:21r.david.murraysetversions: + Python 3.4, Python 3.6
nosy: + r.david.murray

messages: + msg253040

stage: needs patch
2015-10-15 06:04:51The Compilercreate