Skip to content

Unpickling Bug object breaks repr(bug) and str(bug) #105

@ehabkost

Description

@ehabkost

Version: python-bugzilla-2.3.0

After pickling and unpickling a Bug object, repr(b) and str(b) start crashing:

>>> import bugzilla, pickle
>>> bz = bugzilla.Bugzilla('https://partner-bugzilla.redhat.com')
>>> b = bz.getbug(123)
>>> repr(b)
'<Bug #123 on https://partner-bugzilla.redhat.com/xmlrpc.cgi at 0x7f00b12b5390>'
>>> str(b)
'#123    CLOSED     - Jeff Johnson - netstat -M problem'
>>> b = pickle.loads(pickle.dumps(b))
>>> repr(b)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/ehabkost/rh/proj/virt/virtreporting/virtualenv/lib64/python3.7/site-packages/bugzilla/bug.py", line 71, in __repr__
    return '<Bug #%i on %s at %#x>' % (self.bug_id, self.bugzilla.url,
  File "/home/ehabkost/rh/proj/virt/virtreporting/virtualenv/lib64/python3.7/site-packages/bugzilla/bug.py", line 83, in __getattr__
    aliases = self.bugzilla._get_bug_aliases()
AttributeError: 'NoneType' object has no attribute '_get_bug_aliases'
>>> str(b)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/ehabkost/rh/proj/virt/virtreporting/virtualenv/lib64/python3.7/site-packages/bugzilla/bug.py", line 58, in __str__
    return self.__unicode__()
  File "/home/ehabkost/rh/proj/virt/virtreporting/virtualenv/lib64/python3.7/site-packages/bugzilla/bug.py", line 67, in __unicode__
    return "#%-6s %-10s - %s - %s" % (self.bug_id, self.bug_status,
  File "/home/ehabkost/rh/proj/virt/virtreporting/virtualenv/lib64/python3.7/site-packages/bugzilla/bug.py", line 83, in __getattr__
    aliases = self.bugzilla._get_bug_aliases()
AttributeError: 'NoneType' object has no attribute '_get_bug_aliases'
>>> 

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions