Using Blender's Python API to get parent bone names
Since parent as a property is always present (being either an object or None and objects always have a name) you can make a ternary conditional inside the print since it's the second access that causes issues not the first (accessing the parent's name not accesing the parent itself).

print('%s, %s' %(bone.name, bone.parent.name if bone.parent else "No Parent"))


When updating the property, similarly you can simply check or place it inside a try/except block:

if bone.parent:
     bone.parent.name = ""


or

try:
     bone.parent.name = ""
except:
     pass