This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Infinite recursion in glob.glob('*:') on Windows
Type: behavior Stage: resolved
Components: Library (Lib), Windows Versions: Python 3.2, Python 3.3, Python 3.4, Python 2.7
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: eric.araujo, pitrou, python-dev, serhiy.storchaka
Priority: normal Keywords: patch

Created on 2012-12-06 11:17 by serhiy.storchaka, last changed 2022-04-11 14:57 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
glob_magic_in_drive.patch serhiy.storchaka, 2012-12-14 18:21 review
glob_magic_in_drive_test.patch serhiy.storchaka, 2012-12-15 21:36 Test for 3.x review
glob_magic_in_drive_test-2.7_2.patch serhiy.storchaka, 2012-12-15 22:31 Test for 2.7 review
glob_magic_in_drive_2.patch serhiy.storchaka, 2012-12-16 09:03 review
Messages (13)
msg177038 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2012-12-06 11:17
glob.glob() can fall in infinite recursion (causing stack overflow) on Windows with patterns which contains metacharacters in drive or UNC path ('*:foo', r'\\?\c:\bar'). This is my assumption, someone should confirm it on Windows.

Here is a patch, which fix an infinite recursion.
msg177480 - (view) Author: Éric Araujo (eric.araujo) * (Python committer) Date: 2012-12-14 17:55
Patch contains unrelated changes.
msg177486 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2012-12-14 18:21
> Patch contains unrelated changes.

Sorry, my fault.

Here is a cleaned patch.
msg177557 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2012-12-15 20:04
How about adding a test?
msg177565 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2012-12-15 21:36
I have made the test, but I can't run it. Therefore I can't guarantee that the test works.
msg177568 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2012-12-15 22:24
Tests work fine under 3.x, but under 2.7 I get:

======================================================================
FAIL: test_glob_magic_in_drive (test.test_glob.GlobTests)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "C:\t\cpython\lib\test\test_glob.py", line 117, in test_glob_magic_in_dri
ve
    eq(glob.glob('\\\\?\\c:\\'), ['\\\\?\\c:\\'])
  File "C:\t\cpython\lib\test\test_glob.py", line 48, in assertSequencesEqual_no
order
    self.assertEqual(set(l1), set(l2))
AssertionError: Items in the second set but not the first:
'\\\\?\\c:\\'
msg177569 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2012-12-15 22:31
Ah, I forgot that splitdrive() on 2.7 does not work with UNC paths. Here is an updated patch.
msg177570 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2012-12-15 22:40
Thank you, the new test works fine.
msg177582 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2012-12-16 09:03
Patch updated with clarified comments.

Are the tests fail on non-fixed Python?
msg177583 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2012-12-16 10:03
> Patch updated with clarified comments.
> 
> Are the tests fail on non-fixed Python?

Yes, they do.
msg177593 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2012-12-16 12:55
New changeset 4af260a54e05 by Antoine Pitrou in branch '3.2':
Issue #16626: Fix infinite recursion in glob.glob() on Windows when the pattern contains a wildcard in the drive or UNC path.
http://hg.python.org/cpython/rev/4af260a54e05

New changeset b90aa7f66e4a by Antoine Pitrou in branch '3.3':
Issue #16626: Fix infinite recursion in glob.glob() on Windows when the pattern contains a wildcard in the drive or UNC path.
http://hg.python.org/cpython/rev/b90aa7f66e4a

New changeset bfb39fb93af7 by Antoine Pitrou in branch 'default':
Issue #16626: Fix infinite recursion in glob.glob() on Windows when the pattern contains a wildcard in the drive or UNC path.
http://hg.python.org/cpython/rev/bfb39fb93af7
msg177594 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2012-12-16 12:57
New changeset b0935ef48186 by Antoine Pitrou in branch '2.7':
Issue #16626: Fix infinite recursion in glob.glob() on Windows when the pattern contains a wildcard in the drive or UNC path.
http://hg.python.org/cpython/rev/b0935ef48186
msg177595 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2012-12-16 12:58
Patches now committed, thank you !
History
Date User Action Args
2022-04-11 14:57:39adminsetgithub: 60830
2012-12-16 12:58:03pitrousetstatus: open -> closed
resolution: fixed
messages: + msg177595

stage: patch review -> resolved
2012-12-16 12:57:33python-devsetmessages: + msg177594
2012-12-16 12:55:59python-devsetnosy: + python-dev
messages: + msg177593
2012-12-16 10:03:02pitrousetmessages: + msg177583
2012-12-16 09:03:57serhiy.storchakasetfiles: + glob_magic_in_drive_2.patch

messages: + msg177582
2012-12-15 22:40:47pitrousetmessages: + msg177570
2012-12-15 22:32:03serhiy.storchakasetfiles: - glob_magic_in_drive_test-2.7.patch
2012-12-15 22:31:24serhiy.storchakasetfiles: + glob_magic_in_drive_test-2.7_2.patch

messages: + msg177569
2012-12-15 22:24:36pitrousetmessages: + msg177568
2012-12-15 21:40:10serhiy.storchakasetfiles: + glob_magic_in_drive_test-2.7.patch
2012-12-15 21:36:38serhiy.storchakasetfiles: + glob_magic_in_drive_test.patch

messages: + msg177565
2012-12-15 20:04:18pitrousetnosy: + pitrou
messages: + msg177557
2012-12-14 18:22:08serhiy.storchakasetfiles: - glob_magic_in_drive.patch
2012-12-14 18:21:07serhiy.storchakasetfiles: + glob_magic_in_drive.patch

messages: + msg177486
2012-12-14 17:55:59eric.araujosetnosy: + eric.araujo
messages: + msg177480
2012-12-06 11:17:19serhiy.storchakacreate