nebius/SWE-rebench-V2-PRs huggingface dataset:
Repository: tomplus/kubernetes_asyncio
Pull request #57 (2019-01-08 21:28:49)

feat: use yaml.safe_load/dump
Use safer methods to load/dump yaml.

Porting: https://github.com/kubernetes-client/python-base/pull/111


Patch:
diff --git a/kubernetes_asyncio/config/kube_config.py b/kubernetes_asyncio/config/kube_config.py
index 0be8a850..b5bc48c8 100644
--- a/kubernetes_asyncio/config/kube_config.py
+++ b/kubernetes_asyncio/config/kube_config.py
@@ -426,7 +426,7 @@ class ConfigNode(object):
 def _get_kube_config_loader_for_yaml_file(filename, **kwargs):
     with open(filename) as f:
         return KubeConfigLoader(
-            config_dict=yaml.load(f),
+            config_dict=yaml.safe_load(f),
             config_base_path=os.path.abspath(os.path.dirname(filename)),
             **kwargs)
 


Test patch:
diff --git a/kubernetes_asyncio/config/kube_config_test.py b/kubernetes_asyncio/config/kube_config_test.py
index 8f0cc63f..36552657 100644
--- a/kubernetes_asyncio/config/kube_config_test.py
+++ b/kubernetes_asyncio/config/kube_config_test.py
@@ -853,7 +853,7 @@ class TestKubeConfigLoader(BaseTestCase):
     async def test_load_kube_config(self):
         expected = FakeConfig(host=TEST_HOST,
                               token=BEARER_TOKEN_FORMAT % TEST_DATA_BASE64)
-        config_file = self._create_temp_file(yaml.dump(self.TEST_KUBE_CONFIG))
+        config_file = self._create_temp_file(yaml.safe_dump(self.TEST_KUBE_CONFIG))
         actual = FakeConfig()
         await load_kube_config(config_file=config_file,
                                context="simple_token",
@@ -861,7 +861,7 @@ class TestKubeConfigLoader(BaseTestCase):
         self.assertEqual(expected, actual)
 
     def test_list_kube_config_contexts(self):
-        config_file = self._create_temp_file(yaml.dump(self.TEST_KUBE_CONFIG))
+        config_file = self._create_temp_file(yaml.safe_dump(self.TEST_KUBE_CONFIG))
         contexts, active_context = list_kube_config_contexts(
             config_file=config_file)
         self.assertDictEqual(self.TEST_KUBE_CONFIG['contexts'][0],
@@ -874,7 +874,7 @@ class TestKubeConfigLoader(BaseTestCase):
                                   contexts)
 
     async def test_new_client_from_config(self):
-        config_file = self._create_temp_file(yaml.dump(self.TEST_KUBE_CONFIG))
+        config_file = self._create_temp_file(yaml.safe_dump(self.TEST_KUBE_CONFIG))
         client = await new_client_from_config(
             config_file=config_file, context="simple_token")
         self.assertEqual(TEST_HOST, client.configuration.host)
diff --git a/kubernetes_asyncio/e2e_test/test_extensions.py b/kubernetes_asyncio/e2e_test/test_extensions.py
index 15b24684..743ad08d 100644
--- a/kubernetes_asyncio/e2e_test/test_extensions.py
+++ b/kubernetes_asyncio/e2e_test/test_extensions.py
@@ -51,7 +51,7 @@ spec:
         - containerPort: 80
 '''
         resp = await api.create_namespaced_deployment(
-            body=yaml.load(deployment % name),
+            body=yaml.safe_load(deployment % name),
             namespace="default")
         resp = await api.read_namespaced_deployment(name, 'default')
         self.assertIsNotNone(resp)