[docs] glob returns empty list with "[" character in the folder name (issue 8402)

storchaka at gmail.com storchaka at gmail.com
Mon Oct 15 12:12:24 CEST 2012


http://bugs.python.org/review/8402/diff/6281/Doc/library/fnmatch.rst
File Doc/library/fnmatch.rst (right):

http://bugs.python.org/review/8402/diff/6281/Doc/library/fnmatch.rst#newcode76
Doc/library/fnmatch.rst:76: arbitrary literal string that may have
special characters in it.
On 2012/10/15 11:21:37, ezio.melotti wrote:
> This could mention what the special characters are.

The special characters exposed in the table above.

http://bugs.python.org/review/8402/diff/6281/Doc/library/fnmatch.rst#newcode86
Doc/library/fnmatch.rst:86: True
On 2012/10/15 11:21:37, ezio.melotti wrote:
> I'm not sure that showing the output is useful.  The *-[[] seems a bit
confusing
> if you don't know how escaping works.

Is '.*\\.txt$' below less confusing? Well, I'll remove it. May be worth
to remove the entire "escape()" example?

> If you want to show it, it might be better to escape a pattern that
contains
> '?'.

Unhappy non-escaped '?' matches literal '?'. We should use negative
example (not matching '?').

'file_locked-[Converted].png' is a real file from Nuvola icon theme. Can
you give a good example with and without '?'?

http://bugs.python.org/review/8402/diff/6281/Lib/fnmatch.py
File Lib/fnmatch.py (right):

http://bugs.python.org/review/8402/diff/6281/Lib/fnmatch.py#newcode82
Lib/fnmatch.py:82: _magic_check_bytes = re.compile(b'([*?[])')
On 2012/10/15 11:21:37, ezio.melotti wrote:
> I would put these two before the function definition, adding a comment
that
> explains that escaping is done by wrapping any of *?[ between square
brackets.
> 

Agree.

http://bugs.python.org/review/8402/diff/6281/Lib/test/test_fnmatch.py
File Lib/test/test_fnmatch.py (right):

http://bugs.python.org/review/8402/diff/6281/Lib/test/test_fnmatch.py#newcode53
Lib/test/test_fnmatch.py:53: check('abc', escape('a*'), False)
On 2012/10/15 11:21:37, ezio.melotti wrote:
> I would also check escape() directly, rather than doing it only
through check().
>  Checking for invalid inputs is a good idea too.

What do you mean "invalid input"? Test already contains negative
matches. Any input for escape() is valid.

http://bugs.python.org/review/8402/


More information about the docs mailing list