I had the same question here: https://forums.halite.io/t/ships-not-docking/815/9
getOwner returns a player object if it is owned, otherwise it returns None. If you want to attack an enemy planet I suggest doing something like.
if planet.owner and planet.owner.id == game_map.my_id: # attack planet
This will check if the planet has an owner and if it isn't you, run your attack it code.
It is important to have "if planet.owner" first because if you try to check the id of a planet without owner, you will get the error, "cannot get property id of NoneType"