For what I recall (:D) changing mode set to OBJECT ( bpy.ops.object.mode_set(mode='OBJECT')) is needed to save the changes made to the armature.
While testing urdfToBlender w/ @randaz81 with Blender 4.x, edit_bones structure is cleared when changing the mode set, making crash the script.
With Blender 3.x it works just fine, probably they made a breaking change in the API.