From 465dadec0b854f7e7e7cdfa9b13ad8186b5ddfbb Mon Sep 17 00:00:00 2001 From: Alexis Ballier Date: Wed, 11 Dec 2019 15:07:18 +0100 Subject: [PATCH] dev-python/rospkg: use yaml.safe_load Package-Manager: Portage-2.3.81, Repoman-2.3.20 Signed-off-by: Alexis Ballier --- dev-python/rospkg/files/yaml_load.patch | 52 +++++++++++++++++++++++++ dev-python/rospkg/rospkg-1.2.0.ebuild | 2 +- dev-python/rospkg/rospkg-9999.ebuild | 2 +- 3 files changed, 54 insertions(+), 2 deletions(-) create mode 100644 dev-python/rospkg/files/yaml_load.patch diff --git a/dev-python/rospkg/files/yaml_load.patch b/dev-python/rospkg/files/yaml_load.patch new file mode 100644 index 000000000000..f56b6db59ad8 --- /dev/null +++ b/dev-python/rospkg/files/yaml_load.patch @@ -0,0 +1,52 @@ +Index: rospkg-1.2.0/src/rospkg/distro.py +=================================================================== +--- rospkg-1.2.0.orig/src/rospkg/distro.py ++++ rospkg-1.2.0/src/rospkg/distro.py +@@ -192,14 +192,14 @@ def load_distro(source_uri): + if os.path.isfile(source_uri): + # load rosdistro file + with open(source_uri) as f: +- raw_data = yaml.load(f.read()) ++ raw_data = yaml.safe_load(f.read()) + else: + try: + request = urlopen(source_uri) + except Exception as e: + raise ResourceNotFound('%s (%s)' % (str(e), source_uri)) + try: +- raw_data = yaml.load(request) ++ raw_data = yaml.safe_load(request) + except ValueError: + raise ResourceNotFound(source_uri) + if not type(raw_data) == dict: +Index: rospkg-1.2.0/test/test_rospkg_distro.py +=================================================================== +--- rospkg-1.2.0.orig/test/test_rospkg_distro.py ++++ rospkg-1.2.0/test/test_rospkg_distro.py +@@ -315,7 +315,7 @@ def test_load_distro_simple(): + + assert distro.release_name == 'simple', distro.release_name + assert distro.version == '1', distro.version +- assert yaml.load(open(p)) == distro.raw_data, distro.raw_data ++ assert yaml.safe_load(open(p)) == distro.raw_data, distro.raw_data + assert set(distro.variants.keys()) == set(['base']) + assert set(distro.stacks.keys()) == set(['stack1']) + +@@ -334,7 +334,7 @@ def test_load_distro_diamondback(): + + assert distro.release_name == 'diamondback', distro.release_name + assert distro.version == 'r8596', distro.version +- assert yaml.load(open(p)) == distro.raw_data, distro.raw_data ++ assert yaml.safe_load(open(p)) == distro.raw_data, distro.raw_data + assert set(distro.variants.keys()) == set(diamondback_variants) + assert set(distro.stacks.keys()) == set(diamondback_stacks), set(distro.stacks.keys()) ^ set(diamondback_stacks) + +@@ -350,7 +350,7 @@ def test_load_distro_diamondback(): + + def test__load_variants(): + from rospkg.distro import _load_variants +- raw_data = yaml.load("""variants: ++ raw_data = yaml.safe_load("""variants: + - ros-base: + stacks: [ros, ros_comm] + - ros-full: diff --git a/dev-python/rospkg/rospkg-1.2.0.ebuild b/dev-python/rospkg/rospkg-1.2.0.ebuild index bb6a7366b4ad..49c3524f1d4a 100644 --- a/dev-python/rospkg/rospkg-1.2.0.ebuild +++ b/dev-python/rospkg/rospkg-1.2.0.ebuild @@ -42,7 +42,7 @@ DEPEND="${RDEPEND} ${BDEPEND} dev-python/mock[${PYTHON_USEDEP}] ) " -PATCHES=( "${FILESDIR}/gentoo.patch" ) +PATCHES=( "${FILESDIR}/gentoo.patch" "${FILESDIR}/yaml_load.patch" ) python_test() { nosetests --with-coverage --cover-package=rospkg --with-xunit test || die diff --git a/dev-python/rospkg/rospkg-9999.ebuild b/dev-python/rospkg/rospkg-9999.ebuild index bb6a7366b4ad..49c3524f1d4a 100644 --- a/dev-python/rospkg/rospkg-9999.ebuild +++ b/dev-python/rospkg/rospkg-9999.ebuild @@ -42,7 +42,7 @@ DEPEND="${RDEPEND} ${BDEPEND} dev-python/mock[${PYTHON_USEDEP}] ) " -PATCHES=( "${FILESDIR}/gentoo.patch" ) +PATCHES=( "${FILESDIR}/gentoo.patch" "${FILESDIR}/yaml_load.patch" ) python_test() { nosetests --with-coverage --cover-package=rospkg --with-xunit test || die -- 2.26.2