@@ -32,6 +32,10 @@ def __init__(self, bugzilla, bug_id=None, dict=None, autorefresh=False):
3232 self ._rawdata = {}
3333 self .autorefresh = autorefresh
3434
35+ # pylint: disable=protected-access
36+ self ._aliases = self .bugzilla ._get_bug_aliases ()
37+ # pylint: enable=protected-access
38+
3539 if not dict :
3640 dict = {}
3741 if bug_id :
@@ -59,8 +63,10 @@ def __unicode__(self):
5963 self .assigned_to , self .summary )
6064
6165 def __repr__ (self ):
62- return '<Bug #%i on %s at %#x>' % (self .bug_id , self .bugzilla .url ,
63- id (self ))
66+ url = ""
67+ if self .bugzilla :
68+ url = self .bugzilla .url
69+ return '<Bug #%i on %s at %#x>' % (self .bug_id , url , id (self ))
6470
6571 def __getattr__ (self , name ):
6672 refreshed = False
@@ -70,11 +76,7 @@ def __getattr__(self, name):
7076 # have never been called.
7177 return self .__dict__ [name ]
7278
73- # pylint: disable=protected-access
74- aliases = self .bugzilla ._get_bug_aliases ()
75- # pylint: enable=protected-access
76-
77- for newname , oldname in aliases :
79+ for newname , oldname in self ._aliases :
7880 if name == oldname and newname in self .__dict__ :
7981 return self .__dict__ [newname ]
8082
@@ -120,16 +122,10 @@ def refresh(self, include_fields=None, exclude_fields=None,
120122 reload = refresh
121123
122124 def _translate_dict (self , newdict ):
123- if not self .bugzilla :
124- return
125-
126- self .bugzilla .post_translation ({}, newdict )
127-
128- # pylint: disable=protected-access
129- aliases = self .bugzilla ._get_bug_aliases ()
130- # pylint: enable=protected-access
125+ if self .bugzilla :
126+ self .bugzilla .post_translation ({}, newdict )
131127
132- for newname , oldname in aliases :
128+ for newname , oldname in self . _aliases :
133129 if oldname not in newdict :
134130 continue
135131
@@ -161,11 +157,15 @@ def _update_dict(self, newdict):
161157 ##################
162158
163159 def __getstate__ (self ):
164- return self ._rawdata
160+ ret = self ._rawdata .copy ()
161+ ret ["_aliases" ] = self ._aliases
162+ return ret
165163
166164 def __setstate__ (self , vals ):
167165 self ._rawdata = {}
168166 self .bugzilla = None
167+ self ._aliases = vals .get ("_aliases" , [])
168+ self .autorefresh = False
169169 self ._update_dict (vals )
170170
171171
0 commit comments