[New-bugs-announce] [issue35314] fnmatch failed with leading caret (^)
Cyker Way
report at bugs.python.org
Mon Nov 26 05:58:12 EST 2018
New submission from Cyker Way <cykerway at gmail.com>:
In short, `fnmatch.fnmatch` doesn't match shell result. To test this, create a dir with 2 files: `a.py` and `b.py`. Then `ls [!b].py` and `ls [^b].py` will both show `a.py`. However, `fnmatch.fnmatch('a.py', '[!b].py')` returns `True` but `fnmatch.fnmatch('a.py', '[^b].py')` returns `False`.
Problem seems to come from an escaped caret: https://github.com/python/cpython/blob/master/Lib/fnmatch.py#L124
I don't see why caret and exclamation mark are different from `man bash`:
> ...If the first character following the [ is a ! or a ^ then any character not enclosed is matched...
Could someone please confirm it's a bug or intended behavior?
----------
components: Library (Lib)
messages: 330417
nosy: cykerway
priority: normal
severity: normal
status: open
title: fnmatch failed with leading caret (^)
versions: Python 3.7
_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue35314>
_______________________________________
More information about the New-bugs-announce
mailing list