From 871a76ff9f4e437aac5f5c68ed7654543a654fa1 Mon Sep 17 00:00:00 2001 From: Niall Grant Date: Tue, 23 Apr 2019 09:26:35 +0100 Subject: [PATCH] Upgrade to PyYaml 5.1 (#681) Updates the PyYaml version to 5.1. Adds in YamlLoader as per https://github.com/yaml/pyyaml/issues/292 Other incompatible changes were reviewed (https://github.com/yaml/pyyaml/issues/265) and the yaml.Loader appears to the be only concern for now. [Resolves #665] --- requirements.txt | 2 +- sceptre/cli/helpers.py | 14 ++++++++------ setup.py | 2 +- 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/requirements.txt b/requirements.txt index 3390d6993..421519c63 100644 --- a/requirements.txt +++ b/requirements.txt @@ -15,7 +15,7 @@ packaging==16.8 pygments==2.2.0 pytest-runner>=3.0.0,<3.1.0 pytest>=3.2.0,<3.3.0 -PyYaml>=4.2b1,<5.0 +PyYaml>=5.1,<6.0 readme-renderer>=24.0 setuptools>=40.6.2 six>=1.11.0,<2.0.0 diff --git a/sceptre/cli/helpers.py b/sceptre/cli/helpers.py index 060618bfc..937ce36ba 100644 --- a/sceptre/cli/helpers.py +++ b/sceptre/cli/helpers.py @@ -112,19 +112,21 @@ def _generate_yaml(stream): try: if isinstance(item, dict): items.append( - yaml.safe_dump(item, default_flow_style=False, explicit_start=True) + yaml.safe_dump(item, default_flow_style=False, explicit_start=True) ) else: items.append( - yaml.safe_dump( - yaml.load(item), default_flow_style=False, explicit_start=True) + yaml.safe_dump( + yaml.load(item, Loader=yaml.FullLoader), + default_flow_style=False, explicit_start=True + ) ) except Exception: print("An error occured whilst writing the YAML object.") return yaml.safe_dump( - [yaml.load(item) for item in items], - default_flow_style=False, explicit_start=True - ) + [yaml.load(item, Loader=yaml.FullLoader) for item in items], + default_flow_style=False, explicit_start=True + ) else: try: return yaml.safe_loads(stream) diff --git a/setup.py b/setup.py index 9c6bf934b..e8d8e0c06 100755 --- a/setup.py +++ b/setup.py @@ -13,7 +13,7 @@ install_requirements = [ "boto3>=1.3,<2.0", "click==7.0", - "PyYaml>=4.2b1,<5.0", + "PyYaml>=5.1,<6.0", "Jinja2>=2.8,<3", "packaging==16.8", "colorama==0.3.9",