This is an archive of the discontinued LLVM Phabricator instance.

Update pyyaml to fix build failure with Python 3.9
ClosedPublic

Authored by thopre on Sep 3 2021, 4:32 AM.

Details

Summary

Upgrade pyyaml to the latest bugfix release for the next stable version:
5.1.2. This fixes a build failure when Python is 3.9. This requires
migrating to yaml.safe_load to avoid warnings due to the use of unsafe
load() method.

Diff Detail

Repository
rLNT LNT

Event Timeline

thopre requested review of this revision.Sep 3 2021, 4:32 AM
thopre created this revision.

Hmm the last time I upgraded pyyaml it started complaining about the interface we're using being insecure and a security issue. is that no longer the case?

I remember it required slight tweaking.

thopre added a comment.Sep 3 2021, 4:47 AM

Hmm the last time I upgraded pyyaml it started complaining about the interface we're using being insecure and a security issue. is that no longer the case?

I remember it required slight tweaking.

I didn't get any warning, except for pip complaining about being run as root but that's a separate issue

tnfchris accepted this revision.Sep 3 2021, 4:53 AM

Hmm the last time I upgraded pyyaml it started complaining about the interface we're using being insecure and a security issue. is that no longer the case?

I remember it required slight tweaking.

I didn't get any warning, except for pip complaining about being run as root but that's a separate issue

Hmm ok, It should be giving this warning https://github.com/yaml/pyyaml/wiki/PyYAML-yaml.load(input)-Deprecation when LNT starts up.

But if you don't see it they might have did something to not require it.. so LGTM then.

This revision is now accepted and ready to land.Sep 3 2021, 4:53 AM
kragniz added a subscriber: kragniz.Sep 3 2021, 6:41 AM

Running tox with this change results in the warning appearing, for example:

~/git/llvm-lnt/.tox/py3/lib/python3.6/site-packages/lnt/lnttool/admin.py:53: YAMLLoadWarning: calling yaml.load() without Loader=... is deprecated, as the default Loader is unsafe. Please read https://msg.pyyaml.org/load for full details.

I'd recommend switching the couple of yaml.load calls with yaml.safe_load.

thopre updated this revision to Diff 370575.Sep 3 2021, 6:59 AM

Move to yaml safe_load() method instead of load()

thopre added a comment.Sep 3 2021, 7:00 AM

Hmm the last time I upgraded pyyaml it started complaining about the interface we're using being insecure and a security issue. is that no longer the case?

I remember it required slight tweaking.

I didn't get any warning, except for pip complaining about being run as root but that's a separate issue

Hmm ok, It should be giving this warning https://github.com/yaml/pyyaml/wiki/PyYAML-yaml.load(input)-Deprecation when LNT starts up.

But if you don't see it they might have did something to not require it.. so LGTM then.

Builds and runs without warning for the current alpine base image (based on Python 3.7).

Hmm the last time I upgraded pyyaml it started complaining about the interface we're using being insecure and a security issue. is that no longer the case?

I remember it required slight tweaking.

I didn't get any warning, except for pip complaining about being run as root but that's a separate issue

Hmm ok, It should be giving this warning https://github.com/yaml/pyyaml/wiki/PyYAML-yaml.load(input)-Deprecation when LNT starts up.

But if you don't see it they might have did something to not require it.. so LGTM then.

I had only run the tests and launched LNT. I see one of the codepath that uses yaml.load is in lnt admin. I've made an updated patch that update all the calls to load to use safe_load instead and it seems to work.

thopre requested review of this revision.Sep 3 2021, 7:00 AM
thopre edited the summary of this revision. (Show Details)

@tnfchris Are you happy with the new patch?

tnfchris accepted this revision.Sep 3 2021, 7:34 AM

Yes, thanks both!

This revision is now accepted and ready to land.Sep 3 2021, 7:34 AM
This revision was automatically updated to reflect the committed changes.