[PATCH 1 of 3] import-checker: refactor sys.path prefix check (issue4129)
Chris Jerdonek
chris.jerdonek at gmail.com
Tue Dec 24 17:54:16 CST 2013
On Tue, Dec 24, 2013 at 2:52 PM, Augie Fackler <raf at durin42.com> wrote:
>
> On Dec 24, 2013, at 5:45 PM, Augie Fackler <raf at durin42.com> wrote:
>
>>
>> On Dec 23, 2013, at 12:34 AM, Chris Jerdonek <chris.jerdonek at gmail.com> wrote:
>>
>>>
>>> for libpath in sys.path:
>>> - # We want to walk everything in sys.path that starts with
>>> - # either sys.prefix or sys.exec_prefix.
>>> - if not (libpath.startswith(sys.prefix)
>>> - or libpath.startswith(sys.exec_prefix)):
>>> + # We want to walk everything in sys.path that starts with something
>>> + # in stdlib_prefixes.
>>> + for prefix in stdlib_prefixes:
>>> + if libpath.startswith(prefix):
>>> + break
>>> + else:
>>> continue
>>
>> This file already depends on 2.6isms (the ast module), so perhaps we could use any() here and avoid the slightly-awkward-to-me for/else? I think it might read more clearly.
>
> After looking at the rest of the series, I'm crewing it with my own follow-up patch to use any() on a genexp instead of the for/break/else/continue trick. Thanks for following up on this!
Great, thanks, Augie!
--Chris
More information about the Mercurial-devel
mailing list