From fb7b7aa7f9dbcb0c0ecc8a3ed4f9c41dc7e4a6e3 Mon Sep 17 00:00:00 2001 From: bourgesl Date: Mon, 15 Jul 2019 13:45:23 +0200 Subject: [PATCH 1/2] pickle support: try dump after load in test_base --- gitlab/tests/test_base.py | 1 + 1 file changed, 1 insertion(+) diff --git a/gitlab/tests/test_base.py b/gitlab/tests/test_base.py index 2526bee5d..47eda6c19 100644 --- a/gitlab/tests/test_base.py +++ b/gitlab/tests/test_base.py @@ -93,6 +93,7 @@ def test_pickability(self): self.assertIsInstance(unpickled, FakeObject) self.assertTrue(hasattr(unpickled, "_module")) self.assertEqual(unpickled._module, original_obj_module) + pickled2 = pickle.dumps(unpickled) def test_attrs(self): obj = FakeObject(self.manager, {"foo": "bar"}) From 3f5d0e561b171d475df118b1a5c1045e69336760 Mon Sep 17 00:00:00 2001 From: bourgesl Date: Mon, 15 Jul 2019 14:32:08 +0200 Subject: [PATCH 2/2] fixed pickle support: use __dict[_module] instead of self._module as set_attr() is present --- gitlab/base.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gitlab/base.py b/gitlab/base.py index d2e44b8ae..f81d03989 100644 --- a/gitlab/base.py +++ b/gitlab/base.py @@ -52,7 +52,7 @@ def __getstate__(self): def __setstate__(self, state): module_name = state.pop("_module_name") self.__dict__.update(state) - self._module = importlib.import_module(module_name) + self.__dict__["_module"] = importlib.import_module(module_name) def __getattr__(self, name): try: