diff --git a/kubernetes/client/api_client.py b/kubernetes/client/api_client.py index c1b015fff7..d553aef6f8 100644 --- a/kubernetes/client/api_client.py +++ b/kubernetes/client/api_client.py @@ -626,6 +626,8 @@ def __deserialize_model(self, data, klass): and instance.attribute_map[attr] in data\ and isinstance(data, (list, dict)): value = data[instance.attribute_map[attr]] + if value is None: + value = [] if isinstance(data, list) else {} setattr(instance, attr, self.__deserialize(value, attr_type)) return instance diff --git a/kubernetes/e2e_test/test_client.py b/kubernetes/e2e_test/test_client.py index e23cf0c48b..5ccdf3c8fb 100644 --- a/kubernetes/e2e_test/test_client.py +++ b/kubernetes/e2e_test/test_client.py @@ -187,6 +187,8 @@ def test_configmap_apis(self): resp = api.delete_namespaced_config_map( name='test-configmap', body={}, namespace='default') + resp = api.list_namespaced_config_map('kube-system', pretty=True) + self.assertEqual([], resp.items) @unittest.skipUnless( _is_k8s_running(), "Kubernetes is not available")