I found a workaround for this now. Previously I was doing
bug = self.launchpad.bugs[id]
for a in bug.attachments: if a.title in (...): try: a.removeFromBug() except HTTPError: pass # workaround for 404 error, see LP #315387
# MARKER1 if not bug.duplicate_of: bug.duplicate_of = master
self.launchpad.lp_save() # MARKER2
This gave me the afforementioned 412 error. After a looong time of fiddling, I found out the following:
* Deleting attachmends and then changing properties leads to this error in lp_save() * Calling lp_save() twice in a row leads to this error.
So what I did to circumvent the crash:
* at MARKER1: get a new bug object with "bug = self.launchpad.bugs[id]"
* at MARKER2:
if bug._dirty_attributes: # avoid "412: Precondition Failed" bug.lp_save()
I really shouldn't have to explicitly query a private attribute (_dirty_attributes). If it's empty, lp_save() should just be a no-op.
I found a workaround for this now. Previously I was doing
bug = self.launchpad. bugs[id]
for a in bug.attachments:
try:
a.removeFrom Bug()
except HTTPError:
pass # workaround for 404 error, see LP #315387
if a.title in (...):
# MARKER1
bug.duplicate _of = master
if not bug.duplicate_of:
This gave me the afforementioned 412 error. After a looong time of fiddling, I found out the following:
* Deleting attachmends and then changing properties leads to this error in lp_save()
* Calling lp_save() twice in a row leads to this error.
So what I did to circumvent the crash:
* at MARKER1: get a new bug object with "bug = self.launchpad. bugs[id] "
* at MARKER2:
if bug._dirty_ attributes: # avoid "412: Precondition Failed"
bug. lp_save( )
I really shouldn't have to explicitly query a private attribute (_dirty_ attributes) . If it's empty, lp_save() should just be a no-op.