[OE-core] [PATCH] package_rpm.bbclass: support packaging of symlinks to directories

Patrick Ohly patrick.ohly at intel.com
Wed Feb 18 08:43:30 UTC 2015


On Tue, 2015-02-17 at 08:55 -0700, Christopher Larson wrote:
> 
> On Tue, Feb 17, 2015 at 6:42 AM, Patrick Ohly <patrick.ohly at intel.com>
> wrote:
>         +            # Treat all symlinks to directories as normal
>         files.
>         +            # os.walk() lists them as directories.
>         +            for i, entry in enumerate(dirs):
>         +                if os.path.islink(os.path.join(rootpath,
>         entry)):
>         +                    del dirs[i]
>         +                    files.append(entry)
>         +
> 
> You're deleting elements of a list while you're iterating over it. I'm
> fairly certain that will lead to pain, unless you explicitly ensure
> you're operating against a copy: for i, entry in
> enumerate(list(dirs)):

I was wondering about that myself, but couldn't find any definite
statement about whether it's okay or not for enumerate(). It works in
practice, but of course that doesn't guarantee that it is okay.

Iterating backwards will be more obviously correct, I'll send a patch
update using that.

I'm still curious, though, whether the code above is really broken or
just dubious because one cannot be certain.

-- 
Best Regards, Patrick Ohly

The content of this message is my personal opinion only and although
I am an employee of Intel, the statements I make here in no way
represent Intel's position on the issue, nor am I authorized to speak
on behalf of Intel on this matter.






More information about the Openembedded-core mailing list