diff mbox series

Fix YAML loader warning

Message ID 20190315062740.5914-1-dja@axtens.net
State Accepted
Headers show
Series Fix YAML loader warning | expand

Commit Message

Daniel Axtens March 15, 2019, 6:27 a.m. UTC
In my tests I'm seeing:
/home/patchwork/patchwork/patchwork/tests/api/validator.py:229:
YAMLLoadWarning: calling yaml.load() without Loader=... is deprecated,
as the default Loader is unsafe. Please read https://msg.pyyaml.org/load
for full details.

Fix this by using the safe loader in the tests.

Signed-off-by: Daniel Axtens <dja@axtens.net>
---
 patchwork/tests/api/validator.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Stephen Finucane March 21, 2019, 1:19 p.m. UTC | #1
On Fri, 2019-03-15 at 17:27 +1100, Daniel Axtens wrote:
> In my tests I'm seeing:
> /home/patchwork/patchwork/patchwork/tests/api/validator.py:229:
> YAMLLoadWarning: calling yaml.load() without Loader=... is deprecated,
> as the default Loader is unsafe. Please read https://msg.pyyaml.org/load
> for full details.
> 
> Fix this by using the safe loader in the tests.
> 
> Signed-off-by: Daniel Axtens <dja@axtens.net>

Good call.

Reviewed-by: Stephen Finucane <stephen@that.guru>

and applied.

Stephen
diff mbox series

Patch

diff --git a/patchwork/tests/api/validator.py b/patchwork/tests/api/validator.py
index 3f13847..ad4d7f1 100644
--- a/patchwork/tests/api/validator.py
+++ b/patchwork/tests/api/validator.py
@@ -226,7 +226,7 @@  def _load_spec(version):
                              'patchwork.yaml')
 
     with open(spec_path, 'r') as fh:
-        data = yaml.load(fh)
+        data = yaml.load(fh, Loader=yaml.SafeLoader)
 
     _LOADED_SPECS[version] = openapi_core.create_spec(data)