~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/lazy_regex.py

  • Committer: Jelmer Vernooij
  • Date: 2011-11-21 16:02:13 UTC
  • mto: This revision was merged to the branch mainline in revision 6285.
  • Revision ID: jelmer@samba.org-20111121160213-w3w6jkfps6s091gq
Allow lazy_regex.lazy_compile patterns to be pickled.

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