classification
Title: Test Glob: files starting with .
Type: enhancement Stage: resolved
Components: Tests Versions: Python 3.4, Python 3.2, Python 3.3, Python 2.7
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: Sebastian.Kreft, eric.araujo, hynek, pitrou, python-dev, serhiy.storchaka, tarek
Priority: normal Keywords: patch

Created on 2012-12-11 18:25 by Sebastian.Kreft, last changed 2012-12-16 11:52 by hynek. This issue is now closed.

Files
File name Uploaded Description Edit
python.patch Sebastian.Kreft, 2012-12-11 18:25
Messages (8)
msg177345 - (view) Author: Sebastian Kreft (Sebastian.Kreft) Date: 2012-12-11 18:25
Please find attached a patch to improve the test cases for the glob module. It adds test cases for files starting with '.'.
msg177347 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2012-12-11 19:04
See also issue16618.
msg177422 - (view) Author: √Čric Araujo (eric.araujo) * (Python committer) Date: 2012-12-13 17:11
Hm, unix shells have different rules about matching a leading dot or not.  Are the docs clear about Python's glob's rules?
msg177428 - (view) Author: Sebastian Kreft (Sebastian.Kreft) Date: 2012-12-13 18:00
The docs don't say anything about it. However the code is there (docs bug probably). 

See the following lines in glob.py:
    57     if pattern[0] != '.':
    58         names = [x for x in names if x[0] != '.']
    59     return fnmatch.filter(names, pattern)

The documentation is even harder to follow.

The glob docs say:
"The pattern may contain simple shell-style wildcards a la fnmatch."

but the fnmatch docs say:
"Similarly, filenames starting with a period are not special for this module, and are matched by the * and ? patterns."


The posix standard states that "if a filename begins with a period ( '.' ), the period shall be explicitly matched"
(http://pubs.opengroup.org/onlinepubs/009695399/utilities/xcu_chap02.html#tag_02_13_03).
msg177547 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2012-12-15 18:53
The patch looks good to me. The docs may need improving but that's a separate concern.
(also, the current behaviour is reasonable, and there is certainly existing code relying on it)
msg177586 - (view) Author: Hynek Schlawack (hynek) * (Python committer) Date: 2012-12-16 11:35
Patch LGTM and will be applied, I have opened issue16695 for the related update of the docs.

BTW how did you create the patch? The bugtracker/Rietveld didn't recognize it for review and applying it took some effort too.
msg177588 - (view) Author: Roundup Robot (python-dev) Date: 2012-12-16 11:49
New changeset 028ecc3900f5 by Hynek Schlawack in branch '2.7':
#16664: Add regression tests for glob's behaviour concerning "."-entries
http://hg.python.org/cpython/rev/028ecc3900f5

New changeset 29f0c45ce576 by Hynek Schlawack in branch '3.2':
#16664: Add regression tests for glob's behaviour concerning "."-entries
http://hg.python.org/cpython/rev/29f0c45ce576

New changeset f646842023b3 by Hynek Schlawack in branch '3.3':
#16664: Add regression tests for glob's behaviour concerning "."-entries
http://hg.python.org/cpython/rev/f646842023b3

New changeset 1fb39efcc3dd by Hynek Schlawack in branch 'default':
#16664: Add regression tests for glob's behaviour concerning "."-entries
http://hg.python.org/cpython/rev/1fb39efcc3dd
msg177589 - (view) Author: Hynek Schlawack (hynek) * (Python committer) Date: 2012-12-16 11:52
Thank you for your patch and welcome to CPython core development!

Presuming you want to submit more patches in future, please take the time to sign a Python contributor agreement: http://www.python.org/psf/contrib/ . You'll get a pretty star next to your name in the bug tracker in return. ;)
History
Date User Action Args
2012-12-16 11:52:30hyneksetstatus: open -> closed
resolution: fixed
messages: + msg177589

stage: commit review -> resolved
2012-12-16 11:49:03python-devsetnosy: + python-dev
messages: + msg177588
2012-12-16 11:35:24hyneksettype: enhancement
messages: + msg177586
title: [PATCH] Test Glob: files starting with . -> Test Glob: files starting with .
2012-12-15 18:53:40pitrousetversions: + Python 2.7, Python 3.2, Python 3.3
nosy: + hynek, pitrou, tarek

messages: + msg177547

stage: commit review
2012-12-13 18:00:15Sebastian.Kreftsetmessages: + msg177428
2012-12-13 17:11:53eric.araujosetnosy: + eric.araujo

messages: + msg177422
versions: - Python 3.5
2012-12-11 19:04:11serhiy.storchakasetnosy: + serhiy.storchaka
messages: + msg177347
2012-12-11 18:25:32Sebastian.Kreftcreate