~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/lazy_regex.py

  • Committer: Patch Queue Manager
  • Date: 2011-11-23 14:11:03 UTC
  • mfrom: (6282.1.1 pickle-lazy-regex)
  • Revision ID: pqm@pqm.ubuntu.com-20111123141103-afx95vxa2t07ijy6
(jelmer) Support pickling lazy_regex patterns. (Jelmer Vernooij)

Show diffs side-by-side

added added

removed removed

Lines of Context:
71
71
            # cleaner message to the user.
72
72
            raise errors.InvalidPattern('"' + args[0] + '" ' +str(e))
73
73
 
 
74
    def __getstate__(self):
 
75
        """Return the state to use when pickling."""
 
76
        return {
 
77
            "args": self._regex_args,
 
78
            "kwargs": self._regex_kwargs,
 
79
            }
 
80
 
 
81
    def __setstate__(self, dict):
 
82
        """Restore from a pickled state."""
 
83
        self._real_regex = None
 
84
        setattr(self, "_regex_args", dict["args"])
 
85
        setattr(self, "_regex_kwargs", dict["kwargs"])
 
86
 
74
87
    def __getattr__(self, attr):
75
88
        """Return a member from the proxied regex object.
76
89