Commits

Matt Chaput  committed 607b731

Add fix for missing attributes on pickled instances. Fixes issue #348

  • Participants
  • Parent commits 6be535a

Comments (0)

Files changed (1)

File src/whoosh/fields.py

         self.signed = signed
         self.analyzer = analysis.IDAnalyzer()
         self.format = formats.Existence(field_boost=field_boost)
-
-        # Calculate the minimum and maximum possible values for error checking
-        self.min_value = from_sortable(numtype, bits, signed, 0)
-        self.max_value = from_sortable(numtype, bits, signed, 2 ** bits - 1)
+        self.min_value, self.max_value = self._min_max()
 
         # Column configuration
         if default is None:
     def __setstate__(self, d):
         self.__dict__.update(d)
         self._struct = struct.Struct(">" + self.sortable_typecode)
+        if "min_value" not in d:
+            d["min_value"], d["max_value"] = self._min_max()
+
+    def _min_max(self):
+        numtype = self.numtype
+        bits = self.bits
+        signed = self.signed
+
+        # Calculate the minimum and maximum possible values for error checking
+        min_value = from_sortable(numtype, bits, signed, 0)
+        max_value = from_sortable(numtype, bits, signed, 2 ** bits - 1)
+
+        return min_value, max_value
 
     def default_column(self):
         return columns.NumericColumn(self.sortable_typecode,