[py] fix reference counting of exception types (thanks @wackou)