From 48f3f4a7d300c7c9f93dc00a4bd86ef8803d157d Mon Sep 17 00:00:00 2001 From: Syres916 <46537884+Syres916@users.noreply.github.com> Date: Tue, 26 Dec 2023 11:54:29 +0000 Subject: [PATCH] [Gears] Allow for both Python 3.11 and above as... well as 3.10 and below as they are all currently supported by FreeCAD core. --- freecad/gears/features.py | 37 +++++++++++++++++++++++++++---------- 1 file changed, 27 insertions(+), 10 deletions(-) diff --git a/freecad/gears/features.py b/freecad/gears/features.py index 89acb12..300170f 100644 --- a/freecad/gears/features.py +++ b/freecad/gears/features.py @@ -18,6 +18,7 @@ from __future__ import division import os +import sys import numpy as np import math @@ -94,13 +95,22 @@ class ViewProviderGear(object): self._check_attr() return self.icon_fn - def dumps(self): - self._check_attr() - return {"icon_fn": self.icon_fn} + if sys.version_info[0] == 3 and sys.version_info[1] >= 11: + def dumps(self): + self._check_attr() + return {"icon_fn": self.icon_fn} - def loads(self, state): - if state and "icon_fn" in state: - self.icon_fn = state["icon_fn"] + def loads(self, state): + if state and "icon_fn" in state: + self.icon_fn = state["icon_fn"] + else: + def __getstate__(self): + self._check_attr() + return {"icon_fn": self.icon_fn} + + def __setstate__(self, state): + if state and "icon_fn" in state: + self.icon_fn = state["icon_fn"] class BaseGear(object): @@ -147,11 +157,18 @@ class BaseGear(object): """ raise NotImplementedError("generate_gear_shape not implemented") - def loads(self, state): - pass + if sys.version_info[0] == 3 and sys.version_info[1] >= 11: + def loads(self, state): + pass - def dumps(self): - pass + def dumps(self): + pass + else: + def __setstate__(self, state): + pass + + def __getstate__(self): + pass class InvoluteGear(BaseGear):