Message91398
Hello,
at the moment, fnmatch.fnmatch() will fail to match any string, which
has \n character. This of course breaks glob as well.
Example
> import fnmatch
> fnmatch.fnmatch("foo\nbar", "foo*")
False
> import glob
> open("foobar", "w").close()
> open("foo\nbar", "w").close()
> glob.glob("foo*")
['foobar']
while the expected result is ['foobar', 'foo\nbar']. The standard C
fnmatch function from fnmatch.h is behaving correctly i.e. this code
will print out "match!"
#include <fnmatch.h>
#include <stdio.h>
int main()
{
if (fnmatch("foo*", "foo\nbar", FNM_NOESCAPE) == 0)
printf("match!\n");
else
printf("fail!\n");
return 0;
}
This misbehaviour is caused by the fnmatch.translate() which adds $ to
the end of the regexp. Without the ending $ the fnmatch function works OK. |
|
Date |
User |
Action |
Args |
2009-08-07 09:49:20 | rajcze | set | recipients:
+ rajcze |
2009-08-07 09:49:19 | rajcze | set | messageid: <1249638559.7.0.0574356115412.issue6665@psf.upfronthosting.co.za> |
2009-08-07 09:49:16 | rajcze | link | issue6665 messages |
2009-08-07 09:49:14 | rajcze | create | |
|