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.

Author liu chang
Recipients Antony.Lee, Arfrever, liu chang, pitrou
Date 2015-01-01.18:42:50
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1420137771.22.0.602030937365.issue23076@psf.upfronthosting.co.za>
In-reply-to
Content
hi pitrou, should we fix it in _make_selector(pattern_parts) function? 
origin code as:

def _make_selector(pattern_parts):
    pat = pattern_parts[0]
    child_parts = pattern_parts[1:]
    if pat == '**':
        cls = _RecursiveWildcardSelector
    elif '**' in pat:
        raise ValueError("Invalid pattern: '**' can only be an entire path component")
    elif _is_wildcard_pattern(pat):
        cls = _WildcardSelector
    else:
        cls = _PreciseSelector
    return cls(pat, child_parts)

Is it a good fix that: check the length of pattern_parts, if its length < 2, we set pat to empty str, set child_parts to a empty list。

A simple code like:

def _make_selector(pattern_parts):
    try:
        pat = pattern_parts[0]
        child_parts = pattern_parts[1:]
    except IndexError:
        pat = ""
        child_parts = []
    if pat == '**':
        cls = _RecursiveWildcardSelector
    elif '**' in pat:
        raise ValueError("Invalid pattern: '**' can only be an entire path component")
    elif _is_wildcard_pattern(pat):
        cls = _WildcardSelector
    else:
        cls = _PreciseSelector
    return cls(pat, child_parts)
History
Date User Action Args
2015-01-01 18:42:51liu changsetrecipients: + liu chang, pitrou, Arfrever, Antony.Lee
2015-01-01 18:42:51liu changsetmessageid: <1420137771.22.0.602030937365.issue23076@psf.upfronthosting.co.za>
2015-01-01 18:42:51liu changlinkissue23076 messages
2015-01-01 18:42:50liu changcreate