How can I script moving bone constraints up the constraints stack? I'm running into walls trying to reorder the bone constraints stack on blender 2.78.

I have an armature for which I want to re-order bone constraints on every bone. The way to do this seems to be to use 

bpy.ops.constraint.move_up(constraint=name, owner='BONE')


Where name is the name of the constraint.

I'm assuming I need to be in pose mode and I need to select the bone I want to operate on, so:

bpy.ops.object.mode_set(mode = 'POSE')
bone = bpy.context.active_object.pose.bones['the_bone_i_want']
bone.bone.select = True
bpy.ops.constraint.move_up(constraint=name, owner='BONE')


This produces a RuntimeError: Operator bpy.ops.constraint.move_up.poll() Context missing 'constraint'

OK, so I'm in the wrong context. Why? Which context has the necessary constraint?

I also thought about changing the active area to the properties beforehand, like this:

bpy.context.area.type = 'PROPERTIES'


This does change the active area, but doesn't get rid of the error message.

Can anyone point out what I'm doing wrong, or give me a way to reorder bone constraints that works?
This can now be done without bpy.ops.

bone.constraints.move(from_index, to_index)

https://docs.blender.org/api/current/bpy.types.ObjectConstraints.html?highlight=constraints%20move#bpy.types.ObjectConstraints.move