Scripted generation of circle yields error only in B.Mask

my first experiments creating solder mask openings revealed “unexpected behavior”:

def circle(x, y, d):
    circle = pcbnew.PCB_SHAPE()
    circle.SetShape(pcbnew.S_CIRCLE)
    circle.SetWidth(1413) # nanometers
    circle.SetCenter(pcbnew.VECTOR2I(pcbnew.FromMM(x), pcbnew.FromMM(y)))
    circle.SetRadius(pcbnew.FromMM(d/2))
    circle.SetFilled(True)
    circle.SetLayer(pcbnew.F_Mask)
    pcbnew.GetBoard().Add(circle)
    pcbnew.Refresh()

seems to work as expected: I get a round shape in F.Mask which I can select, move, delete.

But if I change F_Mask to B_Mask, I get the following when I click the circle:
circle_of_death

Regardless of my selection, the doubled circle is selected. I can’t delete it, and the systems seems to get unstable.

Using “circle.SetLayer(38)” shows no problems.

What could be the difference between “circle.SetLayer(pcbnew.B_Mask)” and “circle.SetLayer(38)”?

And why does it happen only with pcbnew.B_Mask and not with pcbnew.F_Mask?

Disregard: It seems there was a conflicting definition of circle() in my code.

What is the best way / the convention in this forum to deal with such wrong posts: Delete, edit, comment (as currently)?

If I delete the original post, it wouldn’t do any more harm, but it might annoy people who have already read it.

Don’t delete. If you find the solution by yourself you can mark your post as Solution.

Even “wrong” questions may be beneficial for others, and deleting valid posts just causes confusion.

I agree that removing posts is confusing/annoying.

The subject is likely misleading since I misinterpreted my observations.