<H2>Script:</H2>


    import bpy
    import math
    
    def test_fn2(pose_bone):
        rig = pose_bone.id_data
        mat = rig.matrix_world @ pose_bone.matrix
        vec = mat.col[1].normalized()
        angle = math.degrees(math.acos(vec[2]))
        return angle
    
    bpy.app.driver_namespace["test_fn2"] = test_fn2

<H2>Settings:</H2>

Turn on [tag:Register] in Text Editor. And *Auto Run Python Scripts* in User Preferences if you need.

    Expression: test_fn2(bones["Bone"])/45

[![enter image description here][1]][1]

Additions: <br>
Original script has two mistakes.<br>
1. Transformation matrix for converting to world space is 

    object.matrix_world @ pose_bone.matrix
2. Vector myvec needs to be normalized. <br>


  [1]: https://i.sstatic.net/GiEfq.jpg