Armature bones created in python disappear after exiting edit mode
At the point of creation, the new bone's head and tail is both (0, 0, 0), which gives zero (invalid) length. You only need to modify at least one of them, giving a valid length, to keep the new bone outside of Edit mode:

&gt;&gt;&gt; bone = C.object.data.edit_bones.new("test")
&gt;&gt;&gt; bone.head = (0, 1, 0)
&gt;&gt;&gt; bone.tail = (1, 1, 0)
&gt;&gt;&gt; bpy.ops.object.mode_set(mode='OBJECT')
# The new bone won't disappear after exiting edit mode.