classification
Title: Different glob() results for strings and bytes
Type: behavior Stage: resolved
Components: Library (Lib), 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: hynek, jcea, pitrou, python-dev, serhiy.storchaka
Priority: normal Keywords: patch

Created on 2012-12-05 17:09 by serhiy.storchaka, last changed 2012-12-27 09:40 by hynek. This issue is now closed.

Files
File name Uploaded Description Edit
glob_dotfiles.patch serhiy.storchaka, 2012-12-05 17:09 review
glob_tests-2.7.patch serhiy.storchaka, 2012-12-05 17:22 Tests only for 2.7 review
glob_dotfiles_2.patch serhiy.storchaka, 2012-12-16 19:47 review
glob_tests-2.7_2.patch serhiy.storchaka, 2012-12-16 19:47 review
glob_dotfiles_3.patch serhiy.storchaka, 2012-12-22 18:33 review
glob_tests-2.7_3.patch serhiy.storchaka, 2012-12-22 18:33 review
Messages (12)
msg176991 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2012-12-05 17:09
glob ignores names which starts with dot if pattern is not starts with dot. But this is wrong for bytes pattern in Python 3.

>>> import glob
>>> glob.glob('*hg')
[]
>>> glob.glob(b'*hg')
[b'.hg']

The proposed patch fixes this inconsistency. Also it contains new tests for this and some other possible cases.
msg176992 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2012-12-05 17:22
Python 2.7 is not needed the fix, however additional tests can be useful. Here is a patch.
msg177597 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2012-12-16 13:25
See also issue16696.
msg177617 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2012-12-16 18:09
The patch doesn't apply cleanly.
msg177619 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2012-12-16 18:59
Patches updated to resolve conflicts with recent commits. Some minor test 
errors fixed.
msg177621 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2012-12-16 19:13
Patches updated. Unrelated changes removed.
msg177623 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2012-12-16 19:47
Yet one attempt.
msg177944 - (view) Author: Hynek Schlawack (hynek) * (Python committer) Date: 2012-12-22 15:42
Serhiy, are you going to update your patches? I can implement the feedback of our Q4 Community Service Award awardee too in case you’re busy.
msg177948 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2012-12-22 17:59
Aha! It's OS/2 where glob('*/') returns result without trailing slash. Here also glob() can return str (on 2.7) result for unicode pattern.
msg177949 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2012-12-22 18:33
Here is an updated patches. I hope it satisfies Antoine's comments.
msg178284 - (view) Author: Roundup Robot (python-dev) Date: 2012-12-27 09:25
New changeset 62f67a52b0c2 by Hynek Schlawack in branch '3.2':
#16618: Make glob.glob match consistently across strings and bytes
http://hg.python.org/cpython/rev/62f67a52b0c2

New changeset fa8c4f96d990 by Hynek Schlawack in branch '3.3':
#16618: Make glob.glob match consistently across strings and bytes
http://hg.python.org/cpython/rev/fa8c4f96d990

New changeset eae2a42603ee by Hynek Schlawack in branch 'default':
#16618: Make glob.glob match consistently across strings and bytes
http://hg.python.org/cpython/rev/eae2a42603ee

New changeset 44609ff7e53c by Hynek Schlawack in branch '2.7':
#16618: Add more glob regression tests
http://hg.python.org/cpython/rev/44609ff7e53c
msg178285 - (view) Author: Hynek Schlawack (hynek) * (Python committer) Date: 2012-12-27 09:40
Thanks Serhiy!
History
Date User Action Args
2012-12-27 09:40:54hyneksetstatus: open -> closed
resolution: fixed
messages: + msg178285

stage: patch review -> resolved
2012-12-27 09:25:52python-devsetnosy: + python-dev
messages: + msg178284
2012-12-22 18:33:12serhiy.storchakasetfiles: + glob_dotfiles_3.patch, glob_tests-2.7_3.patch

messages: + msg177949
2012-12-22 17:59:01serhiy.storchakasetmessages: + msg177948
2012-12-22 15:42:57hyneksetmessages: + msg177944
2012-12-16 19:52:37serhiy.storchakasetfiles: - glob_tests-2.7_2.patch
2012-12-16 19:52:23serhiy.storchakasetfiles: - glob_dotfiles_2.patch
2012-12-16 19:47:16serhiy.storchakasetfiles: + glob_dotfiles_2.patch, glob_tests-2.7_2.patch

messages: + msg177623
2012-12-16 19:14:53serhiy.storchakasetfiles: - glob_tests-2.7_2.patch
2012-12-16 19:14:34serhiy.storchakasetfiles: - glob_dotfiles_2.patch
2012-12-16 19:13:53serhiy.storchakasetfiles: + glob_dotfiles_2.patch, glob_tests-2.7_2.patch

messages: + msg177621
2012-12-16 18:59:08serhiy.storchakasetfiles: + glob_dotfiles_2.patch, glob_tests-2.7_2.patch

messages: + msg177619
2012-12-16 18:09:16pitrousetmessages: + msg177617
2012-12-16 13:25:54pitrousetmessages: + msg177597
2012-12-16 11:48:52hyneksetnosy: + hynek
2012-12-15 21:50:39serhiy.storchakasetnosy: + pitrou
2012-12-05 18:20:16jceasetnosy: + jcea
2012-12-05 17:51:49serhiy.storchakalinkissue13968 dependencies
2012-12-05 17:22:38serhiy.storchakasetfiles: + glob_tests-2.7.patch

messages: + msg176992
components: + Tests
versions: + Python 2.7
2012-12-05 17:09:02serhiy.storchakacreate