Parent object to a bone and object becomes offsets! How do I prevent object from moving?
I have just tested batFINGER's code in Blender 2.79b, there is a bug in the formula.

When you multiply armature's world matrix with pose bone's object space matrix, you actually reached the bone head, not the bone tip, so you need to walk a bone's length to the bone tip, which is the origin of the pose bone.

Pose bone has a 'head' property and a 'tail' property, so we can calculate the bone vector, which equals to bone.tail minus bone.head.

I have verified the code in my project, it works correctly.

Here is the bug fixed version:

import bpy
context = bpy.context
from mathutils import Matrix
scene = context.scene
armature = scene.objects.get("Armature")
cube = scene.objects.get("Cube")

if cube and armature:
    cube.parent = armature
    bone = armature.pose.bones.get("Bone")
    cube.parent_bone = bone.name
    cube.parent_type = 'BONE'
    # keep current location
    cube.matrix_parent_inverse = (armature.matrix_world * Matrix.Translation(bone.tail - bone.head) * bone.matrix).inverted()